Created
December 1, 2010 12:10
-
-
Save paulchubatyy/723403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_shortcode_regex() { | |
global $shortcode_tags; | |
$tagnames = array_keys($shortcode_tags); | |
$tagregexp = join( '|', array_map('preg_quote', $tagnames) ); | |
// WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes() | |
return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment