Make WordPress Core

Changeset 26050


Ignore:
Timestamp:
11/08/2013 10:21:02 PM (11 years ago)
Author:
wonderboymusic
Message:

Split the content to balance open tags when <!--nextpage--> and <!--more.*?--> are used. Needs filter inline docs. The 4 unit tests that were previously failing for ticket 6297 now pass.

See #6297.
Props devesine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r25695 r26050  
    11701170 */
    11711171function balanceTags( $text, $force = false ) {
    1172     if ( $force || get_option('use_balanceTags') == 1 )
    1173         return force_balance_tags( $text );
    1174     else
    1175         return $text;
     1172    if ( $force || get_option('use_balanceTags') == 1 ) {
     1173        $balance_tags_delimiters = apply_filters( 'balance_tags_delimiters', array( '<!--more.*?-->', '<!--nextpage-->' ) );
     1174        // Capture lets PREG_SPLIT_DELIM_CAPTURE return the delimiters
     1175        $delimiters_regex = '/(' . implode( '|', $balance_tags_delimiters ) . ')/';
     1176        $parts = preg_split( $delimiters_regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
     1177        return implode( '', array_map( 'force_balance_tags', $parts ) );
     1178    }
     1179
     1180    return $text;
    11761181}
    11771182
Note: See TracChangeset for help on using the changeset viewer.