WordPress.org

Make WordPress Core

Ticket #20278: balanceTags_quicktags-trunk.patch

File balanceTags_quicktags-trunk.patch, 825 bytes (added by devesine, 6 years ago)
  • wp-includes/formatting.php

     
    10621062function balanceTags( $text, $force = false ) {
    10631063        if ( !$force && get_option('use_balanceTags') == 0 )
    10641064                return $text;
    1065         return force_balance_tags( $text );
     1065        $quicktags = apply_filters( 'balancetags_quicktags', array( 'more.*?', 'nextpage' ) );
     1066        // Outer capture lets PREG_SPLIT_DELIM_CAPTURE return the quicktags
     1067        // Inner noncapturing group matches any of the defined quicktags
     1068        $quicktag_regex = '/(<!--(?:' . implode('|', $quicktags) . ')-->)/';
     1069        $parts = preg_split($quicktag_regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE);
     1070        return implode('', array_map('force_balance_tags', $parts));
    10661071}
    10671072
    10681073/**