Make WordPress Core


Ignore:
Timestamp:
07/31/2015 01:44:04 AM (10 years ago)
Author:
azaozz
Message:

Backport r33469 and r33470 to 3.9.
See #33106.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9/src/wp-includes/shortcodes.php

    r33386 r33523  
    330330   
    331331    $pattern = get_shortcode_regex();
    332 
    333     $comment_regex =
    334           '!'           // Start of comment, after the <.
    335         . '(?:'         // Unroll the loop: Consume everything until --> is found.
    336         .     '-(?!->)' // Dash not followed by end of comment.
    337         .     '[^\-]*+' // Consume non-dashes.
    338         . ')*+'         // Loop possessively.
    339         . '(?:-->)?';   // End of comment. If not found, match all input.
    340 
    341     $regex =
    342           '/('                   // Capture the entire match.
    343         .     '<'                // Find start of element.
    344         .     '(?(?=!--)'        // Is this a comment?
    345         .         $comment_regex // Find end of comment.
    346         .     '|'
    347         .         '[^>]*>?'      // Find end of element. If not found, match all input.
    348         .     ')'
    349         . ')/s';
    350 
    351     $textarr = preg_split( $regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     332    $textarr = wp_html_split( $content );
    352333
    353334    foreach ( $textarr as &$element ) {
    354         if ( '<' !== $element[0] ) {
     335        if ( '' == $element || '<' !== $element[0] ) {
    355336            continue;
    356337        }
     
    367348        }
    368349
    369         if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) ) {
     350        if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) {
    370351            // Encode all [ and ] chars.
    371352            $element = strtr( $element, $trans );
Note: See TracChangeset for help on using the changeset viewer.