diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index b4cbbcf8e9..4afb487a07 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -96,11 +96,13 @@ function wptexturize($text, $reset = false) { $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); - $spaces = wp_spaces_regexp(); - // Pattern-based replacements of characters. + // Sort the remaining patterns into several arrays for performance tuning. + $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); + $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); $dynamic = array(); + $spaces = wp_spaces_regexp(); // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. if ( "'" !== $apos || "'" !== $closing_single_quote ) { @@ -115,10 +117,7 @@ function wptexturize($text, $reset = false) { $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos; } - // Quoted Numbers like "42" or '42.00' - if ( '"' !== $opening_quote && '"' !== $closing_quote ) { - $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; - } + // Quoted Numbers like '0.42' if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote; } @@ -133,16 +132,30 @@ function wptexturize($text, $reset = false) { $dynamic[ '/(?