| 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/Site/ |
Upload File : |
<?php
/*******************************************************************************
* Copyright (c) 2019, Code Atlantic LLC
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Post_Types
*/
class PUM_Site_Popups {
/**
* @var PUM_Popup|null
*
* @deprecated 1.8.0
*/
public static $current;
/**
* @var WP_Query|null
*/
public static $loaded;
/**
* @var array
*/
public static $cached_content = array();
/**
* @var array
*/
public static $loaded_ids = array();
/**
* Hook the initialize method to the WP init action.
*/
public static function init() {
// Preload the $loaded query.
add_action( 'init', array( __CLASS__, 'get_loaded_popups' ) );
// TODO determine if the late priority is needed.
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_popups' ), 11 );
add_action( 'wp_footer', array( __CLASS__, 'render_popups' ) );
}
/**
* Returns the current popup.
*
* @deprecated 1.8.0
*
* @param bool|object|null $new_popup
*
* @return null|PUM_Popup
*/
public static function current_popup( $new_popup = false ) {
global $popup;
if ( $new_popup !== false ) {
pum()->current_popup = $new_popup;
$popup = $new_popup;
}
return pum()->current_popup;
}
/**
* Gets the loaded popup query.
*
* @return null|WP_Query
*/
public static function get_loaded_popups() {
if ( ! self::$loaded instanceof WP_Query ) {
self::$loaded = new WP_Query();
self::$loaded->posts = array();
}
return self::$loaded;
}
/**
* Preload popups in the head and determine if they will be rendered or not.
*
* @uses `pum_preload_popup` filter
* @uses `popmake_preload_popup` filter
*/
public static function load_popups() {
if ( is_admin() ) {
return;
}
$popups = pum_get_all_popups();
if ( ! empty( $popups ) ) {
foreach ( $popups as $popup ) {
// Set this popup as the global $current.
pum()->current_popup = $popup;
// If the popup is loadable (passes conditions) load it.
if ( pum_is_popup_loadable( $popup->ID ) ) {
self::preload_popup( $popup );
}
}
// Clear the global $current.
pum()->current_popup = null;
}
}
/**
* @param PUM_Model_Popup $popup
*/
public static function preload_popup( $popup ) {
// Add to the $loaded_ids list.
self::$loaded_ids[] = $popup->ID;
// Add to the $loaded query.
self::$loaded->posts[] = $popup;
self::$loaded->post_count ++;
// Preprocess the content for shortcodes that need to enqueue their own assets.
self::$cached_content[ $popup->ID ] = $popup->get_content();
// Fire off preload action.
do_action( 'pum_preload_popup', $popup->ID );
// Deprecated filter.
do_action( 'popmake_preload_popup', $popup->ID );
}
// REWRITE THIS
public static function load_popup( $id ) {
if ( did_action( 'wp_head' ) && ! in_array( $id, self::$loaded_ids ) ) {
$args1 = array(
'post_type' => 'popup',
'p' => $id,
);
$query = new WP_Query( $args1 );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->next_post();
pum()->current_popup = $query->post;
self::preload_popup( $query->post );
endwhile;
pum()->current_popup = null;
}
}
return;
}
/**
* Render the popups in the footer.
*/
public static function render_popups() {
$loaded = self::get_loaded_popups();
if ( $loaded->have_posts() ) {
while ( $loaded->have_posts() ) : $loaded->next_post();
pum()->current_popup = $loaded->post;
pum_template_part( 'popup' );
endwhile;
pum()->current_popup = null;
}
}
/**
* @param $popup_id
*
* @return string|bool
*/
public static function get_cache_content( $popup_id ) {
return isset( self::$cached_content[ $popup_id ] ) ? self::$cached_content[ $popup_id ] : false;
}
}