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/clone/wp-conte.../plugins/popup-ma.../includes/importer
File: easy-modal-v2.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Function
[2] Fix | Delete
*
[3] Fix | Delete
* @package POPMAKE_EMODAL
[4] Fix | Delete
* @subpackage Functions/Import
[5] Fix | Delete
* @copyright Copyright (c) 2023, Code Atlantic LLC
[6] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[7] Fix | Delete
* @since 1.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
// Exit if accessed directly
[11] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[12] Fix | Delete
exit;
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Import
[17] Fix | Delete
*
[18] Fix | Delete
* Runs on plugin install by setting up the post types, custom taxonomies,
[19] Fix | Delete
* flushing rewrite rules also creates the plugin and populates the settings
[20] Fix | Delete
* fields for those plugin pages. After successful install, the user is
[21] Fix | Delete
* redirected to the POPMAKE_EMODAL Welcome screen.
[22] Fix | Delete
*
[23] Fix | Delete
* @since 1.0
[24] Fix | Delete
* @global $wpdb
[25] Fix | Delete
* @global $popmake_options
[26] Fix | Delete
* @global $wp_version
[27] Fix | Delete
* @return void
[28] Fix | Delete
*/
[29] Fix | Delete
function popmake_emodal_v2_import() {
[30] Fix | Delete
global $wpdb, $popmake_options, $wp_version, $popmake_tools_page;
[31] Fix | Delete
[32] Fix | Delete
require_once POPMAKE_DIR . 'includes/importer/easy-modal-v2/functions.php';
[33] Fix | Delete
[34] Fix | Delete
if ( ! class_exists( 'EModal_Model' ) ) {
[35] Fix | Delete
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model.php';
[36] Fix | Delete
}
[37] Fix | Delete
if ( ! class_exists( 'EModal_Model_Modal' ) ) {
[38] Fix | Delete
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/modal.php';
[39] Fix | Delete
}
[40] Fix | Delete
if ( ! class_exists( 'EModal_Model_Theme' ) ) {
[41] Fix | Delete
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/theme.php';
[42] Fix | Delete
}
[43] Fix | Delete
if ( ! class_exists( 'EModal_Model_Theme_Meta' ) ) {
[44] Fix | Delete
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/theme/meta.php';
[45] Fix | Delete
}
[46] Fix | Delete
if ( ! class_exists( 'EModal_Model_Modal_Meta' ) ) {
[47] Fix | Delete
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/modal/meta.php';
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
$themes = get_all_modal_themes( '1 = 1' );
[51] Fix | Delete
$theme_id_map = [];
[52] Fix | Delete
foreach ( $themes as $Theme ) {
[53] Fix | Delete
$theme = $Theme->as_array();
[54] Fix | Delete
$meta = $theme['meta'];
[55] Fix | Delete
[56] Fix | Delete
$theme_meta = apply_filters(
[57] Fix | Delete
'popmake_emodal_import_theme_meta',
[58] Fix | Delete
[
[59] Fix | Delete
'popup_theme_defaults_set' => true,
[60] Fix | Delete
'popup_theme_overlay_background_color' => $meta['overlay']['background']['color'],
[61] Fix | Delete
'popup_theme_overlay_background_opacity' => $meta['overlay']['background']['opacity'],
[62] Fix | Delete
'popup_theme_container_padding' => $meta['container']['padding'],
[63] Fix | Delete
'popup_theme_container_background_color' => $meta['container']['background']['color'],
[64] Fix | Delete
'popup_theme_container_background_opacity' => $meta['container']['background']['opacity'],
[65] Fix | Delete
'popup_theme_container_border_radius' => $meta['container']['border']['radius'],
[66] Fix | Delete
'popup_theme_container_border_style' => $meta['container']['border']['style'],
[67] Fix | Delete
'popup_theme_container_border_color' => $meta['container']['border']['color'],
[68] Fix | Delete
'popup_theme_container_border_width' => $meta['container']['border']['width'],
[69] Fix | Delete
'popup_theme_container_boxshadow_inset' => $meta['container']['boxshadow']['inset'],
[70] Fix | Delete
'popup_theme_container_boxshadow_horizontal' => $meta['container']['boxshadow']['horizontal'],
[71] Fix | Delete
'popup_theme_container_boxshadow_vertical' => $meta['container']['boxshadow']['vertical'],
[72] Fix | Delete
'popup_theme_container_boxshadow_blur' => $meta['container']['boxshadow']['blur'],
[73] Fix | Delete
'popup_theme_container_boxshadow_spread' => $meta['container']['boxshadow']['spread'],
[74] Fix | Delete
'popup_theme_container_boxshadow_color' => $meta['container']['boxshadow']['color'],
[75] Fix | Delete
'popup_theme_container_boxshadow_opacity' => $meta['container']['boxshadow']['opacity'],
[76] Fix | Delete
'popup_theme_title_font_color' => $meta['title']['font']['color'],
[77] Fix | Delete
'popup_theme_title_line_height' => $meta['title']['font']['size'],
[78] Fix | Delete
'popup_theme_title_font_size' => $meta['title']['font']['size'],
[79] Fix | Delete
'popup_theme_title_font_family' => $meta['title']['font']['family'],
[80] Fix | Delete
'popup_theme_title_font_weight' => $meta['title']['font']['weight'],
[81] Fix | Delete
'popup_theme_title_font_style' => $meta['title']['font']['style'],
[82] Fix | Delete
'popup_theme_title_text_align' => $meta['title']['text']['align'],
[83] Fix | Delete
'popup_theme_title_textshadow_horizontal' => $meta['title']['textshadow']['horizontal'],
[84] Fix | Delete
'popup_theme_title_textshadow_vertical' => $meta['title']['textshadow']['vertical'],
[85] Fix | Delete
'popup_theme_title_textshadow_blur' => $meta['title']['textshadow']['blur'],
[86] Fix | Delete
'popup_theme_title_textshadow_color' => $meta['title']['textshadow']['color'],
[87] Fix | Delete
'popup_theme_title_textshadow_opacity' => $meta['title']['textshadow']['opacity'],
[88] Fix | Delete
'popup_theme_content_font_color' => $meta['content']['font']['color'],
[89] Fix | Delete
'popup_theme_content_font_family' => $meta['content']['font']['family'],
[90] Fix | Delete
'popup_theme_content_font_weight' => $meta['content']['font']['weight'],
[91] Fix | Delete
'popup_theme_content_font_style' => $meta['content']['font']['style'],
[92] Fix | Delete
'popup_theme_close_text' => $meta['close']['text'],
[93] Fix | Delete
'popup_theme_close_padding' => $meta['close']['padding'],
[94] Fix | Delete
'popup_theme_close_location' => $meta['close']['location'],
[95] Fix | Delete
'popup_theme_close_position_top' => $meta['close']['position']['top'],
[96] Fix | Delete
'popup_theme_close_position_left' => $meta['close']['position']['left'],
[97] Fix | Delete
'popup_theme_close_position_bottom' => $meta['close']['position']['bottom'],
[98] Fix | Delete
'popup_theme_close_position_right' => $meta['close']['position']['right'],
[99] Fix | Delete
'popup_theme_close_line_height' => $meta['close']['font']['size'],
[100] Fix | Delete
'popup_theme_close_font_color' => $meta['close']['font']['color'],
[101] Fix | Delete
'popup_theme_close_font_size' => $meta['close']['font']['size'],
[102] Fix | Delete
'popup_theme_close_font_family' => $meta['close']['font']['family'],
[103] Fix | Delete
'popup_theme_close_font_weight' => $meta['close']['font']['weight'],
[104] Fix | Delete
'popup_theme_close_font_style' => $meta['close']['font']['style'],
[105] Fix | Delete
'popup_theme_close_background_color' => $meta['close']['background']['color'],
[106] Fix | Delete
'popup_theme_close_background_opacity' => $meta['close']['background']['opacity'],
[107] Fix | Delete
'popup_theme_close_border_radius' => $meta['close']['border']['radius'],
[108] Fix | Delete
'popup_theme_close_border_style' => $meta['close']['border']['style'],
[109] Fix | Delete
'popup_theme_close_border_color' => $meta['close']['border']['color'],
[110] Fix | Delete
'popup_theme_close_border_width' => $meta['close']['border']['width'],
[111] Fix | Delete
'popup_theme_close_boxshadow_inset' => $meta['close']['boxshadow']['inset'],
[112] Fix | Delete
'popup_theme_close_boxshadow_horizontal' => $meta['close']['boxshadow']['horizontal'],
[113] Fix | Delete
'popup_theme_close_boxshadow_vertical' => $meta['close']['boxshadow']['vertical'],
[114] Fix | Delete
'popup_theme_close_boxshadow_blur' => $meta['close']['boxshadow']['blur'],
[115] Fix | Delete
'popup_theme_close_boxshadow_spread' => $meta['close']['boxshadow']['spread'],
[116] Fix | Delete
'popup_theme_close_boxshadow_color' => $meta['close']['boxshadow']['color'],
[117] Fix | Delete
'popup_theme_close_boxshadow_opacity' => $meta['close']['boxshadow']['opacity'],
[118] Fix | Delete
'popup_theme_close_textshadow_horizontal' => $meta['close']['textshadow']['horizontal'],
[119] Fix | Delete
'popup_theme_close_textshadow_vertical' => $meta['close']['textshadow']['vertical'],
[120] Fix | Delete
'popup_theme_close_textshadow_blur' => $meta['close']['textshadow']['blur'],
[121] Fix | Delete
'popup_theme_close_textshadow_color' => $meta['close']['textshadow']['color'],
[122] Fix | Delete
'popup_theme_close_textshadow_opacity' => $meta['close']['textshadow']['opacity'],
[123] Fix | Delete
],
[124] Fix | Delete
$Theme
[125] Fix | Delete
);
[126] Fix | Delete
[127] Fix | Delete
$new_theme_id = wp_insert_post(
[128] Fix | Delete
[
[129] Fix | Delete
'post_title' => $theme['name'],
[130] Fix | Delete
'post_status' => $theme['is_trash'] ? 'trash' : 'publish',
[131] Fix | Delete
'post_author' => get_current_user_id(),
[132] Fix | Delete
'post_type' => 'popup_theme',
[133] Fix | Delete
'comment_status' => 'closed',
[134] Fix | Delete
]
[135] Fix | Delete
);
[136] Fix | Delete
foreach ( $theme_meta as $meta_key => $meta_value ) {
[137] Fix | Delete
update_post_meta( $new_theme_id, $meta_key, $meta_value );
[138] Fix | Delete
}
[139] Fix | Delete
update_post_meta( $new_theme_id, 'popup_theme_old_easy_modal_id', $theme['id'] );
[140] Fix | Delete
[141] Fix | Delete
$theme_id_map[ $theme['id'] ] = $new_theme_id;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
if ( count( $themes ) === 1 ) {
[145] Fix | Delete
update_post_meta( $new_theme_id, 'popup_theme_defaults_set', true );
[146] Fix | Delete
update_option( 'popmake_default_theme', $new_theme_id );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
$modals = get_all_modals( '1 = 1' );
[150] Fix | Delete
[151] Fix | Delete
// echo '<pre>'; var_export(popmake_popup_meta_fields()); echo '</pre>';
[152] Fix | Delete
[153] Fix | Delete
foreach ( $modals as $Modal ) {
[154] Fix | Delete
$modal = $Modal->as_array();
[155] Fix | Delete
$meta = $modal['meta'];
[156] Fix | Delete
[157] Fix | Delete
$modal_meta = apply_filters(
[158] Fix | Delete
'popmake_emodal_import_modal_meta',
[159] Fix | Delete
[
[160] Fix | Delete
'popup_old_easy_modal_id' => $modal['id'],
[161] Fix | Delete
'popup_defaults_set' => true,
[162] Fix | Delete
'popup_theme' => isset( $theme_id_map[ $theme['id'] ] ) ? $theme_id_map[ $theme['id'] ] : null,
[163] Fix | Delete
'popup_title' => $modal['title'],
[164] Fix | Delete
'popup_display_scrollable_content' => null,
[165] Fix | Delete
'popup_display_overlay_disabled' => $meta['display']['overlay_disabled'],
[166] Fix | Delete
'popup_display_size' => $meta['display']['size'],
[167] Fix | Delete
'popup_display_responsive_min_width' => '',
[168] Fix | Delete
'popup_display_responsive_min_width_unit' => 'px',
[169] Fix | Delete
'popup_display_responsive_max_width' => '',
[170] Fix | Delete
'popup_display_responsive_max_width_unit' => 'px',
[171] Fix | Delete
'popup_display_custom_width' => $meta['display']['custom_width'],
[172] Fix | Delete
'popup_display_custom_width_unit' => $meta['display']['custom_width_unit'],
[173] Fix | Delete
'popup_display_custom_height' => $meta['display']['custom_height'],
[174] Fix | Delete
'popup_display_custom_height_unit' => $meta['display']['custom_height_unit'],
[175] Fix | Delete
'popup_display_custom_height_auto' => $meta['display']['custom_height_auto'],
[176] Fix | Delete
'popup_display_location' => $meta['display']['location'],
[177] Fix | Delete
'popup_display_position_top' => $meta['display']['position']['top'],
[178] Fix | Delete
'popup_display_position_left' => $meta['display']['position']['left'],
[179] Fix | Delete
'popup_display_position_bottom' => $meta['display']['position']['bottom'],
[180] Fix | Delete
'popup_display_position_right' => $meta['display']['position']['right'],
[181] Fix | Delete
'popup_display_position_fixed' => $meta['display']['position']['fixed'],
[182] Fix | Delete
'popup_display_animation_type' => $meta['display']['animation']['type'],
[183] Fix | Delete
'popup_display_animation_speed' => $meta['display']['animation']['speed'],
[184] Fix | Delete
'popup_display_animation_origin' => $meta['display']['animation']['origin'],
[185] Fix | Delete
'popup_close_overlay_click' => $meta['close']['overlay_click'],
[186] Fix | Delete
'popup_close_esc_press' => $meta['close']['esc_press'],
[187] Fix | Delete
'popup_close_f4_press' => null,
[188] Fix | Delete
],
[189] Fix | Delete
$Modal
[190] Fix | Delete
);
[191] Fix | Delete
[192] Fix | Delete
if ( 1 === $modal['is_sitewide'] ) {
[193] Fix | Delete
$modal_meta['popup_targeting_condition_on_entire_site'] = true;
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$new_modal_id = wp_insert_post(
[197] Fix | Delete
[
[198] Fix | Delete
'post_title' => $modal['name'],
[199] Fix | Delete
'post_status' => $modal['is_trash'] ? 'trash' : 'publish',
[200] Fix | Delete
'post_content' => $modal['content'],
[201] Fix | Delete
'post_author' => get_current_user_id(),
[202] Fix | Delete
'post_type' => 'popup',
[203] Fix | Delete
'comment_status' => 'closed',
[204] Fix | Delete
]
[205] Fix | Delete
);
[206] Fix | Delete
foreach ( $modal_meta as $meta_key => $meta_value ) {
[207] Fix | Delete
update_post_meta( $new_modal_id, $meta_key, $meta_value );
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
[213] Fix | Delete
function popmake_emodal_init() {
[214] Fix | Delete
if ( pum_get_option( 'enable_easy_modal_compatibility_mode' ) ) {
[215] Fix | Delete
if ( ! shortcode_exists( 'modal' ) ) {
[216] Fix | Delete
add_shortcode( 'modal', 'popmake_emodal_shortcode_modal' );
[217] Fix | Delete
}
[218] Fix | Delete
add_filter( 'pum_popup_data_attr', 'popmake_emodal_get_the_popup_data_attr', 10, 2 );
[219] Fix | Delete
add_filter( 'popmake_shortcode_popup_default_atts', 'popmake_emodal_shortcode_popup_default_atts', 10, 2 );
[220] Fix | Delete
add_filter( 'popmake_shortcode_data_attr', 'popmake_emodal_shortcode_data_attr', 10, 2 );
[221] Fix | Delete
[222] Fix | Delete
add_filter( 'pum_popup_is_loadable', 'popmake_emodal_popup_is_loadable', 20, 2 );
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
add_action( 'init', 'popmake_emodal_init' );
[227] Fix | Delete
[228] Fix | Delete
[229] Fix | Delete
function popmake_emodal_popup_is_loadable( $return, $popup_id ) {
[230] Fix | Delete
global $post;
[231] Fix | Delete
if ( empty( $post ) || ! isset( $post->ID ) ) {
[232] Fix | Delete
return $return;
[233] Fix | Delete
}
[234] Fix | Delete
$easy_modal_id = get_post_meta( $popup_id, 'popup_old_easy_modal_id', true );
[235] Fix | Delete
$post_modals = get_post_meta( $post->ID, 'easy-modal_post_modals', true );
[236] Fix | Delete
if ( ! $easy_modal_id || empty( $post_modals ) || ! in_array( $easy_modal_id, $post_modals ) ) {
[237] Fix | Delete
return $return;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
return true;
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
function popmake_emodal_get_the_popup_data_attr( $data_attr, $popup_id ) {
[244] Fix | Delete
$easy_modal_id = get_post_meta( $popup_id, 'popup_old_easy_modal_id', true );
[245] Fix | Delete
if ( ! $easy_modal_id ) {
[246] Fix | Delete
return $data_attr;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
return array_merge(
[250] Fix | Delete
$data_attr,
[251] Fix | Delete
[
[252] Fix | Delete
'old_easy_modal_id' => $easy_modal_id,
[253] Fix | Delete
]
[254] Fix | Delete
);
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
function popmake_emodal_shortcode_modal( $atts, $content = null ) {
[258] Fix | Delete
$atts = shortcode_atts(
[259] Fix | Delete
apply_filters(
[260] Fix | Delete
'emodal_shortcode_modal_default_atts',
[261] Fix | Delete
[
[262] Fix | Delete
'id' => '',
[263] Fix | Delete
'theme_id' => null,
[264] Fix | Delete
'title' => null,
[265] Fix | Delete
'overlay_disabled' => null,
[266] Fix | Delete
'size' => null,
[267] Fix | Delete
'width' => null,
[268] Fix | Delete
'widthUnit' => null,
[269] Fix | Delete
'height' => null,
[270] Fix | Delete
'heightUnit' => null,
[271] Fix | Delete
'location' => null,
[272] Fix | Delete
'positionTop' => null,
[273] Fix | Delete
'positionLeft' => null,
[274] Fix | Delete
'positionBottom' => null,
[275] Fix | Delete
'positionRight' => null,
[276] Fix | Delete
'positionFixed' => null,
[277] Fix | Delete
'animation' => null,
[278] Fix | Delete
'animationSpeed' => null,
[279] Fix | Delete
'animationOrigin' => null,
[280] Fix | Delete
'overlayClose' => null,
[281] Fix | Delete
'escClose' => null,
[282] Fix | Delete
// Deprecated
[283] Fix | Delete
'theme' => null,
[284] Fix | Delete
'duration' => null,
[285] Fix | Delete
'direction' => null,
[286] Fix | Delete
'overlayEscClose' => null,
[287] Fix | Delete
]
[288] Fix | Delete
),
[289] Fix | Delete
apply_filters( 'emodal_shortcode_modal_atts', $atts )
[290] Fix | Delete
);
[291] Fix | Delete
[292] Fix | Delete
$new_shortcode_atts = [
[293] Fix | Delete
'id' => $atts['id'],
[294] Fix | Delete
'emodal_id' => $atts['id'],
[295] Fix | Delete
'theme_id' => $atts['theme_id'],
[296] Fix | Delete
'title' => $atts['title'],
[297] Fix | Delete
'overlay_disabled' => $atts['overlay_disabled'],
[298] Fix | Delete
'size' => $atts['size'],
[299] Fix | Delete
'width' => $atts['width'],
[300] Fix | Delete
'width_unit' => $atts['widthUnit'],
[301] Fix | Delete
'height' => $atts['height'],
[302] Fix | Delete
'height_unit' => $atts['heightUnit'],
[303] Fix | Delete
'location' => $atts['location'],
[304] Fix | Delete
'position_top' => $atts['positionTop'],
[305] Fix | Delete
'position_left' => $atts['positionLeft'],
[306] Fix | Delete
'position_bottom' => $atts['positionBottom'],
[307] Fix | Delete
'position_right' => $atts['positionRight'],
[308] Fix | Delete
'position_fixed' => $atts['positionFixed'],
[309] Fix | Delete
'animation_type' => $atts['animation'],
[310] Fix | Delete
'animation_speed' => $atts['animationSpeed'],
[311] Fix | Delete
'animation_origin' => $atts['animationOrigin'],
[312] Fix | Delete
'overlay_click' => $atts['overlayClose'],
[313] Fix | Delete
'esc_press' => $atts['escClose'],
[314] Fix | Delete
];
[315] Fix | Delete
[316] Fix | Delete
$shortcode = '[popup ';
[317] Fix | Delete
[318] Fix | Delete
foreach ( $new_shortcode_atts as $attr => $val ) {
[319] Fix | Delete
if ( $val && ! empty( $val ) ) {
[320] Fix | Delete
$shortcode .= $attr . '="' . $val . '" ';
[321] Fix | Delete
}
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
$shortcode .= ']' . $content . '[/popup]';
[325] Fix | Delete
[326] Fix | Delete
return do_shortcode( $shortcode );
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
[330] Fix | Delete
function popmake_emodal_shortcode_popup_default_atts( $default_atts = [] ) {
[331] Fix | Delete
return array_merge(
[332] Fix | Delete
$default_atts,
[333] Fix | Delete
[
[334] Fix | Delete
'emodal_id' => null,
[335] Fix | Delete
]
[336] Fix | Delete
);
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
[340] Fix | Delete
function popmake_emodal_shortcode_data_attr( $data, $attr ) {
[341] Fix | Delete
if ( ! empty( $attr['emodal_id'] ) ) {
[342] Fix | Delete
$data['old_easy_modal_id'] = $attr['emodal_id'];
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
return $data;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function