Changeset 18952 for trunk/wp-includes/formatting.php
- Timestamp:
- 10/12/2011 04:50:30 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/formatting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r18877 r18952 233 233 * @return string The filtered content. 234 234 */ 235 function shortcode_unautop( $pee) {235 function shortcode_unautop( $pee ) { 236 236 global $shortcode_tags; 237 237 238 if ( !empty($shortcode_tags) && is_array($shortcode_tags) ) { 239 $tagnames = array_keys($shortcode_tags); 240 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 241 $pee = preg_replace('/<p>\\s*?(\\[(' . $tagregexp . ')\\b.*?\\/?\\](?:.+?\\[\\/\\2\\])?)\\s*<\\/p>/s', '$1', $pee); 242 } 243 244 return $pee; 238 if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) { 239 return $pee; 240 } 241 242 $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); 243 244 $pattern = 245 '/' 246 . '<p>' // Opening paragraph 247 . '\\s*+' // Optional leading whitespace 248 . '(' // 1: The shortcode 249 . '\\[' // Opening bracket 250 . "($tagregexp)" // 2: Shortcode name 251 . '\\b' // Word boundary 252 // Unroll the loop: Inside the opening shortcode tag 253 . '[^\\]\\/]*' // Not a closing bracket or forward slash 254 . '(?:' 255 . '\\/(?!\\])' // A forward slash not followed by a closing bracket 256 . '[^\\]\\/]*' // Not a closing bracket or forward slash 257 . ')*?' 258 . '(?:' 259 . '\\/\\]' // Self closing tag and closing bracket 260 . '|' 261 . '\\]' // Closing bracket 262 . '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags 263 . '[^\\[]*+' // Not an opening bracket 264 . '(?:' 265 . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag 266 . '[^\\[]*+' // Not an opening bracket 267 . ')*+' 268 . '\\[\\/\\2\\]' // Closing shortcode tag 269 . ')?' 270 . ')' 271 . ')' 272 . '\\s*+' // optional trailing whitespace 273 . '<\\/p>' // closing paragraph 274 . '/s'; 275 276 return preg_replace( $pattern, '$1', $pee ); 245 277 } 246 278
Note: See TracChangeset
for help on using the changeset viewer.