web/wp-includes/shortcodes.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
   173 function get_shortcode_regex() {
   173 function get_shortcode_regex() {
   174 	global $shortcode_tags;
   174 	global $shortcode_tags;
   175 	$tagnames = array_keys($shortcode_tags);
   175 	$tagnames = array_keys($shortcode_tags);
   176 	$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
   176 	$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
   177 
   177 
       
   178 	// WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes()
   178 	return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';
   179 	return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';
   179 }
   180 }
   180 
   181 
   181 /**
   182 /**
   182  * Regular Expression callable for do_shortcode() for calling shortcode hook.
   183  * Regular Expression callable for do_shortcode() for calling shortcode hook.
   287 	if (empty($shortcode_tags) || !is_array($shortcode_tags))
   288 	if (empty($shortcode_tags) || !is_array($shortcode_tags))
   288 		return $content;
   289 		return $content;
   289 
   290 
   290 	$pattern = get_shortcode_regex();
   291 	$pattern = get_shortcode_regex();
   291 
   292 
   292 	return preg_replace('/'.$pattern.'/s', '', $content);
   293 	return preg_replace('/'.$pattern.'/s', '$1$6', $content);
   293 }
   294 }
   294 
   295 
   295 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
   296 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
   296 
   297 
   297 ?>
   298 ?>