403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.217.224.44
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/includes/tracks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/includes/tracks/class-kkart-tracks-footer-pixel.php
<?php
/**
 * Send Tracks events on behalf of a user using pixel images in page footer.
 *
 * @package Kkart\Tracks
 */

defined( 'ABSPATH' ) || exit;

/**
 * KKART_Tracks_Footer_Pixel class.
 */
class KKART_Tracks_Footer_Pixel {
	/**
	 * Singleton instance.
	 *
	 * @var KKART_Tracks_Footer_Pixel
	 */
	protected static $instance = null;

	/**
	 * Events to send to Tracks.
	 *
	 * @var array
	 */
	protected $events = array();

	/**
	 * Instantiate the singleton.
	 *
	 * @return KKART_Tracks_Footer_Pixel
	 */
	public static function instance() {
		if ( is_null( self::$instance ) ) {
			self::$instance = new KKART_Tracks_Footer_Pixel();
		}

		return self::$instance;
	}

	/**
	 * Constructor - attach hooks to the singleton instance.
	 */
	public function __construct() {
		add_action( 'admin_footer', array( $this, 'render_tracking_pixels' ) );
		add_action( 'shutdown', array( $this, 'send_tracks_requests' ) );
	}

	/**
	 * Record a Tracks event
	 *
	 * @param  array $event Array of event properties.
	 * @return bool|WP_Error True on success, WP_Error on failure.
	 */
	public static function record_event( $event ) {
		if ( ! $event instanceof KKART_Tracks_Event ) {
			$event = new KKART_Tracks_Event( $event );
		}

		if ( is_wp_error( $event ) ) {
			return $event;
		}

		self::instance()->add_event( $event );

		return true;
	}

	/**
	 * Add a Tracks event to the queue.
	 *
	 * @param KKART_Tracks_Event $event Event to track.
	 */
	public function add_event( $event ) {
		$this->events[] = $event;
	}

	/**
	 * Add events as tracking pixels to page footer.
	 */
	public function render_tracking_pixels() {
		if ( empty( $this->events ) ) {
			return;
		}

		foreach ( $this->events as $event ) {
			$pixel = $event->build_pixel_url();

			if ( ! $pixel ) {
				continue;
			}

			echo '<img style="position: fixed;" src="', esc_url( $pixel ), '" />';
		}

		$this->events = array();
	}

	/**
	 * Fire off API calls for events that weren't converted to pixels.
	 *
	 * This handles wp_redirect().
	 */
	public function send_tracks_requests() {
		if ( empty( $this->events ) ) {
			return;
		}

		foreach ( $this->events as $event ) {
			KKART_Tracks_Client::record_event( $event );
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit