From 2a8b83fbb060e48251937b1c6ad8a462898284dc Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 8 Nov 2013 22:21:02 +0000 Subject: [PATCH] Split the content to balance open tags when `` and `` are used. Needs filter inline docs. The 4 unit tests that were previously failing for ticket 6297 now pass. See #6297. Props devesine. git-svn-id: https://develop.svn.wordpress.org/trunk@26050 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 904c99b17b..5d6813c27b 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -1169,10 +1169,15 @@ function convert_chars($content, $deprecated = '') { * @return string Balanced text */ function balanceTags( $text, $force = false ) { - if ( $force || get_option('use_balanceTags') == 1 ) - return force_balance_tags( $text ); - else - return $text; + if ( $force || get_option('use_balanceTags') == 1 ) { + $balance_tags_delimiters = apply_filters( 'balance_tags_delimiters', array( '', '' ) ); + // Capture lets PREG_SPLIT_DELIM_CAPTURE return the delimiters + $delimiters_regex = '/(' . implode( '|', $balance_tags_delimiters ) . ')/'; + $parts = preg_split( $delimiters_regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); + return implode( '', array_map( 'force_balance_tags', $parts ) ); + } + + return $text; } /**