diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-25 09:03:55 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-25 09:03:55 +0000 |
commit | 4dbe26b26fe556c71cc38e2531110bc63f351b4d (patch) | |
tree | de454a939b6567f1eef16952ff4ba883548eb498 /wp-includes/shortcodes.php | |
parent | bc31549fc8053f8bc6502c337707168d5e66c508 (diff) | |
download | wordpress-mu-4dbe26b26fe556c71cc38e2531110bc63f351b4d.tar.gz wordpress-mu-4dbe26b26fe556c71cc38e2531110bc63f351b4d.tar.xz wordpress-mu-4dbe26b26fe556c71cc38e2531110bc63f351b4d.zip |
WP Merge to revision 7826
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1266 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/shortcodes.php')
-rw-r--r-- | wp-includes/shortcodes.php | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index 791710b..907f7ff 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -47,18 +47,17 @@ add_shortcode('baztag', 'baztag_func'); $shortcode_tags = array(); -function add_shortcode($tag, $func, $after_formatting = false) { +function add_shortcode($tag, $func) { global $shortcode_tags; - if ( is_callable($func) ) { - $shortcode_tags[($after_formatting)? 11:9][$tag] = $func; - } + if ( is_callable($func) ) + $shortcode_tags[$tag] = $func; } function remove_shortcode($tag) { global $shortcode_tags; - unset($shortcode_tags[9][$tag], $shortcode_tags[11][$tag]); + unset($shortcode_tags[$tag]); } function remove_all_shortcodes() { @@ -67,37 +66,25 @@ function remove_all_shortcodes() { $shortcode_tags = array(); } -function do_shortcode_after_formatting($content) { - return do_shortcode($content, true); -} -function do_shortcode($content, $after_formatting = false) { - $pattern = get_shortcode_regex($after_formatting); - if (!$pattern) { - return $content; - } else { - $callback_func = 'do_shortcode_tag'; - if ($after_formatting) - $callback_func .= '_after_formatting'; - - return preg_replace_callback('/' . $pattern . '/s', $callback_func, $content); - } -} -function get_shortcode_regex($after_formatting) { +function do_shortcode($content) { global $shortcode_tags; - if (empty($shortcode_tags[($after_formatting)? 11:9]) || !is_array($shortcode_tags[($after_formatting)? 11:9])) - return false; + if (empty($shortcode_tags) || !is_array($shortcode_tags)) + return $content; - $tagnames = array_keys($shortcode_tags[($after_formatting)? 11:9]); + $pattern = get_shortcode_regex(); + return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content); +} + +function get_shortcode_regex() { + global $shortcode_tags; + $tagnames = array_keys($shortcode_tags); $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?'; } -function do_shortcode_tag_after_formatting($m) { - return do_shortcode_tag($m, true); -} -function do_shortcode_tag($m, $after_formatting = false) { +function do_shortcode_tag($m) { global $shortcode_tags; $tag = $m[1]; @@ -105,10 +92,10 @@ function do_shortcode_tag($m, $after_formatting = false) { if ( isset($m[4]) ) { // enclosing tag - extra parameter - return call_user_func($shortcode_tags[($after_formatting)? 11:9][$tag], $attr, $m[4]); + return call_user_func($shortcode_tags[$tag], $attr, $m[4]); } else { // self-closing tag - return call_user_func($shortcode_tags[($after_formatting)? 11:9][$tag], $attr); + return call_user_func($shortcode_tags[$tag], $attr); } } @@ -147,7 +134,6 @@ function shortcode_atts($pairs, $atts) { return $out; } -add_filter( 'the_content', 'do_shortcode', 9 ); -add_filter( 'the_content', 'do_shortcode_after_formatting', 11 ); +add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() ?> |