Ticket #18558: 18558.diff
File 18558.diff, 3.4 KB (added by , 10 years ago) |
---|
-
wp-includes/media.php
1061 1061 * @return string Content with shortcode parsed 1062 1062 */ 1063 1063 function run_shortcode( $content ) { 1064 global $shortcode_tags;1065 1066 // Back up current registered shortcodes and clear them all out1067 $orig_shortcode_tags = $shortcode_tags;1068 remove_all_shortcodes();1069 1070 1064 add_shortcode( 'embed', array(&$this, 'shortcode') ); 1071 1065 1072 1066 // Do the shortcode (only the [embed] one is registered) 1073 $content = do_shortcode( $content );1067 $content = do_shortcode( $content, 'embed' ); 1074 1068 1075 // Put the original shortcodes back1076 $shortcode_tags = $orig_shortcode_tags;1077 1078 1069 return $content; 1079 1070 } 1080 1071 … … 1438 1429 return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr ); 1439 1430 } 1440 1431 1441 ?> 1442 No newline at end of file 1432 ?> -
wp-includes/shortcodes.php
141 141 * @param string $content Content to search for shortcodes 142 142 * @return string Content with shortcodes filtered out. 143 143 */ 144 function do_shortcode($content ) {144 function do_shortcode($content, $tag = null) { 145 145 global $shortcode_tags; 146 146 147 147 if (empty($shortcode_tags) || !is_array($shortcode_tags)) 148 148 return $content; 149 149 150 $pattern = get_shortcode_regex( );150 $pattern = get_shortcode_regex( $tag ); 151 151 return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content); 152 152 } 153 153 … … 168 168 * @since 2.5 169 169 * @uses $shortcode_tags 170 170 * 171 * @param string $tag Specify a single tag to process 172 * 171 173 * @return string The shortcode search regular expression 172 174 */ 173 function get_shortcode_regex() { 174 global $shortcode_tags; 175 $tagnames = array_keys($shortcode_tags); 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 175 function get_shortcode_regex( $tag = null ) { 176 if ( empty( $tag ) ) 177 $tag = '[^\s\]]+'; 178 else 179 $tag = preg_quote( $tag ); 177 180 178 181 // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes() 179 return '(.?)\[(' .$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';182 return '(.?)\[(' . $tag . ')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 180 183 } 181 184 182 185 /** … … 201 204 $tag = $m[2]; 202 205 $attr = shortcode_parse_atts( $m[3] ); 203 206 207 if ( empty( $shortcode_tags[$tag] ) || ! is_callable( $shortcode_tags[$tag] ) ) 208 $shortcode_tags[$tag] = 'unregistered_shortcode'; 209 204 210 if ( isset( $m[5] ) ) { 205 211 // enclosing tag - extra parameter 206 212 return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6]; … … 295 301 296 302 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() 297 303 298 ?> 299 No newline at end of file 304 /** 305 * Function used to process any unregistered shortcodes 306 * 307 * @param array $atts Attributes from shortcode - Unused 308 * @param string $content Content of shortcode 309 * 310 * @return string Content of shortcode 311 */ 312 function unregistered_shortcode( $atts = null, $content = null ) { 313 return (string) $content; 314 } 315 ?>