WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r30450 r29707  
    2929 */
    3030function wptexturize($text, $reset = false) {
    31     global $wp_cockneyreplace, $shortcode_tags;
     31    global $wp_cockneyreplace;
    3232    static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
    3333        $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true;
     
    206206    // Look for shortcodes and HTML elements.
    207207
    208     $tagnames = array_keys( $shortcode_tags );
    209     $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
    210     $tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex().
    211 
    212     $comment_regex =
    213           '!'           // Start of comment, after the <.
    214         . '(?:'         // Unroll the loop: Consume everything until --> is found.
    215         .     '-(?!->)' // Dash not followed by end of comment.
    216         .     '[^\-]*+' // Consume non-dashes.
    217         . ')*+'         // Loop possessively.
    218         . '-->';        // End of comment.
    219 
    220208    $regex =  '/('          // Capture the entire match.
    221209        .   '<'     // Find start of element.
    222210        .   '(?(?=!--)' // Is this a comment?
    223         .       $comment_regex  // Find end of comment
     211        .       '.+?--\s*>' // Find end of comment
    224212        .   '|'
    225213        .       '[^>]+>'    // Find end of element
     
    227215        . '|'
    228216        .   '\['        // Find start of shortcode.
    229         .   '[\/\[]?'   // Shortcodes may begin with [/ or [[
    230         .   $tagregexp  // Only match registered shortcodes, because performance.
     217        .   '\[?'       // Shortcodes may begin with [[
    231218        .   '(?:'
    232         .       '[^\[\]<>]+'    // Shortcodes do not contain other shortcodes. Quantifier critical.
     219        .       '[^\[\]<>]' // Shortcodes do not contain other shortcodes.
    233220        .   '|'
    234         .       '<[^\[\]>]*>'   // HTML elements permitted. Prevents matching ] before >.
    235         .   ')*+'       // Possessive critical.
     221        .       '<[^>]+>'   // HTML elements permitted. Prevents matching ] before >.
     222        .   ')++'
    236223        .   '\]'        // Find end of shortcode.
    237224        .   '\]?'       // Shortcodes may end with ]]
     
    255242            continue;
    256243
    257         } elseif ( '[' === $first && 1 === preg_match( '/^\[\/?' . $tagregexp . '(?:[^\[\]<>]+|<[^\[\]>]*>)*+\]$/', $curl ) ) {
     244        } elseif ( '[' === $first && 1 === preg_match( '/^\[(?:[^\[\]<>]|<[^>]+>)++\]$/', $curl ) ) {
    258245            // This is a shortcode delimiter.
    259246
    260247            _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );
    261248
    262         } elseif ( '[' === $first && 1 === preg_match( '/^\[[\/\[]?' . $tagregexp . '(?:[^\[\]<>]+|<[^\[\]>]*>)*+\]\]?$/', $curl ) ) {
     249        } elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<[^>]+>)++\]\]?$/', $curl ) ) {
    263250            // This is an escaped shortcode delimiter.
    264251
Note: See TracChangeset for help on using the changeset viewer.