preview->is_preview_mode() ) { $template = WPR_ADDONS_PATH . 'modules/popup/editor.php'; } return $template; } return $template; } /** ** Popups */ public function render_popups() { $conditions = json_decode( get_option('wpr_popup_conditions'), true ); if ( ! empty( $conditions ) ) { $conditions = $this->reverse_template_conditions( $conditions ); // Global if ( isset( $conditions['global'] ) ) { WPR_Templates_Modal_Popups::display_popups_by_location( $conditions, 'global' ); } // Custom if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) { // Archive \WprAddonsPro\Classes\Pro_Modules::archive_pages_popup_conditions( $conditions ); // Single \WprAddonsPro\Classes\Pro_Modules::single_pages_popup_conditions( $conditions ); } // Enqueue ScrolBar JS //TODO - check if displayed multiple times wp_enqueue_script( 'wpr-popup-scroll-js', WPR_ADDONS_URL .'assets/js/lib/perfect-scrollbar/perfect-scrollbar.min.js', [ 'jquery' ], '0.4.9' ); } } /** ** Reverse Template Conditions */ public function reverse_template_conditions( $conditions ) { $reverse = []; foreach ( $conditions as $key => $condition ) { foreach( $condition as $location ) { if ( ! isset( $reverse[$location] ) ) { $reverse[$location] = [ $key ]; } else { array_push( $reverse[$location], $key ); } } } return $reverse; } /** ** Display Popups by Location */ public static function display_popups_by_location( $conditions, $page ) { foreach ( $conditions[$page] as $key => $popup ) { WPR_Templates_Modal_Popups::render_popup_content( $popup ); } } /** ** Display Elementor Content */ public static function render_popup_content( $slug ) { $template_name = ''; $template_id = Utilities::get_template_id( $slug ); if ( defined('ICL_LANGUAGE_CODE') ) { $default_language_code = apply_filters('wpml_default_language', null); $current_language_code = apply_filters( 'wpml_current_language', NULL ); IF ( ICL_LANGUAGE_CODE !== $default_language_code ) { $template_id = apply_filters('wpml_object_id', $template_id, 'wpr_templates', true, $current_language_code); } } $get_settings = WPR_Templates_Modal_Popups::get_template_settings( $slug ); $get_elementor_content = self::$elementor_instance->frontend->get_builder_content( $template_id, false ); if ( '' === $get_elementor_content ) { return; } // Encode Settings $get_encoded_settings = ! empty( $get_settings ) ? wp_json_encode( $get_settings ) : '[]'; // Template Settings Attribute $template_settings_attr = "data-settings='". esc_attr($get_encoded_settings) ."'"; // Return if NOT available for current user if ( ! WPR_Templates_Modal_Popups::check_available_user_roles( $get_settings['popup_show_for_roles'] ) ) { return; } if ( ! self::$elementor_instance->preview->is_preview_mode() ) { echo '