WordPress.org

Make WordPress Core

Ticket #16684: 16684.diff

File 16684.diff, 1.7 KB (added by solarissmoke, 7 years ago)
  • wp-includes/formatting.php

     
    2929function wptexturize($text) {
    3030        global $wp_cockneyreplace;
    3131        static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
    32         $output = '';
    33         $curl = '';
     32
    3433        $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    35         $stop = count($textarr);
    3634
    3735        // No need to set up these variables more than once
    3836        if (!$static_setup) {
     
    7068        $no_texturize_tags_stack = array();
    7169        $no_texturize_shortcodes_stack = array();
    7270
    73         for ( $i = 0; $i < $stop; $i++ ) {
    74                 $curl = $textarr[$i];
    75 
    76                 if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0]
     71        foreach( $textarr as &$curl ) {
     72                if ( !empty( $curl ) && '<' != $curl[0] && '[' != $curl[0]
    7773                                && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) {
    7874                        // This is not a tag, nor is the texturization disabled
    7975                        // static strings
    8076                        $curl = str_replace($static_characters, $static_replacements, $curl);
    8177                        // regular expressions
    8278                        $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
    83                 } elseif (!empty($curl)) {
     79                } elseif ( !empty( $curl ) ) {
    8480                        /*
    8581                         * Only call _wptexturize_pushpop_element if first char is correct
    8682                         * tag opening
     
    9288                }
    9389
    9490                $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
    95                 $output .= $curl;
    9691        }
    9792
    98         return $output;
     93        return implode( '', $textarr );
    9994}
    10095
    10196/**