| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/popup-maker/classes/ |
Upload File : |
<?php
/*******************************************************************************
* Copyright (c) 2019, Code Atlantic LLC
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class PUM_Previews
*
* This class sets up the necessary changes to allow admins & editors to preview popups on the front end.
*/
class PUM_Previews {
/**
* Initiator method.
*/
public static function init() {
// add_filter( 'template_include', array( __CLASS__, 'template_include' ), 1000, 2 );
add_filter( 'pum_popup_is_loadable', array( __CLASS__, 'is_loadable' ), 1000, 2 );
add_filter( 'pum_popup_data_attr', array( __CLASS__, 'data_attr' ), 1000, 2 );
add_filter( 'pum_popup_get_public_settings', array( __CLASS__, 'get_public_settings' ), 1000, 2 );
}
/**
* This changes the template to a blank one to prevent duplicate content issues.
*
* @param $template
*
* @return string
*/
public static function template_include( $template ) {
if ( ! is_singular( 'popup' ) ) {
return $template;
}
return POPMAKE_DIR . 'templates/single-popup.php';
}
/**
* For popup previews this will force only the correct popup to load.
*
* @param bool $loadable
* @param int $popup_id
*
* @return bool
*/
public static function is_loadable( $loadable, $popup_id ) {
return self::should_preview_popup( $popup_id ) ? true : $loadable;
}
/**
* Sets the Popup Post Type public arg to true for content editors.
*
* This enables them to use the built in preview links.
*
* @param int $popup_id
*
* @return bool
*/
public static function should_preview_popup( $popup_id = 0 ) {
if ( defined( "DOING_AJAX" ) && DOING_AJAX ) {
return false;
}
if ( isset( $_GET['popup_preview'] ) && $_GET['popup_preview'] && isset( $_GET['popup'] ) ) {
static $popup;
if ( ! isset( $popup ) ) {
if ( is_numeric( $_GET['popup'] ) && absint( $_GET['popup'] ) > 0 ) {
$popup = absint( $_GET['popup'] );
} else {
$post = get_page_by_path( sanitize_text_field( $_GET['popup'] ), OBJECT, 'popup' );
$popup = $post->ID;
}
}
if ( $popup_id == $popup && current_user_can( 'edit_post', $popup ) ) {
return true;
}
}
return false;
}
/**
* On popup previews add an admin debug trigger.
*
* @param $data_attr
* @param $popup_id
*
* @return mixed
*/
public static function data_attr( $data_attr, $popup_id ) {
if ( ! self::should_preview_popup( $popup_id ) ) {
return $data_attr;
}
$data_attr['triggers'] = array(
array(
'type' => 'admin_debug',
),
);
return $data_attr;
}
/**
* On popup previews add an admin debug trigger.
*
* @param array $settings
* @param PUM_Model_Popup $popup
*
* @return array
*/
public static function get_public_settings( $settings, $popup ) {
if ( ! self::should_preview_popup( $popup->ID ) ) {
return $settings;
}
$settings['triggers'] = array(
array(
'type' => 'admin_debug',
),
);
return $settings;
}
}