function pre_compile($content) { global $shortcode_tags; //in case we got none/more than one postcontent elements make sure that replacement doesnt get executed/onle gets executed once if (strpos($content, 'av_postcontent') === false) { return $content; } //save the "real" shortcode array $old_sc = $shortcode_tags; //execute only this single shortcode and return the result $shortcode_tags = array($this->config['shortcode'] => array($this, 'shortcode_handler')); $content = do_shortcode($content); //re create the old shortcode pattern $shortcode_tags = $old_sc; //$content = preg_replace("!\[av_postcontent.*?\]!","",$content); //now we need to re calculate the shortcode tree so that all elements that are pulled from different posts also get the correct location $pattern = str_replace('av_postcontent', 'av_psprocessed', ShortcodeHelper::get_fake_pattern()); preg_match_all("/" . $pattern . "/s", $content, $matches); ShortcodeHelper::$tree = ShortcodeHelper::build_shortcode_tree($matches); return $content; }
/** *function that checks if a dynamic template exists and uses that template instead of the default page template **/ public function template_redirect() { global $avia_config; $post_id = @get_the_ID(); if ($post_id && is_singular() || isset($avia_config['builder_redirect_id'])) { if (!empty($avia_config['builder_redirect_id'])) { $post_id = $avia_config['builder_redirect_id']; } ShortcodeHelper::$tree = get_post_meta($post_id, '_avia_builder_shortcode_tree', true); if ('active' == get_post_meta($post_id, '_aviaLayoutBuilder_active', true) && ($template = locate_template('template-builder.php', false))) { $avia_config['conditionals']['is_builder'] = true; //only redirect if no custom template is set $template_file = get_post_meta($post_id, '_wp_page_template', true); if ("default" == $template_file || empty($template_file)) { $avia_config['conditionals']['is_builder_template'] = true; require_once $template; exit; } } //if a custom page was passed and the template builder is not active redirect to the default page template if (isset($avia_config['builder_redirect_id'])) { if ($template = locate_template('page.php', false)) { require_once $template; exit; } } } }
function post_has_layerslider() { if (!is_singular()) { return false; } if (empty(ShortcodeHelper::$tree)) { $id = @get_the_ID(); if (!$id) { return false; } ShortcodeHelper::$tree = get_post_meta($id, '_avia_builder_shortcode_tree', true); } if (is_array(ShortcodeHelper::$tree)) { foreach (ShortcodeHelper::$tree as $sc) { if ($sc['tag'] == 'av_layerslider') { return true; } } } //script below excluded. creates to many layout errors //is the user tries to use the default layerslider shortcode also include the slider global $post; if (!empty($post->post_content) && strpos($post->post_content, "[layerslider") !== false) { return true; } /* */ return false; }
/** *function that checks if a dynamic template exists and uses that template instead of the default page template **/ public function template_redirect() { $post_id = @get_the_ID(); if ($post_id && is_singular()) { ShortcodeHelper::$tree = get_post_meta($post_id, '_avia_builder_shortcode_tree', true); if ('active' == get_post_meta($post_id, '_aviaLayoutBuilder_active', true) && ($template = locate_template('template-builder.php', false))) { global $avia_config; $avia_config['conditionals']['is_builder'] = true; //only redirect if no custom template is set $template_file = get_post_meta($post_id, '_wp_page_template', true); if ("default" == $template_file || empty($template_file)) { $avia_config['conditionals']['is_builder_template'] = true; require_once $template; exit; } } } }