Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Search content for shortcodes and filter shortcodes through their hooks.
- *
- * If there are no shortcode tags defined, then the content will be returned
- * without any filtering. This might cause issues when plugins are disabled but
- * the shortcode will still show up in the post or content.
- *
- * @since 2.5
- * @uses $shortcode_tags
- * @uses get_shortcode_regex() Gets the search pattern for searching shortcodes.
- *
- * @param string $content Content to search for shortcodes
- * @return string Content with shortcodes filtered out.
- */
- function do_shortcode($content) {
- global $shortcode_tags;
- if (empty($shortcode_tags) || !is_array($shortcode_tags))
- return $content;
- $pattern = get_shortcode_regex();
- return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
- }
- /**
- * Retrieve the shortcode regular expression for searching.
- *
- * The regular expression combines the shortcode tags in the regular expression
- * in a regex class.
- *
- * @since 2.5
- * @uses $shortcode_tags
- *
- * @return string The shortcode search regular expression
- */
- function get_shortcode_regex() {
- global $shortcode_tags;
- $tagnames = array_keys($shortcode_tags);
- $tagregexp = join( '|', array_map('preg_quote', $tagnames) );
- return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';
- }
Add Comment
Please, Sign In to add comment