Skip to content

Commit 7c52413

Browse files
committed
Revert "Refactor replacement of dashes to hyphens"
This reverts commit ff2d2a7.
1 parent ff2d2a7 commit 7c52413

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

src/wp-includes/formatting.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,42 +2294,12 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
22942294
$title = strtolower( $title );
22952295

22962296
if ( 'save' === $context ) {
2297-
// Mapping of Unicode hex codepoint to HTML named entity (if it exists).
2298-
$dash_characters = array(
2299-
// Non-breaking space (U+00A0).
2300-
'A0' => 'nbsp',
2301-
2302-
// Non-breaking hyphen (U+2011).
2303-
'2011' => null,
2304-
2305-
// En dash (U+2013).
2306-
'2013' => 'ndash',
2307-
2308-
// Em dash (U+2014).
2309-
'2014' => 'mdash',
2310-
);
2311-
2312-
// Convert dashes to hyphens.
2313-
$replacements = array();
2314-
foreach ( $dash_characters as $hex_codepoint => $named_entity ) {
2315-
// HTML entities.
2316-
$replacements[] = '&#x' . $hex_codepoint . ';';
2317-
if ( $named_entity ) {
2318-
$replacements[] = '&' . $named_entity . ';';
2319-
}
2320-
$decimal_codepoint = hexdec( $hex_codepoint );
2321-
$replacements[] = '&#' . $decimal_codepoint . ';';
2322-
2323-
// URL-encoded characters.
2324-
if ( function_exists( 'mb_chr' ) ) {
2325-
$replacements[] = rawurlencode( mb_chr( $decimal_codepoint, 'UTF-8' ) );
2326-
}
2327-
}
2328-
2297+
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash to hyphens.
2298+
$title = str_replace( array( '%c2%a0', '%e2%80%91', '%e2%80%93', '%e2%80%94' ), '-', $title );
2299+
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash HTML entities to hyphens.
2300+
$title = str_replace( array( ' ', '‑', ' ', '–', '–', '—', '—' ), '-', $title );
23292301
// Convert forward slash to hyphen.
2330-
$replacements[] = '/';
2331-
2332-
$title = str_ireplace( $replacements, '-', $title );
2302+
$title = str_replace( '/', '-', $title );
23332303

23342304
// Strip these characters entirely.
23352305
$title = str_replace(

0 commit comments

Comments
 (0)