diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 4f28e745751ff..dd7d7861d17e0 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2294,10 +2294,10 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa $title = strtolower( $title ); if ( 'save' === $context ) { - // Convert  , &ndash, and &mdash to hyphens. - $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); - // Convert  , &ndash, and &mdash HTML entities to hyphens. - $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title ); + // Convert  , non-breaking hyphen, &ndash, and &mdash to hyphens. + $title = str_replace( array( '%c2%a0', '%e2%80%91', '%e2%80%93', '%e2%80%94' ), '-', $title ); + // Convert  , non-breaking hyphen, &ndash, and &mdash HTML entities to hyphens. + $title = str_replace( array( ' ', '‑', ' ', '–', '–', '—', '—' ), '-', $title ); // Convert forward slash to hyphen. $title = str_replace( '/', '-', $title ); diff --git a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php index 5c7a81cb2974f..8a2ee4f9d9fee 100644 --- a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php +++ b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php @@ -85,6 +85,20 @@ public function test_replaces_ndash_mdash_entities() { $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); } + /** + * @ticket 64089 + */ + public function test_replaces_non_breaking_hyphen() { + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do‑the Dash', '', 'save' ) ); + } + + /** + * @ticket 64089 + */ + public function test_replaces_non_breaking_hyphen_entity() { + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do ‑ the Dash', '', 'save' ) ); + } + public function test_replaces_iexcel_iquest() { $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) );