Ticket #10082: 10082.diff
File 10082.diff, 2.0 KB (added by , 15 years ago) |
---|
-
wp-includes/shortcodes.php
175 175 $tagnames = array_keys($shortcode_tags); 176 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 177 177 178 return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 178 return '(\[?)' // possibly escape shortcode, part 1 179 . "\[($tagregexp)\b" // a valid shortcode, e.g. [foo 180 . '(.*?)' // maybe attributes 181 . '(\/)?' // mark self-closing shortcode with a / 182 . '\]' 183 . '(' 184 . '?(4)' // stop if the shortcode is self-closing 185 . '|' 186 . '(?:' 187 . "((?:(?!\[(?:$tagregexp)\b).)+?)" // look-ahead to make the shortcodes non-greedy 188 . '\[\/\2\]' // stop on [/foo] 189 . ')?' 190 . ')?' // allow for [foo] to be treated as [foo/] 191 . '(\]?)'; // possibly escape shortcode, part 2 179 192 } 180 193 181 194 /** … … 191 204 */ 192 205 function do_shortcode_tag($m) { 193 206 global $shortcode_tags; 194 195 // allow [[foo]] syntax for escaping a tag 196 if ($m[1] == '[' && $m[6] == ']') { 197 return substr($m[0], 1, -1); 207 208 $return = array_shift($m); 209 $begin = array_shift($m); 210 $end = array_pop($m); 211 212 // allow [[foo]] and [[foo]bar[/foo]] syntax for escaping a tag 213 if ($begin == '[' && $end == ']') { 214 return substr($return, 1, -1); 198 215 } 199 216 200 $tag = $m[2]; 201 $attr = shortcode_parse_atts($m[3]); 217 $tag = array_shift($m); 218 $attr = array_shift($m); 219 $content = array_pop($m); 220 221 $attr = shortcode_parse_atts($attr); 202 222 203 if ( isset($m[5])) {223 if ( $content ) { 204 224 // enclosing tag - extra parameter 205 return $ m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[5], $m[2]) . $m[6];225 return $begin . call_user_func($shortcode_tags[$tag], $attr, $content, $tag) . $end; 206 226 } else { 207 227 // self-closing tag 208 return $ m[1] . call_user_func($shortcode_tags[$tag], $attr, NULL, $m[2]) . $m[6];228 return $begin . call_user_func($shortcode_tags[$tag], $attr, NULL, $tag) . $end; 209 229 } 210 230 } 211 231