SILENT KILLERPanel

Current Path: > home > transcarter > > public_html > > wp-content > plugins > LayerSlider > assets > classes


Operation   : Linux host59.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Software     : Apache
Server IP    : 198.54.126.42 | Your IP: 216.73.216.135
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/transcarter//public_html//wp-content/plugins/LayerSlider/assets/classes

NameTypeSizeLast ModifiedActions
class.km.autoupdate.plugins.v3.php File 1726 bytes March 10 2023 20:45:24.
class.km.autoupdate.v3.php File 16249 bytes March 10 2023 20:45:24.
class.ls.config.php File 2480 bytes March 10 2023 20:45:24.
class.ls.dom.php File 4008 bytes March 10 2023 20:45:24.
class.ls.elementor.php File 2533 bytes March 10 2023 20:45:24.
class.ls.elementor.widget.php File 4505 bytes March 10 2023 20:45:24.
class.ls.exportutil.php File 6149 bytes March 10 2023 20:45:24.
class.ls.filesystem.php File 1953 bytes March 10 2023 20:45:24.
class.ls.importutil.php File 9880 bytes March 10 2023 20:45:24.
class.ls.modulemanager.php File 4185 bytes March 10 2023 20:45:24.
class.ls.modules.php File 3000 bytes March 10 2023 20:45:24.
class.ls.notifications.php File 13031 bytes March 10 2023 20:45:24.
class.ls.popups.php File 4787 bytes March 10 2023 20:45:24.
class.ls.posts.php File 10320 bytes March 10 2023 20:45:24.
class.ls.remotedata.php File 2462 bytes March 10 2023 20:45:24.
class.ls.revisions.php File 6622 bytes March 10 2023 20:45:24.
class.ls.sliders.php File 21612 bytes March 10 2023 20:45:24.
class.ls.sources.php File 7556 bytes March 10 2023 20:45:24.
class.ls.templateutils.php File 6958 bytes March 10 2023 20:45:24.
class.ls.transitionpresets.php File 785 bytes March 10 2023 20:45:24.
class.ls.uninstaller.php File 4185 bytes March 10 2023 20:45:24.
index.php File 27 bytes March 10 2023 20:45:24.

Reading File: /home/transcarter//public_html//wp-content/plugins/LayerSlider/assets/classes/class.ls.popups.php

<?php

// Prevent direct file access
defined( 'LS_ROOT_FILE' ) || exit;

class LS_Popups {

	public static $index;
	public static $popups;
	public static $postType;
	public static $frontPage;

	public static $optionKey = 'ls-popup-index';


	/**
	 * Private constructor to prevent instantiate static class
	 *
	 * @since 6.5.0
	 * @access private
	 * @return void
	 */
	private function __construct() {

	}



	public static function init() {

		// Popup is an exclusive feature, don't try to initialize it
		// in case of unactivated sites.
		if( ! LS_Config::isActivatedSite() ) {
			return false;
		}

		// Init Popups data
		self::$index = get_option( self::$optionKey, [] );
		self::$popups = [];

		// Make sure that the Popup Index is an array
		if( ! is_array( self::$index ) ) {
			self::$index = [];
		}

		// Examine the Popup Index, see if there are popups
		// that needs to be automatically included on page
		// based on the user settings.
		if( ! is_admin() ) {
			add_action('wp', [ __CLASS__, 'setup' ] );
		}
	}


	public static function setup() {
		self::$postType = get_post_type();
		self::$frontPage = is_front_page();

		self::autoinclude();
		self::display();

		add_action('wp_footer', [ __CLASS__, 'render' ], 1);
	}



	public static function addIndex( $data ) {

		if( empty( $data ) || empty( $data['id'] ) ) {
			return false;
		}

		if( ! is_array( self::$index ) ) {
			self::$index = [];
		}

		self::$index[ $data['id'] ] = $data;
		update_option(self::$optionKey, self::$index);
	}



	public static function removeIndex( $id ) {

		if( ! is_array( self::$index ) ) {
			self::$index = [];
		}

		if( empty( $id ) || empty( self::$index[ $id ] ) ) {
			return false;
		}

		unset( self::$index[ $id ] );
		update_option(self::$optionKey, self::$index);
	}



	protected static function autoinclude() {

		if( is_array(self::$index) && ! empty( self::$index ) ) {
			foreach( self::$index as $key => $popup ) {

				// First time visitor
				if( $popup['first_time_visitor'] && ! empty($_COOKIE['ls-popup-last-displayed'] ) ) {
					continue;
				}

				// Repeat control
				if( ! $popup['repeat'] && ! empty( $_COOKIE['ls-popup-'.$popup['id']] ) ) {
					continue;

				} elseif( $popup['repeat'] && $popup['repeat_days'] !== '' ) {
					if( 0 === (int)$popup['repeat_days'] ) {
						if( ! empty($_COOKIE['ls-popup-last-displayed'] ) ) {
							continue;
						}

					} elseif( ! empty($_COOKIE['ls-popup-'.$popup['id']]) && $_COOKIE['ls-popup-'.$popup['id']] > time() - 60 * 60 * 24 * (int)$popup['repeat_days'] ) {
						continue;
					}
				}


				// User roles
				$user = wp_get_current_user();
				if(
					( empty( $user->ID ) && empty( $popup['roles']['visitor'] ) ) ||
					( ! empty($user->roles[0]) && empty( $popup['roles'][ $user->roles[0] ] ) )
				) {
					continue;
				}

				// Include pages
				if( ! empty( $popup['pages'] ) ) {
					if( ! self::checkPages( $popup['pages'] ) ) {
						continue;
					}
				}

				// Exclude pages
				if( ! empty( $popup['pages']['exclude'] ) ) {
					if( self::checkPages( $popup['pages']['exclude'] ) ) {
						continue;
					}
				}


				// Passed every test, include the Popup
				self::$popups[] = $popup;
			}
		}
	}



	protected static function checkPages( $pages ) {
		if( ! empty( $pages ) && is_array( $pages ) ) {

			if(
				$pages['all'] ||
				( $pages['home'] && self::$frontPage ) ||
				( ! empty( $pages[ self::$postType ] ) && ! self::$frontPage )
			) {

				return true;
			}

			$pages = $pages['custom'];
		}

		if( ! empty( $pages ) ) {
			$pages = explode(',', $pages);
			foreach( $pages as $page ) {

				$page = trim( $page );

				// Test for regular WP pages
				if( is_category( $page ) || is_page( $page ) || is_single( $page ) ) {
					return true;
				}

				// Test for WooCommerce pages
				if(
					( function_exists('is_product_category') && is_product_category( $page ) ) ||
					( function_exists('is_product_tag') && is_product_tag( $page ) )
				) {
					return true;
				}
			}
		}

		return false;
	}


	protected static function display( ) {

		if( ! empty(self::$popups) && is_array(self::$popups) ) {

			// Update the date of last displayed popup
			setcookie('ls-popup-last-displayed', time(), time()+60*60*24*30*24, '/');

			foreach( self::$popups as $popup ) {

				// Update the last opened date of this particular Popup
				// for the purpose of serving a repeat control.
				$expires = ( (int)$popup['repeat_days'] === 0 ) ? 0 : time() + 60*60*24*365;
				setcookie('ls-popup-'.$popup['id'], time(), $expires );
			}
		}
	}


	public static function render( ) {

		if( ! empty(self::$popups) && is_array(self::$popups) ) {
			foreach( self::$popups as $popup ) {
				layerslider( $popup['id'], '', [ 'popup' => true ] );
			}

		}
	}

}

SILENT KILLER Tool