Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function wptexturize( $text, $reset = false ) {
);
}

$static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney );
$static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
$static_characters = array( '...', '``', '\'\'', ' (tm)' );
$static_replacements = array( '…', $opening_quote, $closing_quote, ' ™' );

/*
* Pattern-based replacements of characters.
Expand All @@ -153,6 +153,10 @@ function wptexturize( $text, $reset = false ) {
$dynamic = array();
$spaces = wp_spaces_regexp();

foreach ( $cockney as $i => $word ) {
$dynamic[ '/(?<!\w)' . preg_quote( $word, '/' ) . '(?!\w)/' ] = $cockneyreplace[ $i ];
}

// '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 ) {
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote;
Expand Down
28 changes: 28 additions & 0 deletions tests/phpunit/tests/formatting/wpTexturize.php
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,34 @@ public function test_cockney( string $input, string $output ): void {
*/
public static function data_cockney(): array {
return array(
array(
"word 'emulate' word",
'word &#8216;emulate&#8217; word',
),
array(
"word 'emergency' word",
'word &#8216;emergency&#8217; word',
),
array(
"word 'tissue' word",
'word &#8216;tissue&#8217; word',
),
array(
"word 'roundtable' word",
'word &#8216;roundtable&#8217; word',
),
array(
"word 'causes' word",
'word &#8216;causes&#8217; word',
),
array(
"word 'tilt' word",
'word &#8216;tilt&#8217; word',
),
array(
"word 'bouts' word",
'word &#8216;bouts&#8217; word',
),
array(
"word 'tain't word",
'word &#8217;tain&#8217;t word',
Expand Down
Loading