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; }
/** *set status of builder (open/closed) and save the shortcodes that are used in the post **/ public function meta_box_save() { if (isset($_POST['post_ID'])) { //save if the editor is active if (isset($_POST['aviaLayoutBuilder_active'])) { update_post_meta((int) $_POST['post_ID'], '_aviaLayoutBuilder_active', $_POST['aviaLayoutBuilder_active']); $_POST['content'] = ShortcodeHelper::clean_up_shortcode($_POST['content']); } //save the hidden container with unmodified shortcode if (isset($_POST['_aviaLayoutBuilderCleanData'])) { update_post_meta((int) $_POST['post_ID'], '_aviaLayoutBuilderCleanData', $_POST['_aviaLayoutBuilderCleanData']); } //extract all shortcodes from the post array and store them so we know what we are dealing with when the user opens a page. //usesfull for special elements that we might need to render outside of the default loop like fullscreen slideshows preg_match_all("/" . ShortcodeHelper::get_fake_pattern() . "/s", $_POST['content'], $matches); if (is_array($matches) && !empty($matches[0])) { $matches = ShortcodeHelper::build_shortcode_tree($matches); update_post_meta((int) $_POST['post_ID'], '_avia_builder_shortcode_tree', $matches); } } }