Changeset 10576 for trunk/wp-includes/shortcodes.php
- Timestamp:
- 02/15/2009 04:01:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/shortcodes.php
r8613 r10576 157 157 * The regular expression combines the shortcode tags in the regular expression 158 158 * in a regex class. 159 * 159 * 160 * The regular expresion contains 6 different sub matches to help with parsing. 161 * 162 * 1/6 - An extra [ or ] to allow for escaping shortcodes with double [[]] 163 * 2 - The shortcode name 164 * 3 - The shortcode argument list 165 * 4 - The self closing / 166 * 5 - The content of a shortcode when it wraps some content. 167 * 160 168 * @since 2.5 161 169 * @uses $shortcode_tags … … 168 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 169 177 170 return ' \[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';178 return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 171 179 } 172 180 173 181 /** 174 182 * Regular Expression callable for do_shortcode() for calling shortcode hook. 183 * @see get_shortcode_regex for details of the match array contents. 175 184 * 176 185 * @since 2.5 … … 184 193 global $shortcode_tags; 185 194 186 $tag = $m[1]; 187 $attr = shortcode_parse_atts($m[2]); 188 189 if ( isset($m[4]) ) { 195 // allow [[foo]] syntax for escaping a tag 196 if ($m[1] == '[' && $m[6] == ']') { 197 return substr($m[0], 1, -1); 198 } 199 200 $tag = $m[2]; 201 $attr = shortcode_parse_atts($m[3]); 202 203 if ( isset($m[5]) ) { 190 204 // enclosing tag - extra parameter 191 return call_user_func($shortcode_tags[$tag], $attr, $m[4], $tag);205 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[5]) . $m[6]; 192 206 } else { 193 207 // self-closing tag 194 return call_user_func($shortcode_tags[$tag], $attr, NULL, $tag);208 return $m[1] . call_user_func($shortcode_tags[$tag], $attr) . $m[6]; 195 209 } 196 210 }
Note: See TracChangeset
for help on using the changeset viewer.