Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/popup-ma.../trunk/classes/Shortcod...
File: Popup.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Shortcode for Popup
[2] Fix | Delete
*
[3] Fix | Delete
* @package PUM
[4] Fix | Delete
* @copyright Copyright (c) 2023, Code Atlantic LLC
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit;
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Class PUM_Shortcode_Popup
[13] Fix | Delete
*
[14] Fix | Delete
* Registers the popup_close shortcode.
[15] Fix | Delete
*/
[16] Fix | Delete
class PUM_Shortcode_Popup extends PUM_Shortcode {
[17] Fix | Delete
[18] Fix | Delete
public $version = 2;
[19] Fix | Delete
[20] Fix | Delete
public $has_content = true;
[21] Fix | Delete
[22] Fix | Delete
public $inner_content_priority = 15;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* The shortcode tag.
[26] Fix | Delete
*/
[27] Fix | Delete
public function tag() {
[28] Fix | Delete
return 'popup';
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
public function label() {
[32] Fix | Delete
return __( 'Popup', 'popup-maker' );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
public function description() {
[36] Fix | Delete
return __( 'Insert a popup inline rather. Great for simple popups used for supporting content.', 'popup-maker' );
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
public function inner_content_labels() {
[40] Fix | Delete
return [
[41] Fix | Delete
'label' => __( 'Content', 'popup-maker' ),
[42] Fix | Delete
'description' => __( 'Can contain other shortcodes, images, text or html content.', 'popup-maker' ),
[43] Fix | Delete
];
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
public function post_types() {
[47] Fix | Delete
return [];
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* @return array
[52] Fix | Delete
*/
[53] Fix | Delete
public function tabs() {
[54] Fix | Delete
return [
[55] Fix | Delete
'general' => __( 'General', 'popup-maker' ),
[56] Fix | Delete
'display' => __( 'Display', 'popup-maker' ),
[57] Fix | Delete
'position' => __( 'Position', 'popup-maker' ),
[58] Fix | Delete
'animation' => __( 'Animation', 'popup-maker' ),
[59] Fix | Delete
'close' => __( 'Close', 'popup-maker' ),
[60] Fix | Delete
];
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* @return array
[65] Fix | Delete
*/
[66] Fix | Delete
public function subtabs() {
[67] Fix | Delete
return apply_filters(
[68] Fix | Delete
'pum_sub_form_shortcode_subtabs',
[69] Fix | Delete
[
[70] Fix | Delete
'general' => [
[71] Fix | Delete
'main' => __( 'General', 'popup-maker' ),
[72] Fix | Delete
],
[73] Fix | Delete
'display' => [
[74] Fix | Delete
'main' => __( 'Display', 'popup-maker' ),
[75] Fix | Delete
],
[76] Fix | Delete
'position' => [
[77] Fix | Delete
'main' => __( 'Position', 'popup-maker' ),
[78] Fix | Delete
],
[79] Fix | Delete
'animation' => [
[80] Fix | Delete
'main' => __( 'Animation', 'popup-maker' ),
[81] Fix | Delete
],
[82] Fix | Delete
'close' => [
[83] Fix | Delete
'main' => __( 'Close', 'popup-maker' ),
[84] Fix | Delete
],
[85] Fix | Delete
]
[86] Fix | Delete
);
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
public function fields() {
[90] Fix | Delete
return [
[91] Fix | Delete
'general' => [
[92] Fix | Delete
'main' => [
[93] Fix | Delete
'id' => [
[94] Fix | Delete
'label' => __( 'Unique Popup ID', 'popup-maker' ),
[95] Fix | Delete
'placeholder' => __( '`offer`, `more-info`', 'popup-maker' ),
[96] Fix | Delete
'desc' => __( 'Used in popup triggers to target this popup', 'popup-maker' ),
[97] Fix | Delete
'priority' => 5,
[98] Fix | Delete
'required' => true,
[99] Fix | Delete
],
[100] Fix | Delete
'title' => [
[101] Fix | Delete
'label' => __( 'Popup Title', 'popup-maker' ),
[102] Fix | Delete
'placeholder' => __( 'Enter popup title text,', 'popup-maker' ),
[103] Fix | Delete
'desc' => __( 'This will be displayed above the content. Leave it empty to disable it.', 'popup-maker' ),
[104] Fix | Delete
'priority' => 10,
[105] Fix | Delete
],
[106] Fix | Delete
],
[107] Fix | Delete
],
[108] Fix | Delete
'display' => [
[109] Fix | Delete
'main' => [
[110] Fix | Delete
'theme_id' => [
[111] Fix | Delete
'type' => 'select',
[112] Fix | Delete
'label' => __( 'Popup Theme', 'popup-maker' ),
[113] Fix | Delete
'placeholder' => __( 'Choose a theme,', 'popup-maker' ),
[114] Fix | Delete
'desc' => __( 'Choose which popup theme will be used.', 'popup-maker' ),
[115] Fix | Delete
'std' => pum_get_default_theme_id(),
[116] Fix | Delete
'select2' => true,
[117] Fix | Delete
'options' => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
[118] Fix | Delete
'required' => true,
[119] Fix | Delete
'priority' => 5,
[120] Fix | Delete
],
[121] Fix | Delete
'overlay_disabled' => [
[122] Fix | Delete
'label' => __( 'Disable Overlay', 'popup-maker' ),
[123] Fix | Delete
'description' => __( 'Checking this will disable and hide the overlay for this popup.', 'popup-maker' ),
[124] Fix | Delete
'type' => 'checkbox',
[125] Fix | Delete
'std' => false,
[126] Fix | Delete
'priority' => 10,
[127] Fix | Delete
],
[128] Fix | Delete
'size' => [
[129] Fix | Delete
'label' => __( 'Size', 'popup-maker' ),
[130] Fix | Delete
'description' => __( 'Select the size of the popup.', 'popup-maker' ),
[131] Fix | Delete
'type' => 'select',
[132] Fix | Delete
'std' => 'small',
[133] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_popup_display_size_options', [] ) ),
[134] Fix | Delete
'priority' => 15,
[135] Fix | Delete
],
[136] Fix | Delete
'width' => [
[137] Fix | Delete
'label' => __( 'Width', 'popup-maker' ),
[138] Fix | Delete
'priority' => 20,
[139] Fix | Delete
],
[140] Fix | Delete
'width_unit' => [
[141] Fix | Delete
'label' => __( 'Width Unit', 'popup-maker' ),
[142] Fix | Delete
'type' => 'select',
[143] Fix | Delete
'std' => 'px',
[144] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
[145] Fix | Delete
'priority' => 25,
[146] Fix | Delete
],
[147] Fix | Delete
'height' => [
[148] Fix | Delete
'label' => __( 'Height', 'popup-maker' ),
[149] Fix | Delete
'priority' => 30,
[150] Fix | Delete
],
[151] Fix | Delete
'height_unit' => [
[152] Fix | Delete
'label' => __( 'Height Unit', 'popup-maker' ),
[153] Fix | Delete
'type' => 'select',
[154] Fix | Delete
'std' => 'px',
[155] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
[156] Fix | Delete
'priority' => 35,
[157] Fix | Delete
],
[158] Fix | Delete
],
[159] Fix | Delete
],
[160] Fix | Delete
'position' => [
[161] Fix | Delete
'main' => [
[162] Fix | Delete
'location' => [
[163] Fix | Delete
'label' => __( 'Location', 'popup-maker' ),
[164] Fix | Delete
'description' => __( 'Choose where the popup will be displayed.', 'popup-maker' ),
[165] Fix | Delete
'type' => 'select',
[166] Fix | Delete
'std' => 'center top',
[167] Fix | Delete
'priority' => 4,
[168] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_popup_display_location_options', [] ) ),
[169] Fix | Delete
],
[170] Fix | Delete
'position_top' => [
[171] Fix | Delete
'label' => __( 'Top', 'popup-maker' ),
[172] Fix | Delete
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
[173] Fix | Delete
'type' => 'rangeslider',
[174] Fix | Delete
'std' => 100,
[175] Fix | Delete
'priority' => 10,
[176] Fix | Delete
'step' => 1,
[177] Fix | Delete
'min' => 0,
[178] Fix | Delete
'max' => 500,
[179] Fix | Delete
'unit' => 'px',
[180] Fix | Delete
],
[181] Fix | Delete
'position_bottom' => [
[182] Fix | Delete
'label' => __( 'Bottom', 'popup-maker' ),
[183] Fix | Delete
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
[184] Fix | Delete
'type' => 'rangeslider',
[185] Fix | Delete
'std' => 0,
[186] Fix | Delete
'priority' => 10,
[187] Fix | Delete
'step' => 1,
[188] Fix | Delete
'min' => 0,
[189] Fix | Delete
'max' => 500,
[190] Fix | Delete
'unit' => 'px',
[191] Fix | Delete
],
[192] Fix | Delete
'position_left' => [
[193] Fix | Delete
'label' => __( 'Left', 'popup-maker' ),
[194] Fix | Delete
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
[195] Fix | Delete
'type' => 'rangeslider',
[196] Fix | Delete
'std' => 0,
[197] Fix | Delete
'priority' => 10,
[198] Fix | Delete
'step' => 1,
[199] Fix | Delete
'min' => 0,
[200] Fix | Delete
'max' => 500,
[201] Fix | Delete
'unit' => 'px',
[202] Fix | Delete
],
[203] Fix | Delete
'position_right' => [
[204] Fix | Delete
'label' => __( 'Right', 'popup-maker' ),
[205] Fix | Delete
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
[206] Fix | Delete
'type' => 'rangeslider',
[207] Fix | Delete
'std' => 0,
[208] Fix | Delete
'priority' => 10,
[209] Fix | Delete
'step' => 1,
[210] Fix | Delete
'min' => 0,
[211] Fix | Delete
'max' => 500,
[212] Fix | Delete
'unit' => 'px',
[213] Fix | Delete
],
[214] Fix | Delete
],
[215] Fix | Delete
],
[216] Fix | Delete
'animation' => [
[217] Fix | Delete
'main' => [
[218] Fix | Delete
'animation_type' => [
[219] Fix | Delete
'label' => __( 'Animation Type', 'popup-maker' ),
[220] Fix | Delete
'description' => __( 'Select an animation type for your popup.', 'popup-maker' ),
[221] Fix | Delete
'type' => 'select',
[222] Fix | Delete
'std' => 'fade',
[223] Fix | Delete
'priority' => 5,
[224] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_type_options', [] ) ),
[225] Fix | Delete
],
[226] Fix | Delete
'animation_speed' => [
[227] Fix | Delete
'label' => __( 'Animation Speed', 'popup-maker' ),
[228] Fix | Delete
'description' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
[229] Fix | Delete
'type' => 'rangeslider',
[230] Fix | Delete
'std' => 350,
[231] Fix | Delete
'priority' => 10,
[232] Fix | Delete
'step' => 10,
[233] Fix | Delete
'min' => 50,
[234] Fix | Delete
'max' => 1000,
[235] Fix | Delete
'unit' => __( 'ms', 'popup-maker' ),
[236] Fix | Delete
],
[237] Fix | Delete
'animation_origin' => [
[238] Fix | Delete
'label' => __( 'Animation Origin', 'popup-maker' ),
[239] Fix | Delete
'description' => __( 'Choose where the animation will begin.', 'popup-maker' ),
[240] Fix | Delete
'type' => 'select',
[241] Fix | Delete
'std' => 'center top',
[242] Fix | Delete
'priority' => 15,
[243] Fix | Delete
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_origin_options', [] ) ),
[244] Fix | Delete
],
[245] Fix | Delete
],
[246] Fix | Delete
],
[247] Fix | Delete
'close' => [
[248] Fix | Delete
'main' => [
[249] Fix | Delete
'overlay_click' => [
[250] Fix | Delete
'label' => __( 'Click Overlay to Close', 'popup-maker' ),
[251] Fix | Delete
'description' => __( 'Checking this will cause popup to close when user clicks on overlay.', 'popup-maker' ),
[252] Fix | Delete
'type' => 'checkbox',
[253] Fix | Delete
'std' => false,
[254] Fix | Delete
'priority' => 5,
[255] Fix | Delete
],
[256] Fix | Delete
],
[257] Fix | Delete
],
[258] Fix | Delete
];
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* Shortcode handler
[263] Fix | Delete
*
[264] Fix | Delete
* @param array $atts shortcode attributes
[265] Fix | Delete
* @param string $content shortcode content
[266] Fix | Delete
*
[267] Fix | Delete
* @return string
[268] Fix | Delete
*/
[269] Fix | Delete
public function handler( $atts, $content = null ) {
[270] Fix | Delete
global $popup;
[271] Fix | Delete
[272] Fix | Delete
$atts = shortcode_atts(
[273] Fix | Delete
apply_filters(
[274] Fix | Delete
'pum_popup_shortcode_default_atts',
[275] Fix | Delete
[
[276] Fix | Delete
[277] Fix | Delete
'id' => '',
[278] Fix | Delete
'title' => '',
[279] Fix | Delete
[280] Fix | Delete
'theme_id' => null,
[281] Fix | Delete
'theme' => null,
[282] Fix | Delete
'overlay_disabled' => 0,
[283] Fix | Delete
'size' => 'small',
[284] Fix | Delete
'width' => '',
[285] Fix | Delete
'width_unit' => 'px',
[286] Fix | Delete
'height' => '',
[287] Fix | Delete
'height_unit' => 'px',
[288] Fix | Delete
[289] Fix | Delete
'location' => 'center top',
[290] Fix | Delete
'position_top' => 100,
[291] Fix | Delete
'position_left' => 0,
[292] Fix | Delete
'position_bottom' => 0,
[293] Fix | Delete
'position_right' => 0,
[294] Fix | Delete
'position_fixed' => 0,
[295] Fix | Delete
[296] Fix | Delete
'animation_type' => 'fade',
[297] Fix | Delete
'animation_speed' => 1000,
[298] Fix | Delete
'animation_origin' => 'top',
[299] Fix | Delete
[300] Fix | Delete
'overlay_click' => 0,
[301] Fix | Delete
'esc_press' => 1,
[302] Fix | Delete
]
[303] Fix | Delete
),
[304] Fix | Delete
$atts,
[305] Fix | Delete
'popup'
[306] Fix | Delete
);
[307] Fix | Delete
[308] Fix | Delete
// We need to fake a popup using the PUM_Popup data model.
[309] Fix | Delete
$post_id = rand( - 99999, - 1 ); // negative ID, to avoid clash with a valid post
[310] Fix | Delete
$post = new stdClass();
[311] Fix | Delete
$post->ID = $post_id;
[312] Fix | Delete
$post->post_author = 1;
[313] Fix | Delete
$post->post_date = current_time( 'mysql' );
[314] Fix | Delete
$post->post_date_gmt = current_time( 'mysql', 1 );
[315] Fix | Delete
$post->post_title = $atts['title'];
[316] Fix | Delete
$post->post_content = $content;
[317] Fix | Delete
$post->post_status = 'publish';
[318] Fix | Delete
$post->comment_status = 'closed';
[319] Fix | Delete
$post->ping_status = 'closed';
[320] Fix | Delete
$post->post_name = $atts['id']; // append random number to avoid clash
[321] Fix | Delete
$post->post_type = 'popup';
[322] Fix | Delete
$post->filter = 'raw'; // important!
[323] Fix | Delete
$post->data_version = 3;
[324] Fix | Delete
$post->mock = true;
[325] Fix | Delete
[326] Fix | Delete
// Convert to WP_Post object
[327] Fix | Delete
$wp_post = new WP_Post( $post );
[328] Fix | Delete
[329] Fix | Delete
// Add the fake post to the cache
[330] Fix | Delete
wp_cache_add( $post_id, $wp_post, 'posts' );
[331] Fix | Delete
[332] Fix | Delete
$popup = new PUM_Model_Popup( $wp_post );
[333] Fix | Delete
[334] Fix | Delete
// Get Theme ID
[335] Fix | Delete
if ( ! $atts['theme_id'] ) {
[336] Fix | Delete
$atts['theme_id'] = $atts['theme'] ? $atts['theme'] : pum_get_default_theme_id();
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
$popup->title = $atts['title'];
[340] Fix | Delete
$popup->settings = array_merge(
[341] Fix | Delete
PUM_Admin_Popups::defaults(),
[342] Fix | Delete
[
[343] Fix | Delete
'disable_analytics' => true,
[344] Fix | Delete
'theme_id' => $atts['theme_id'],
[345] Fix | Delete
'size' => $atts['size'],
[346] Fix | Delete
'overlay_disabled' => $atts['overlay_disabled'],
[347] Fix | Delete
'custom_width' => $atts['width'],
[348] Fix | Delete
'custom_width_unit' => $atts['width_unit'],
[349] Fix | Delete
'custom_height' => $atts['height'],
[350] Fix | Delete
'custom_height_unit' => $atts['height_unit'],
[351] Fix | Delete
'custom_height_auto' => $atts['width'] > 0 ? 0 : 1,
[352] Fix | Delete
'location' => $atts['location'],
[353] Fix | Delete
'position_top' => $atts['position_top'],
[354] Fix | Delete
'position_left' => $atts['position_left'],
[355] Fix | Delete
'position_bottom' => $atts['position_bottom'],
[356] Fix | Delete
'position_right' => $atts['position_right'],
[357] Fix | Delete
'position_fixed' => $atts['position_fixed'],
[358] Fix | Delete
'animation_type' => $atts['animation_type'],
[359] Fix | Delete
'animation_speed' => $atts['animation_speed'],
[360] Fix | Delete
'animation_origin' => $atts['animation_origin'],
[361] Fix | Delete
'close_on_overlay_click' => $atts['overlay_click'],
[362] Fix | Delete
'close_on_esc_press' => $atts['esc_press'],
[363] Fix | Delete
'triggers' => [
[364] Fix | Delete
[
[365] Fix | Delete
'type' => 'click_open',
[366] Fix | Delete
'settings' => [
[367] Fix | Delete
'extra_selectors' => '#popmake-' . $atts['id'],
[368] Fix | Delete
],
[369] Fix | Delete
],
[370] Fix | Delete
],
[371] Fix | Delete
]
[372] Fix | Delete
);
[373] Fix | Delete
[374] Fix | Delete
$current_global_popup = pum()->current_popup;
[375] Fix | Delete
[376] Fix | Delete
pum()->current_popup = $popup;
[377] Fix | Delete
[378] Fix | Delete
$return = pum_get_template_part( 'popup' );
[379] Fix | Delete
[380] Fix | Delete
// Small hack to move popup to body.
[381] Fix | Delete
$return .= "<script type='text/javascript' id='pum-move-popup-" . $post_id . "'>jQuery(document).ready(function () {
[382] Fix | Delete
jQuery('#pum-" . $post_id . "').appendTo('body');
[383] Fix | Delete
window.pum_vars.popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . ";
[384] Fix | Delete
window.pum_popups[ 'pum-" . $popup->ID . "' ] = " . PUM_Utils_Array::safe_json_encode( $popup->get_public_settings() ) . ";
[385] Fix | Delete
jQuery('#pum-move-popup-" . $post_id . "').remove();
[386] Fix | Delete
});</script>";
[387] Fix | Delete
[388] Fix | Delete
pum()->current_popup = $current_global_popup;
[389] Fix | Delete
[390] Fix | Delete
return $return;
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
public function template() { ?>
[394] Fix | Delete
<p class="pum-sub-form-desc">
[395] Fix | Delete
<?php esc_html_e( 'Popup', 'popup-maker' ); ?>: ID "{{attrs.id}}"
[396] Fix | Delete
</p>
[397] Fix | Delete
<?php
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function