Example #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)))));
    }
}
 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();
 }
Example #3
0
/**
 * Check whether split test has report
 *
 * @return bool
 */
function et_pb_ab_has_report($post_id)
{
    global $wpdb;
    if (!et_is_ab_testing_active()) {
        return false;
    }
    $table_name = $wpdb->prefix . 'et_divi_ab_testing_stats';
    $query = $wpdb->prepare("SELECT * FROM {$table_name} WHERE test_id = %d", $post_id);
    $result = $wpdb->get_row($query) ? true : false;
    return apply_filters('et_pb_ab_has_report', $result, $post_id);
}
Example #4
0
/**
 * Returns array of builder settings' value
 *
 * @return array of builder settings' value
 */
function et_pb_get_builder_settings_values($post_id = false)
{
    // Get post ID
    $post_id = $post_id ? $post_id : get_the_ID();
    // Page settings config
    $config = et_pb_get_builder_settings_configurations();
    // Defaults
    $default_bounce_rate_limit = 5;
    // Get values;
    $ab_bounce_rate_limit = get_post_meta($post_id, '_et_pb_ab_bounce_rate_limit', true);
    $et_pb_ab_bounce_rate_limit = '' !== $ab_bounce_rate_limit ? $ab_bounce_rate_limit : $default_bounce_rate_limit;
    $color_palette = get_post_meta($post_id, '_et_pb_color_palette', true);
    $et_pb_color_palette = '' !== $color_palette ? $color_palette : implode('|', et_pb_get_default_color_palette());
    $gutter_width = get_post_meta($post_id, '_et_pb_gutter_width', true);
    $et_pb_gutter_width = '' !== $gutter_width ? $gutter_width : $config['et_pb_gutter_width']['default'];
    $light_text_color = get_post_meta($post_id, '_et_pb_light_text_color', true);
    $et_pb_light_text_color = $config['et_pb_light_text_color']['default'] !== $light_text_color ? $light_text_color : $config['et_pb_light_text_color']['default'];
    $dark_text_color = get_post_meta($post_id, '_et_pb_dark_text_color', true);
    $et_pb_dark_text_color = $config['et_pb_dark_text_color']['default'] !== $dark_text_color ? $dark_text_color : $config['et_pb_dark_text_color']['default'];
    $content_area_background_color = get_post_meta($post_id, '_et_pb_content_area_background_color', true);
    $et_pb_content_area_background_color = '' === $content_area_background_color ? $config['et_pb_content_area_background_color']['default'] : $content_area_background_color;
    $section_background_color = get_post_meta($post_id, '_et_pb_section_background_color', true);
    $et_pb_section_background_color = '' === $section_background_color ? $config['et_pb_section_background_color']['default'] : $section_background_color;
    return apply_filters('et_pb_get_builder_settings_values', array('et_pb_enable_ab_testing' => et_is_ab_testing_active() ? 'on' : 'off', 'et_pb_ab_bounce_rate_limit' => $et_pb_ab_bounce_rate_limit, 'et_pb_ab_refresh_interval' => et_pb_ab_get_refresh_interval($post_id), 'et_pb_enable_shortcode_tracking' => get_post_meta($post_id, '_et_pb_enable_shortcode_tracking', true), 'et_pb_ab_current_shortcode' => '[et_pb_split_track id="' . $post_id . '" /]', 'et_pb_custom_css' => get_post_meta($post_id, '_et_pb_custom_css', true), 'et_pb_color_palette' => $et_pb_color_palette, 'et_pb_gutter_width' => $et_pb_gutter_width, 'et_pb_light_text_color' => strtolower($et_pb_light_text_color), 'et_pb_dark_text_color' => strtolower($et_pb_dark_text_color), 'et_pb_content_area_background_color' => strtolower($et_pb_content_area_background_color), 'et_pb_section_background_color' => strtolower($et_pb_section_background_color)), $post_id);
}