Forums

[resolved] Slug includes non-ASCII characters (3 posts)

  1. ericr23
    Member
    Posted 2 years ago #

    I've noticed that extended ASCII characters are preserved in the title slug, thus creating very unattractive permalinks when they are escaped.

    For example, if I enter the title:

    “Testing” — ‘the test’ [that's an em-dash and all quotes are curly]

    the slug is saved as:

    “testing”-—-‘the-test’ [em-dash and curly quotes preserved]

    It should be:

    testing-the-test

    How can I fix this?

  2. ericr23
    Member
    Posted 2 years ago #

    By the way,

    "Testing" - 'the test' [straight quotes and a hyphen]

    is correctly slugged as

    testing-the-test

  3. ericr23
    Member
    Posted 2 years ago #

    I added these 2 lines to the START of the sanitize_title_with_dashes function in wp-include/formatting.php:

    $title = preg_replace('/[“”‘’]/', '', $title); //delete curly quotes
    $title = preg_replace('/[–—]/', '-', $title); //en- and em-dash to hyphen

Topic Closed

This topic has been closed to new replies.

About this Topic