コード例 #1
0
function et_builder_load_modules_styles()
{
    $current_page_id = apply_filters('et_is_ab_testing_active_post_id', get_the_ID());
    wp_register_script('google-maps-api', esc_url(add_query_arg(array('v' => 3, 'sensor' => 'false'), is_ssl() ? 'https://maps-api-ssl.google.com/maps/api/js' : 'http://maps.google.com/maps/api/js')), array(), ET_BUILDER_VERSION, true);
    wp_enqueue_script('divi-fitvids', ET_BUILDER_URI . '/scripts/jquery.fitvids.js', array('jquery'), ET_BUILDER_VERSION, true);
    wp_enqueue_script('waypoints', ET_BUILDER_URI . '/scripts/waypoints.min.js', array('jquery'), ET_BUILDER_VERSION, true);
    wp_enqueue_script('magnific-popup', ET_BUILDER_URI . '/scripts/jquery.magnific-popup.js', array('jquery'), ET_BUILDER_VERSION, true);
    wp_register_script('hashchange', ET_BUILDER_URI . '/scripts/jquery.hashchange.js', array('jquery'), ET_BUILDER_VERSION, true);
    wp_register_script('salvattore', ET_BUILDER_URI . '/scripts/salvattore.min.js', array(), ET_BUILDER_VERSION, true);
    wp_register_script('easypiechart', ET_BUILDER_URI . '/scripts/jquery.easypiechart.js', array('jquery'), ET_BUILDER_VERSION, true);
    if (et_is_builder_plugin_active()) {
        wp_register_script('fittext', ET_BUILDER_URI . '/scripts/jquery.fittext.js', array('jquery'), ET_BUILDER_VERSION, true);
    }
    // Load main styles CSS file only if the Builder plugin is active
    if (et_is_builder_plugin_active()) {
        wp_enqueue_style('et-builder-modules-style', ET_BUILDER_URI . '/styles/frontend-builder-plugin-style.css', array(), ET_BUILDER_VERSION);
    }
    // Load visible.min.js only if AB testing active on current page
    if (et_is_ab_testing_active()) {
        wp_enqueue_script('et-jquery-visible-viewport', ET_BUILDER_URI . '/scripts/ext/jquery.visible.min.js', array('jquery', 'et-builder-modules-script'), ET_BUILDER_VERSION, true);
    }
    wp_enqueue_style('magnific-popup', ET_BUILDER_URI . '/styles/magnific_popup.css', array(), ET_BUILDER_VERSION);
    wp_enqueue_script('et-jquery-touch-mobile', ET_BUILDER_URI . '/scripts/jquery.mobile.custom.min.js', array('jquery'), ET_BUILDER_VERSION, true);
    wp_enqueue_script('et-builder-modules-script', ET_BUILDER_URI . '/scripts/frontend-builder-scripts.js', array('jquery', 'et-jquery-touch-mobile'), ET_BUILDER_VERSION, true);
    wp_localize_script('et-builder-modules-script', 'et_pb_custom', array('ajaxurl' => admin_url('admin-ajax.php'), 'images_uri' => get_template_directory_uri() . '/images', 'builder_images_uri' => ET_BUILDER_URI . '/images', 'et_frontend_nonce' => wp_create_nonce('et_frontend_nonce'), 'subscription_failed' => esc_html__('Please, check the fields below to make sure you entered the correct information.', 'et_builder'), 'et_ab_log_nonce' => wp_create_nonce('et_ab_testing_log_nonce'), 'fill_message' => esc_html__('Please, fill in the following fields:', 'et_builder'), 'contact_error_message' => esc_html__('Please, fix the following errors:', 'et_builder'), 'invalid' => esc_html__('Invalid email', 'et_builder'), 'captcha' => esc_html__('Captcha', 'et_builder'), 'prev' => esc_html__('Prev', 'et_builder'), 'previous' => esc_html__('Previous', 'et_builder'), 'next' => esc_html__('Next', 'et_builder'), 'wrong_captcha' => esc_html__('You entered the wrong number in captcha.', 'et_builder'), 'is_builder_plugin_used' => et_is_builder_plugin_active(), 'is_divi_theme_used' => function_exists('et_divi_fonts_url'), 'widget_search_selector' => apply_filters('et_pb_widget_search_selector', '.widget_search'), 'is_ab_testing_active' => et_is_ab_testing_active(), 'page_id' => $current_page_id, 'unique_test_id' => get_post_meta($current_page_id, '_et_pb_ab_testing_id', true), 'ab_bounce_rate' => '' !== get_post_meta($current_page_id, '_et_pb_ab_bounce_rate_limit', true) ? get_post_meta($current_page_id, '_et_pb_ab_bounce_rate_limit', true) : 5, 'is_cache_plugin_active' => false === et_pb_detect_cache_plugins() ? 'no' : 'yes', 'is_shortcode_tracking' => get_post_meta($current_page_id, '_et_pb_enable_shortcode_tracking', true)));
    /**
     * Only load this during builder preview screen session
     */
    if (is_et_pb_preview()) {
        // Set fixed protocol for preview URL to prevent cross origin issue
        $preview_scheme = is_ssl() ? 'https' : 'http';
        // Get home url, then parse it
        $preview_origin_component = parse_url(home_url('', $preview_scheme));
        // Rebuild origin URL, strip sub-directory address if there's any (postMessage e.origin doesn't pass sub-directory address)
        $preview_origin = "";
        // Perform check, prevent unnecessary error
        if (isset($preview_origin_component['scheme']) && isset($preview_origin_component['host'])) {
            $preview_origin = "{$preview_origin_component['scheme']}://{$preview_origin_component['host']}";
            // Append port number if different port number is being used
            if (isset($preview_origin_component['port'])) {
                $preview_origin = "{$preview_origin}:{$preview_origin_component['port']}";
            }
        }
        // Enqueue theme's style.css if it hasn't been enqueued (possibly being hardcoded by theme)
        if (!et_builder_has_theme_style_enqueued() && et_is_builder_plugin_active()) {
            wp_enqueue_style('et-builder-theme-style-css', get_stylesheet_uri(), array());
        }
        wp_enqueue_style('et-builder-preview-style', ET_BUILDER_URI . '/styles/preview.css', array(), ET_BUILDER_VERSION);
        wp_enqueue_script('et-builder-preview-script', ET_BUILDER_URI . '/scripts/frontend-builder-preview.js', array('jquery'), ET_BUILDER_VERSION, true);
        wp_localize_script('et-builder-preview-script', 'et_preview_params', array('preview_origin' => esc_url($preview_origin), 'alert_origin_not_matched' => sprintf(esc_html__('Unauthorized access. Preview cannot be accessed outside %1$s.', 'et_builder'), esc_url(home_url('', $preview_scheme)))));
    }
}
コード例 #2
0
 function _shortcode_callback($atts, $content = null, $function_name, $parent_address = '', $global_parent = '', $global_parent_type = '')
 {
     global $et_fb_processing_shortcode_object;
     $this->shortcode_atts = shortcode_atts($this->get_shortcode_fields(), $atts);
     $this->_decode_double_quotes();
     $this->_maybe_remove_default_atts_values();
     $global_shortcode_content = false;
     $ab_testing_enabled = et_is_ab_testing_active();
     $hide_subject_module = false;
     $post_id = apply_filters('et_is_ab_testing_active_post_id', get_the_ID());
     // If the section/row/module is disabled, hide it
     if (isset($this->shortcode_atts['disabled']) && 'on' === $this->shortcode_atts['disabled'] && !$et_fb_processing_shortcode_object) {
         return;
     }
     // need to perform additional check and some modifications in case AB testing enabled
     if ($ab_testing_enabled) {
         // check if ab testing enabled for this module and if it shouldn't be displayed currently
         if (!$et_fb_processing_shortcode_object && !$this->_is_display_module($this->shortcode_atts) && !et_pb_detect_cache_plugins()) {
             return;
         }
         // add class to the AB testing subject if needed
         if (isset($this->shortcode_atts['ab_subject_id']) && '' !== $this->shortcode_atts['ab_subject_id']) {
             $subject_class = sprintf(' et_pb_ab_subject et_pb_ab_subject_id-%1$s_%2$s', esc_attr($post_id), esc_attr($this->shortcode_atts['ab_subject_id']));
             $this->shortcode_atts['module_class'] = isset($this->shortcode_atts['module_class']) && '' !== $this->shortcode_atts['module_class'] ? $this->shortcode_atts['module_class'] . $subject_class : $subject_class;
             if (et_pb_detect_cache_plugins()) {
                 $hide_subject_module = true;
             }
         }
         // add class to the AB testing goal if needed
         if (isset($this->shortcode_atts['ab_goal']) && 'on' === $this->shortcode_atts['ab_goal']) {
             $goal_class = sprintf(' et_pb_ab_goal et_pb_ab_goal_id-%1$s', esc_attr($post_id));
             $this->shortcode_atts['module_class'] = isset($this->shortcode_atts['module_class']) && '' !== $this->shortcode_atts['module_class'] ? $this->shortcode_atts['module_class'] . $goal_class : $goal_class;
         }
     }
     //override module attributes for global module
     if (!empty($this->shortcode_atts['global_module'])) {
         $global_content = et_pb_load_global_module($this->shortcode_atts['global_module']);
         if ('' !== $global_content) {
             $global_atts = shortcode_parse_atts($global_content);
             foreach ($this->shortcode_atts as $single_attr => $value) {
                 if (isset($global_atts[$single_attr])) {
                     $this->shortcode_atts[$single_attr] = $global_atts[$single_attr];
                 }
             }
             if (false !== strpos($this->shortcode_atts['saved_tabs'], 'general') || 'all' === $this->shortcode_atts['saved_tabs']) {
                 $global_shortcode_content = et_pb_extract_shortcode_content($global_content, $function_name);
             }
         }
     }
     self::set_order_class($function_name);
     $this->pre_shortcode_content();
     $content = false !== $global_shortcode_content ? $global_shortcode_content : $content;
     if ($et_fb_processing_shortcode_object) {
         $this->shortcode_content = et_pb_fix_shortcodes($content, $this->decode_entities);
     } else {
         $this->shortcode_content = !(isset($this->is_structure_element) && $this->is_structure_element) ? do_shortcode(et_pb_fix_shortcodes($content, $this->decode_entities)) : '';
     }
     $this->shortcode_atts();
     $this->process_additional_options($function_name);
     $this->process_custom_css_options($function_name);
     // load inline fonts if needed
     if (isset($this->shortcode_atts['inline_fonts'])) {
         $this->process_inline_fonts_option($this->shortcode_atts['inline_fonts']);
     }
     // Prepare shortcode for the frontend building if enabled.
     $shortcode_callback = $et_fb_processing_shortcode_object ? '_shortcode_passthru_callback' : 'shortcode_callback';
     $output = $this->{$shortcode_callback}($atts, $content, $function_name, $parent_address, $global_parent, $global_parent_type);
     $this->_shortcode_callback_num++;
     // Hide module on specific screens if needed
     if (isset($this->shortcode_atts['disabled_on']) && '' !== $this->shortcode_atts['disabled_on']) {
         $disabled_on_array = explode('|', $this->shortcode_atts['disabled_on']);
         $i = 0;
         $current_media_query = 'max_width_767';
         foreach ($disabled_on_array as $value) {
             if ('on' === $value) {
                 ET_Builder_Module::set_style($function_name, array('selector' => '%%order_class%%', 'declaration' => 'display: none !important;', 'media_query' => ET_Builder_Element::get_media_query($current_media_query)));
             }
             $i++;
             $current_media_query = 1 === $i ? '768_980' : 'min_width_981';
         }
     }
     if ($hide_subject_module) {
         $previous_subjects_cache = get_post_meta($post_id, 'et_pb_subjects_cache', true);
         if (empty($previous_subjects_cache)) {
             $previous_subjects_cache = array();
         }
         if (empty($this->template_name)) {
             $previous_subjects_cache[$this->shortcode_atts['ab_subject_id']] = $output;
         } else {
             $previous_subjects_cache[$this->shortcode_atts['ab_subject_id']] = $this->shortcode_output();
         }
         // update the subjects cache in post meta to use it later
         update_post_meta($post_id, 'et_pb_subjects_cache', $previous_subjects_cache);
         // generate the placeholder to output on front-end instead of actual content
         $subject_placeholder = sprintf('<div class="et_pb_subject_placeholder et_pb_subject_placeholder_id_%1$s" style="display: none;"></div>', esc_attr($this->shortcode_atts['ab_subject_id']));
         return $subject_placeholder;
     }
     if (empty($this->template_name)) {
         return $output;
     }
     return $this->shortcode_output();
 }
コード例 #3
0
ファイル: core.php プロジェクト: pacificano/pacificano
    function et_builder_get_cache_notification_modal()
    {
        $cache_plugin_message = '';
        if (false !== ($cache_plugin = et_pb_detect_cache_plugins())) {
            $cache_plugin_message = sprintf(esc_html__('You are using the %1$s plugin. We recommend clearing the plugin cache after updating your theme.', 'et_builder'), esc_html($cache_plugin['name']));
            $cache_plugin_message = '<p>' . $cache_plugin_message . '</p>';
            $cache_plugin_message .= sprintf('<a href="%1$s" class="et_builder_modal_action_button" target="_blank">%2$s</a>', esc_url(admin_url($cache_plugin['page'])), esc_html__('Clear Plugin Cache', 'et_builder'));
        }
        $browser_cache_message = '<p>' . esc_html__('Builder files may also be cached in your browser. Please clear your browser cache.', 'et_builder') . '</p>';
        $browser_cache_message .= sprintf('<a href="http://www.refreshyourcache.com/en/home/" class="et_builder_modal_action_button" target="_blank">%1$s</a>', esc_html__('Clear Browser Cache', 'et_builder'));
        $output = sprintf('<div class="et_pb_modal_overlay et_modal_on_top et_pb_failure_notification_modal et_pb_new_template_modal">
			<div class="et_pb_prompt_modal">
				<h2>%1$s</h2>

				<div class="et_pb_prompt_modal_inside">
					<p>%2$s</p>
					%4$s
					%5$s
					<p>%6$s</p>
				</div>

				<a href="#"" class="et_pb_prompt_dont_proceed et-pb-modal-close"></a>

				<div class="et_pb_prompt_buttons">
					<br>
					<span class="spinner"></span>
					<a href="#" class="et_pb_reload_builder button-primary et_pb_prompt_proceed">%3$s</a>
				</div>
			</div>
		</div>', esc_html__('Builder Cache Warning', 'et_builder'), esc_html__('The Divi Builder has been updated, however your browser is loading an old cached version of the builder. Loading old files can cause the builder to malfunction.', 'et_builder'), esc_html__('Reload The Builder', 'et_builder'), $cache_plugin_message, $browser_cache_message, esc_html__('If you have cleared your plugin cache and browser cache, but still get this warning, then your files may be cached at the DNS or Server level. Contact your host or CDN for assistance.', 'et_builder'));
        return $output;
    }
コード例 #4
0
/**
 * Display the Notice about cache once the theme was udpated
 */
function et_pb_maybe_display_cache_notice()
{
    $ignore_notice_option = get_option('et_pb_cache_notice', array());
    $ignore_this_notice = empty($ignore_notice_option[ET_BUILDER_VERSION]) ? 'show' : $ignore_notice_option[ET_BUILDER_VERSION];
    $screen = get_current_screen();
    // check whether any cache plugin installed and get its page link
    $plugin_page = et_pb_detect_cache_plugins();
    if (current_user_can('manage_options') && 'post' === $screen->base && 'ignore' !== $ignore_this_notice && false !== $plugin_page) {
        $hide_button = sprintf(' <br> <a class="et_pb_hide_cache_notice" href="%3$s">%2$s</a> <a class="et_pb_hide_cache_notice" href="#">%1$s</a>', esc_html__('Hide Notice', 'et_builder'), esc_html__('Clear Cache', 'et_builder'), esc_url(admin_url($plugin_page)));
        $notice_text = et_get_safe_localization(__('The Divi Builder has been updated, but you are currently using a caching plugin. Please clear your plugin cache <strong>and</strong> clear your browser cache (in that order) to make sure you are loading the updated builder files. Loading cached files may cause the builder to malfunction.', 'et_builder'));
        printf('<div class="update-nag et-pb-update-nag"><p>%1$s%2$s</p></div>', $notice_text, $hide_button);
    }
}