WordPress.org

Make WordPress Core

Ticket #6969: 6969.diff

File 6969.diff, 1.3 KB (added by DD32, 10 years ago)
  • wp-includes/formatting.php

     
    3232        $has_pre_parent = false;
    3333        $output = '';
    3434        $curl = '';
    35         $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
     35        $textarr = preg_split('/([<\[].*[>\]]|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    3636        $stop = count($textarr);
    3737
    3838        // if a plugin has provided an autocorrect array, use it
     
    5050        $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');
    5151        $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
    5252
     53        $shortcodes = array_keys($GLOBALS['shortcode_tags']);
     54        $shortcoderegex = '/^\[' . implode('|', array_map('preg_quote', $shortcodes) ) . '/i';
     55
    5356        for ( $i = 0; $i < $stop; $i++ ) {
    5457                $curl = $textarr[$i];
    5558
     
    6467                        $has_pre_parent = true;
    6568                } elseif (strpos($curl, '</pre>') !== false) {
    6669                        $has_pre_parent = false;
     70                } elseif ( preg_match($shortcoderegex, $curl) ) {
     71                        $next = false;
    6772                } else {
    6873                        $next = true;
    6974                }