diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 75ca351c20..0cd9e5c6a6 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -131,7 +131,6 @@ add_filter( 'the_title', 'trim' ); add_filter( 'the_content', 'wptexturize' ); add_filter( 'the_content', 'convert_smilies' ); -add_filter( 'the_content', 'convert_chars' ); add_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'shortcode_unautop' ); add_filter( 'the_content', 'prepend_attachment' ); diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index abbb090612..e0b45fd0a3 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -276,12 +276,13 @@ function wptexturize( $text, $reset = false ) { // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); } + + // Replace each & with & unless it already looks like an entity. + $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); } } - $text = implode( '', $textarr ); - // Replace each & with & unless it already looks like an entity. - return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text ); + return implode( '', $textarr ); } /** diff --git a/tests/phpunit/tests/formatting/WPTexturize.php b/tests/phpunit/tests/formatting/WPTexturize.php index f4b8ef6d67..475a4755fc 100644 --- a/tests/phpunit/tests/formatting/WPTexturize.php +++ b/tests/phpunit/tests/formatting/WPTexturize.php @@ -1267,12 +1267,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { '[caption – is it wise to maybe ]', ), array( - '[ photos by this guy ]', - '[ photos by this guy ]', + '[ photos by this guy & that guy ]', + '[ photos by this guy & that guy ]', ), array( - '[photos by this guy ]', - '[photos by this guy ]', + '[photos by this guy & that guy ]', + '[photos by this guy & that guy ]', ), array( '[gallery ...]',