OMG EMOJI ๐Ÿ˜Ž

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 HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers.-encoded equivalent, and store that, instead. From a UIUI 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 UXUX User experience. If you notice a little chunk of compressed JSJS 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 pluginPlugin 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 URLURL 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