/** * Parse shortcodes in the page content * @param string page content to be evaluated for internal shortcodes */ function wpv_parse_content_shortcodes($content) { $inner_expressions = array(); $inner_expressions[] = "/\\[types.*?\\].*?\\[\\/types\\]/i"; $inner_expressions[] = "/\\[(wpv-post-|types).*?\\]/i"; // search for shortcodes $matches = array(); $counts = _find_outer_brackets($content, $matches); // iterate 0-level shortcode elements if ($counts > 0) { foreach ($matches as $match) { foreach ($inner_expressions as $inner_expression) { $inner_counts = preg_match_all($inner_expression, $match, $inner_matches); // replace all 1-level inner shortcode matches if ($inner_counts > 0) { foreach ($inner_matches[0] as &$inner_match) { // execute shortcode content and replace $replacement = do_shortcode($inner_match); $resolved_match = $replacement; $content = str_replace($inner_match, $resolved_match, $content); $match = str_replace($inner_match, $resolved_match, $match); } } } } } return $content; }
/** * Parse shortcodes in the page content * @param string page content to be evaluated for internal shortcodes */ function wpv_parse_content_shortcodes($content) { global $WPV_settings; $views_shortcodes_regex = wpv_inner_shortcodes_list_regex(); $inner_expressions = array(); $inner_expressions[] = "/\\[types.*?\\].*?\\[\\/types\\]/i"; $inner_expressions[] = "/\\[(". $views_shortcodes_regex .").*?\\]/i"; // support for custom inner shortcodes via settings page // since 1.4 $custom_inner_shortcodes = array(); if ( isset( $WPV_settings->wpv_custom_inner_shortcodes ) && is_array( $WPV_settings->wpv_custom_inner_shortcodes ) ) { $custom_inner_shortcodes = $WPV_settings->wpv_custom_inner_shortcodes; } // wpv_custom_inner_shortcodes filter // since 1.4 // takes an array of shortcodes and returns an array of shortcodes $custom_inner_shortcodes = apply_filters( 'wpv_custom_inner_shortcodes', $custom_inner_shortcodes ); // remove duplicates $custom_inner_shortcodes = array_unique( $custom_inner_shortcodes ); // add the custom inner shortcodes, whether they are self-closing or not if ( sizeof( $custom_inner_shortcodes ) > 0 ) { foreach ( $custom_inner_shortcodes as $custom_inner_shortcode ) { $inner_expressions[] = "/\\[" . $custom_inner_shortcode . ".*?\\].*?\\[\\/" . $custom_inner_shortcode . "\\]/i"; } $inner_expressions[] = "/\\[(" . implode( '|', $custom_inner_shortcodes ) . ").*?\\]/i"; } // search for shortcodes $matches = array(); $counts = _find_outer_brackets($content, $matches); // iterate 0-level shortcode elements if($counts > 0) { foreach($matches as $match) { foreach ($inner_expressions as $inner_expression) { $inner_counts = preg_match_all($inner_expression, $match, $inner_matches); // replace all 1-level inner shortcode matches if($inner_counts > 0) { foreach($inner_matches[0] as &$inner_match) { // execute shortcode content and replace $resolved_match = wpv_preprocess_shortcodes_in_html_elements($inner_match); $filter_state = new WPV_WP_filter_state( 'the_content' ); $resolved_match = do_shortcode( $resolved_match ); $filter_state->restore(); $content = str_replace($inner_match, $resolved_match, $content); $match = str_replace($inner_match, $resolved_match, $match); } } } } } return $content; }
/** * Parse shortcodes in the page content * @param string page content to be evaluated for internal shortcodes */ function wpv_parse_content_shortcodes($content) { global $WP_Views; $options = $WP_Views->get_options(); $inner_expressions = array(); $inner_expressions[] = "/\\[types.*?\\].*?\\[\\/types\\]/i"; $inner_expressions[] = "/\\[(wpv-post-|wpv-taxonomy-|types|wpv-current-user|wpv-user).*?\\]/i"; // support for custom inner shortcodes via settings page // since 1.4 $custom_inner_shortcodes = array(); if (isset($options['wpv_custom_inner_shortcodes']) && is_array($options['wpv_custom_inner_shortcodes'])) { $custom_inner_shortcodes = $options['wpv_custom_inner_shortcodes']; } // wpv_custom_inner_shortcodes filter // since 1.4 // takes an array of shortcodes and returns an array of shortcodes $custom_inner_shortcodes = apply_filters('wpv_custom_inner_shortcodes', $custom_inner_shortcodes); // remove duplicates $custom_inner_shortcodes = array_unique($custom_inner_shortcodes); // add the custom inner shortcodes, whether they are self-closing or not if (sizeof($custom_inner_shortcodes) > 0) { foreach ($custom_inner_shortcodes as $custom_inner_shortcode) { $inner_expressions[] = "/\\[" . $custom_inner_shortcode . ".*?\\].*?\\[\\/" . $custom_inner_shortcode . "\\]/i"; } $inner_expressions[] = "/\\[(" . implode('|', $custom_inner_shortcodes) . ").*?\\]/i"; } // search for shortcodes $matches = array(); $counts = _find_outer_brackets($content, $matches); // iterate 0-level shortcode elements if ($counts > 0) { foreach ($matches as $match) { foreach ($inner_expressions as $inner_expression) { $inner_counts = preg_match_all($inner_expression, $match, $inner_matches); // replace all 1-level inner shortcode matches if ($inner_counts > 0) { foreach ($inner_matches[0] as &$inner_match) { // execute shortcode content and replace $replacement = do_shortcode($inner_match); $resolved_match = $replacement; $content = str_replace($inner_match, $resolved_match, $content); $match = str_replace($inner_match, $resolved_match, $match); } } } } } return $content; }