Ticket #19968: 19968.diff
File 19968.diff, 3.3 KB (added by , 12 years ago) |
---|
-
shortcodes.php
179 179 // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag() 180 180 return 181 181 '\\[' // Opening bracket 182 . '( \\[?)'// 1: Optional second opening bracket for escaping shortcodes: [[tag]]183 . "( $tagregexp)"// 2: Shortcode name182 . '(?P<escape-open>\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] 183 . "(?P<name>$tagregexp)" // 2: Shortcode name 184 184 . '\\b' // Word boundary 185 . '( '// 3: Unroll the loop: Inside the opening shortcode tag185 . '(?P<attributes>' // 3: Unroll the loop: Inside the opening shortcode tag 186 186 . '[^\\]\\/]*' // Not a closing bracket or forward slash 187 187 . '(?:' 188 188 . '\\/(?!\\])' // A forward slash not followed by a closing bracket … … 195 195 . '|' 196 196 . '\\]' // Closing bracket 197 197 . '(?:' 198 . '( '// 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags198 . '(?P<content>' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags 199 199 . '[^\\[]*+' // Not an opening bracket 200 200 . '(?:' 201 201 . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag … … 205 205 . '\\[\\/\\2\\]' // Closing shortcode tag 206 206 . ')?' 207 207 . ')' 208 . '( \\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]]208 . '(?P<escape-close>\\]?)'; // 6: Optional second closing bracket for escaping shortcodes: [[tag]] 209 209 } 210 210 211 211 /** … … 223 223 global $shortcode_tags; 224 224 225 225 // allow [[foo]] syntax for escaping a tag 226 if ( $m[ 1] == '[' && $m[6] == ']' ) {226 if ( $m['escape-open'] == '[' && $m['escape-close'] == ']' ) { 227 227 return substr($m[0], 1, -1); 228 228 } 229 229 230 $tag = $m[ 2];231 $attr = shortcode_parse_atts( $m[ 3] );230 $tag = $m['name']; 231 $attr = shortcode_parse_atts( $m['attributes'] ); 232 232 233 if ( isset( $m[ 5] ) ) {233 if ( isset( $m['content'] ) ) { 234 234 // enclosing tag - extra parameter 235 return $m[ 1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];235 return $m['escape-open'] . call_user_func( $shortcode_tags[$tag], $attr, $m['content'], $tag ) . $m['escape-close']; 236 236 } else { 237 237 // self-closing tag 238 return $m[ 1] . call_user_func( $shortcode_tags[$tag], $attr, NULL, $tag ) . $m[6];238 return $m['escape-open'] . call_user_func( $shortcode_tags[$tag], $attr, NULL, $tag ) . $m['escape-close']; 239 239 } 240 240 } 241 241 … … 324 324 325 325 function strip_shortcode_tag( $m ) { 326 326 // allow [[foo]] syntax for escaping a tag 327 if ( $m[ 1] == '[' && $m[6] == ']' ) {327 if ( $m['escape-open'] == '[' && $m['escape-close'] == ']' ) { 328 328 return substr($m[0], 1, -1); 329 329 } 330 330 331 return $m[ 1] . $m[6];331 return $m['escape-open'] . $m['escape-close']; 332 332 } 333 333 334 334 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()