Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.219.178.243
Web Server : Apache/2.4.61 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/wordpress/wp-content/plugins/cookie-notice/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/wordpress/wp-content/plugins/cookie-notice/includes/welcome-frontend.php
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
	exit;

/**
 * Cookie_Notice_Welcome_Frontend class.
 * 
 * @class Cookie_Notice_Welcome_Frontend
 */
class Cookie_Notice_Welcome_Frontend {
	private $widget_url = '';
	private $preview_mode = false;

	/**
	 * Constructor.
	 *
	 * @return void
	 */
	public function __construct() {
		add_action( 'after_setup_theme', array( $this, 'preview_init' ), 1 );
		
		$this->widget_url = '//cdn.hu-manity.co/hu-banner.min.js';
	}

	/**
	 * Initialize preview mode.
	 */
	public function preview_init() {
		// check preview mode
		$this->preview_mode = isset( $_GET['cn_preview_mode'] ) ? absint( $_GET['cn_preview_mode'] ) : false;

		if ( $this->preview_mode !== false ) {
			// filters
			add_filter( 'show_admin_bar', '__return_false' );
			add_filter( 'cn_cookie_notice_output', '__return_false', 1000 );
			
			// actions
			add_action( 'wp_enqueue_scripts', array( $this, 'wp_dequeue_scripts' ) );
			
			// only in live preview
			if ( $this->preview_mode === 1 ) {
				add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
				add_action( 'wp_head', array( $this, 'wp_head_scripts' ), 0 );
			} 
		}
	}

	/**
	 * Load scripts and styles.
	 *
	 * @return void
	 */
	public function wp_enqueue_scripts( $page ) {
		// show only in live preview
		if ( $this->preview_mode === 1 ) {
			wp_enqueue_script( 'cookie-notice-welcome-frontend', plugins_url( '../js/front-welcome.js', __FILE__ ), array( 'jquery', 'underscore' ), Cookie_Notice()->defaults['version'] );

			wp_localize_script(
				'cookie-notice-welcome-frontend',
				'cnFrontWelcome',
				array(
					'previewMode'	=> $this->preview_mode,
					'allowedURLs'	=> $this->get_allowed_urls(),
					'levelNames' => Cookie_Notice()->settings->level_names,
					'textStrings' => Cookie_Notice()->settings->text_strings
				)
			);
		}
	}
	
	/**
	 * Unload scripts and styles.
	 *
	 * @return void
	 */
	public function wp_dequeue_scripts( $page ) {
		// deregister native CN
		wp_dequeue_script( 'cookie-notice-front' );
	}

	/**
	 * .
	 *
	 * @return void
	 */
	public function wp_head_scripts() {
		$options = array(
			'currentLanguage'	=> 'en',
			'previewMode'		=> true,
			'debugMode'			=> true,
			'config'			=> array(
				'privacyPaper' => true,
				'privacyContact' => true
			)
		);

		echo '
		<!-- Hu Banner -->
		<script type="text/javascript">
			var huOptions = ' . json_encode( $options ) . ';
		</script>
		<script type="text/javascript" src="' . $this->widget_url . '"></script>
		<style>.hu-preview-mode #hu::after {content: "";position: fixed;width: 100%;height: 100%;display: block;top: 0;left: 0;}</style>';
	}

	/**
	 * Get URLs allowed to be previewed.
	 *
	 * @return array
	 */
	public function get_allowed_urls() {
		$allowed_urls = array( home_url( '/' ) );

		if ( is_ssl() && ! $this->is_cross_domain() )
			$allowed_urls[] = home_url( '/', 'https' );

		return $allowed_urls;
	}

	/**
	 * Determines whether the admin and the frontend are on different domains.
	 *
	 * @return bool
	 */
	public function is_cross_domain() {
		$admin_origin = wp_parse_url( admin_url() );
		$home_origin = wp_parse_url( home_url() );

		return ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
	}
}

Anon7 - 2022
AnonSec Team