One of the fun bits of the utf8mb4 upgrade is that we can now store emoji! Once your site is upgraded to utf8mb4, it can natively store any emoji character. There wereย a couple of problems with that, though:
- Some browsers donโt know how to render emoji ๐, or they have bugs in their implementation ๐ข. Notably, Chrome either doesnโt work or has bugs, older versions of IE donโt work, and Firefox has bugs.
- Not all sites will be able to upgrade to utf8mb4, which means theyโll be unable to save emoji characters that they enter.
Not being able to use emoji makes everyone a sad panda (๐ญ๐ผ), so we need to fix this. There are a few moving parts of our emoji support, so lets go through them.
utf8 backwards compatibility
If a site canโt be upgraded to utf8mb4, we convert emoji to their HTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers.-encoded equivalent, and store that, instead. From a UI User interface perspective, post editing works as expected ๐. Because fields need to be white listed to support this, we donโt allow it everywhere โ just post_title, post_content and post_excerpt. We also allow it in the site title and the site description.
Browser support
Thereโs a small compatibility check included on every page, both on the front end, and in the Dashboard. For those interested, this adds 1-4ms (โก๏ธ-fast!) to the page render time โ the aim was to keep this as low as possible, to avoid affecting your UX User experience. If you notice a little chunk of compressed JS JavaScript, a web scripting language typically executed in the browser. Often used for advanced user interfaces and behaviors. at the top your HTML, thatโs probably it. If youโd like to check out how it works in a more readable format, have a look through wp-emoji-loader.js.
Email โ๏ธ and RSS ๐ฏ (Thereโs no RSS emoji, give me a break.)
Of course, the JS shim wonโt work in email and RSS. So, we replace all emoji with a static PNG version in those cases.
TinyMCE ๐
In addition to the browser support JS, thereโs a TinyMCE plugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party that handles keeping emoji looking good, while you type. Itโs pretty magical.
Taxonomies and URL A specific web address of a website or web page on the Internet, such as a websiteโs URL www.wordpress.org slugs
You can totally make taxonomies and URL slugs with emoji in them. Because we love you, and want you to be happy. ๐
โ
So, thatโs about it. If you have any questions about the implementation, drop them in the comments below.
๐ฉ
#4-2, #dev-notes, #%f0%9f%91%bb, #emoji