Remove emoji support in WordPress

WordPress 4.2 introduced a new emoji feature which many were quick to criticise, partly because large parts of the WordPress user community simply didn’t want emoji support, but from what I can gather from forum threads like this, the ugly code it left behind was just not necessary, especially as a core feature that can’t be disabled through the CMS. Don’t worry it can be removed easily.

Remove WordPress emoji support script

The WordPress emoji support script is ugly, really ugly.

Removing the emoji scripts in WordPress

There are four actions we need to remove, one is a front-end detection script, one is an admin detection script, and two stylesheets; one front end the other admin.

remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script'); 
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');

This will completely remove emoji support from your WordPress theme. Just add these into your functions.php file and you’re done.

Emoji support class

If like me you prefer to use classes instead of procedural based code in your WordPress projects.

Create your class, in this example I’m calling it EmojiSupportRemoval.php:

<?php

class EmojiSupportRemoval
{
    /**
     * EmojiSupportRemoval constructor.
     */
    public function __construct()
    {
        $this->removeFrontendSupport();
        $this->removeAdminSupport();
    }

    /**
     * Removes theme front-end support.
     */
    private function removeFrontendSupport()
    {
        remove_action('wp_head', 'print_emoji_detection_script', 7);
        remove_action('wp_print_styles', 'print_emoji_styles');
    }

    /**
     * Removes theme admin support.
     */
    private function removeAdminSupport()
    {
        remove_action('admin_print_scripts', 'print_emoji_detection_script');
        remove_action('admin_print_styles', 'print_emoji_styles');
    }
}

Then in your functions.php file:

require EmojiSupportRemoval.php; // You don't need this if you're autoloading the class.
new EmojiSupportRemoval();

That’s it. Feel free to feed back.

Ste

Web Developer living in Manchester, working for Studio Skylab (http://www.studioskylab.com). Views and thoughts are my own.

You may also like...

3 Responses

  1. Leo Sammarco says:

    Great article, love the OOP approach unlike most other articles available on the web. Worked first time.

  2. Rachen says:

    Hi what is OOP means? It’s better function than the plugin??

    https://wordpress.org/plugins/disable-emojis-littlebizzy/

    • Ste says:

      Hi Rachen. OOP is ‘Object Oriented Programming’, it’s containing functional code within a class. It makes code very readable, testable and reusable among other things

Leave a Reply