• So I’m creating a post: “Cruisin’ The Coast ??” and the automatic system wants to include the car as part of the permalink. I don’t want that so I have to edit the actual link itself to be rid of it. Is there a setting which restricts the permalink to alphanumeric only somewhere that I don’t know about?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    You must be using the classic editor? The emoji gets dropped when using the block editor. After establishing the title you could switch back to the classic editor. There’s a setting in the classic editor plugin that lets one choose their editor. But there is no explicit WP setting for no emoticons in permalinks.

    It is possible to hook the “sanitize_title” filter and add a callback that strips out any UTF-8 characters over a certain value. For basic Latin chars we don’t need anything encoded over hex7F. The first byte of emojis is hexF0 or greater, followed by 3 more bytes. You can learn more about UTF-8 encoding from Wikipedia and other sites.

    Thread Starter Colin Glenn

    (@colinglenn)

    I was using the classic editor because the block editor inhales large amounts of bilge water in terms of usability. And needing to jump back and forth between one editor to another is a colossal pain in the posterior portions of the anatomy.

    https://wtixfm.com/gretna-fest-2023-%f0%9f%a5%b3/

    That is the link produced from using the block editor so there is no change in how the URL gets created.

    Moderator bcworkz

    (@bcworkz)

    You sir have an entertaining way with words X-D

    Then use the “sanitize_title” filter and search the passed title for '-%f'. If found, remove it and the following 10 characters. All emojis start with %f and are always the same encoding length. There are some non-emojis that also start with %f but you likely don’t want those in your slugs either.

    Thread Starter Colin Glenn

    (@colinglenn)

    Used to work on the riverfront, had to learn how to unswear, …

    That aside, just where on the front end do I find this function? The only reference I find for it is in the developers reference guide.

    Moderator bcworkz

    (@bcworkz)

    It’s not literally a function you want, it’s a filter hook which allows you to alter data before it gets saved. Thus it’s not even a front end thing at all. It’s a back end thing. FWIW, a filter hook is related to a function, so your query isn’t that far off.

    sanitize_title doc page (which you’ve probably already found)

    More on filter hooks in general if you need such info.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable Permalink Inclusion Of Emoticons’ is closed to new replies.