Make WordPress Core

Ticket #6969: wp6969_c.diff

File wp6969_c.diff, 1.9 KB (added by mzizka, 17 years ago)

Updated patch that covers last mentioned case scenario

  • wp-includes/formatting.php

     
    2828 */
    2929function wptexturize($text) {
    3030        global $wp_cockneyreplace;
     31        global $shortcode_tags;
     32
    3133        $next = true;
    3234        $has_pre_parent = false;
    3335        $output = '';
    3436        $curl = '';
    35         $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    36         $stop = count($textarr);
    3737
     38        $tagnames = array_keys($shortcode_tags);
     39        $tagregexp = join('|', array_map('preg_quote', $tagnames));
     40        $regex = '/(<[^>]*>|(?<!\[)\[('.$tagregexp.')\b[^\/\]]*\/?\](?:.+?\[\/\2\])?)/s';
     41        $textarr = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE);
     42  $stop = count($textarr);
     43
    3844        // if a plugin has provided an autocorrect array, use it
    3945        if ( isset($wp_cockneyreplace) ) {
    4046                $cockney = array_keys($wp_cockneyreplace);
     
    5056        $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');
    5157        $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
    5258
     59        $skip_count = 0;
     60        $shortcode_start_regex = '/^\[(?:'.$tagregexp.')\b/';
    5361        for ( $i = 0; $i < $stop; $i++ ) {
    5462                $curl = $textarr[$i];
    5563
    56                 if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
     64                if ($skip_count > 0) {
     65                        $skip_count--;
     66                        continue;
     67                } elseif (empty($curl)) {
     68                        $next = true;
     69                        continue;
     70                }       elseif (preg_match($shortcode_start_regex, ltrim($curl))) { //shortcode
     71                        $skip_count = 1;
     72                } elseif ('<' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
    5773                        // static strings
    5874                        $curl = str_replace($static_characters, $static_replacements, $curl);
    5975                        // regular expressions