function _shortcode_callback($atts, $content = null, $function_name) { $this->shortcode_atts = shortcode_atts($this->get_shortcode_fields(), $atts); $this->_decode_double_quotes(); $this->_maybe_remove_default_atts_values(); $global_shortcode_content = false; // If the section/row/module is disabled, hide it if (isset($this->shortcode_atts['disabled']) && 'on' === $this->shortcode_atts['disabled']) { return; } //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; $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(); $output = $this->shortcode_callback($atts, $content, $function_name); $this->_shortcode_callback_num++; $this->process_additional_options($function_name); $this->process_custom_css_options($function_name); if (empty($this->template_name)) { return $output; } return $this->shortcode_output(); }
function _shortcode_callback($atts, $content = null, $function_name) { $this->shortcode_atts = shortcode_atts($this->get_shortcode_fields(), $atts); $this->_decode_double_quotes(); $this->_maybe_remove_default_atts_values(); $global_shortcode_content = false; // If the section/row/module is disabled, hide it if (isset($this->shortcode_atts['disabled']) && 'on' === $this->shortcode_atts['disabled']) { return; } //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; $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(); $output = $this->shortcode_callback($atts, $content, $function_name); $this->_shortcode_callback_num++; $this->process_additional_options($function_name); $this->process_custom_css_options($function_name); // 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 (empty($this->template_name)) { return $output; } return $this->shortcode_output(); }
function _shortcode_passthru_callback($atts, $content = null, $function_name, $parent_address = '', $global_parent = '', $global_parent_type = '') { global $post; $attrs = array(); $fields = $this->process_fields($this->fields_unprocessed); $global_shortcode_content = false; $function_name_processed = et_fb_prepare_tag($function_name); //override module attributes for global module if (!empty($atts['global_module'])) { $global_content = et_pb_load_global_module($atts['global_module']); if ('' !== $global_content) { if (!isset($atts['saved_tabs']) || false !== strpos($atts['saved_tabs'], 'general') || 'all' === $atts['saved_tabs']) { $global_shortcode_content = et_pb_extract_shortcode_content($global_content, $function_name_processed); } // remove the shortcode content to avoid conflicts of parent attributes with similar attrs from child modules if (false !== $global_shortcode_content) { $global_content_processed = str_replace($global_shortcode_content, '', $global_content); } else { $global_content_processed = $global_content; } $global_atts = shortcode_parse_atts($global_content_processed); foreach ($this->shortcode_atts as $single_attr => $value) { if (isset($global_atts[$single_attr])) { $this->shortcode_atts[$single_attr] = $global_atts[$single_attr]; } } } else { // remove global_module attr if it doesn't exist in DB $this->shortcode_atts['global_module'] = ''; $global_parent = ''; } } // TODO, cleanup this loop. foreach ($this->shortcode_atts as $shortcode_attr_key => $shortcode_attr_value) { if (isset($fields[$shortcode_attr_key]['type']) && 'computed' === $fields[$shortcode_attr_key]['type']) { $field = $fields[$shortcode_attr_key]; $depends_on = array(); foreach ($field['computed_depends_on'] as $depends_on_field) { $depends_on[$depends_on_field] = $this->shortcode_atts[$depends_on_field]; } if (!is_callable($field['computed_callback'])) { die($shortcode_attr_key . ' Callback:' . $field['computed_callback'] . ' is not callable.... '); // TODO, fix this make it more graceful... } $value = call_user_func($field['computed_callback'], $depends_on); } else { $value = $shortcode_attr_value; } $attrs[$shortcode_attr_key] = is_string($value) ? html_entity_decode($value) : $value; } // Format FB component path // TODO, move this to class method and property, and allow both to be overridden $component_path = str_replace('et_pb_', '', $function_name_processed); $component_path = str_replace('_', '-', $component_path); $component_path = $component_path; // Prepare modules. $modules = 'child' === $this->type ? self::$child_modules : self::$parent_modules; if (isset($post->post_type, $modules[$post->post_type][$function_name_processed])) { $modules = $modules[$post->post_type][$function_name_processed]; } else { $modules = array(); } // Build custom CSS. $custom_css = array(); if (isset($modules->custom_css_options)) { foreach ($modules->custom_css_options as $custom_css_key => $custom_css_option) { $custom_css_option['key'] = "custom_css_{$custom_css_key}"; $custom_css[] = $custom_css_option; } } // Build advanced options and defaults. $advanced_options = array(); $advanced_defaults = array(); if (!empty($modules->advanced_options)) { $advanced_options = $modules->advanced_options; } if (isset($modules->fields_unprocessed)) { foreach ($modules->fields_unprocessed as $fields_unprocessed_key => $field_unprocessed) { if (isset($field_unprocessed['default'], $field_unprocessed['tab_slug']) && 'advanced' === $field_unprocessed['tab_slug']) { $advanced_defaults[$fields_unprocessed_key] = $field_unprocessed['default']; } } } $_i = isset($atts['_i']) ? $atts['_i'] : 0; $address = isset($atts['_address']) ? $atts['_address'] : '0'; // set the global parent if exists if ((!isset($attrs['global_module']) || '' === $attrs['global_module']) && '' !== $global_parent) { $attrs['global_parent'] = $global_parent; } if (isset($this->is_structure_element) && $this->is_structure_element) { $this->fb_support = true; } if (!$this->fb_support) { global $et_fb_processing_shortcode_object; $et_fb_processing_shortcode_object = false; $raw_child_content = $content; $content = $this->_shortcode_callback($atts, $content, $function_name_processed); $executed_shortcode = do_shortcode($content); $processed_content = false !== $global_shortcode_content ? $global_shortcode_content : $this->shortcode_content; $attrs['content_new'] = array_key_exists('content_new', $this->whitelisted_fields) ? $processed_content : et_fb_process_shortcode($processed_content, $address, $global_parent, $global_parent_type); $et_fb_processing_shortcode_object = true; } else { $processed_content = false !== $global_shortcode_content ? $global_shortcode_content : $this->shortcode_content; $content = array_key_exists('content_new', $this->whitelisted_fields) || 'et_pb_code' === $function_name_processed || 'et_pb_fullwidth_code' === $function_name_processed ? $processed_content : et_fb_process_shortcode($processed_content, $address, $global_parent, $global_parent_type); } if (is_array($content)) { $prepared_content = $content; } else { if ($this->fb_support && count(preg_split('/\\r\\n*\\n/', trim($content), -1, PREG_SPLIT_NO_EMPTY)) > 1) { $prepared_content = wpautop($content); } else { $prepared_content = html_entity_decode($content); } } // Build object. $object = array('_i' => $_i, '_order' => $_i, 'address' => $address, 'child_slug' => $this->child_slug, 'fb_support' => $this->fb_support, 'parent_address' => $parent_address, 'shortcode_index' => $this->_shortcode_callback_num, 'type' => $function_name, 'component_path' => $component_path, 'attrs' => $attrs, 'advanced_options' => $advanced_options, 'advanced_defaults' => $advanced_defaults, 'defaults' => isset($this->defaults) ? $this->defaults : '', 'fields_defaults' => isset($this->fields_defaults) ? $this->fields_defaults : '', 'custom_css' => $custom_css, 'content' => $prepared_content, 'is_module_child' => 'child' === $this->type, 'prepared_styles' => !$this->fb_support ? ET_Builder_Element::get_style() : ''); if (!$this->fb_support) { if (!empty($this->child_slug)) { $object['raw_child_content'] = $raw_child_content; } } return $object; }
function _shortcode_callback($atts, $content = null, $function_name) { $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']) { 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 (!$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; $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); $output = $this->shortcode_callback($atts, $content, $function_name); $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(); }