Disable Emojicons on your WordPress site

a minute read

Since version 4.2 release, WordPress now allows you to add the cool new Emojicons to your posts. In case you don’t know what emojicons are: they are the successor of Emoticons or smilies with more better graphics, and web platforms are quickly adopting them.

It was very easy to opt-out from using emoticons from the WordPress Writing Settings. As emojicons are succeeding emoticons, you can turn them off but this way you just can’t get rid of them completely:

Disabling WordPress emoticons
Emojicons can be turned off but they still add the code responsible for their styling and rendering.

But that is not enough. You still have the emojicons styles and JavaScript auto-enqueued in the header of your theme, which is unnecessary after you opted into not using emojicons.

Extra code added by WordPress emojicons
The extra bit of code added by WordPress emojicons—becomes useless when you don’t want

Removing WordPress Emojicons CSS and JS

As usual, WordPress (4.2+) hooks in some functions to implement the emojicons. In order to disable them, we need to unhook those functions with the help of some code.

Below given code snippet helps you to get rid of those extra bits of emojicon-specific CSS and JS from your WordPress themes. Remove the lines which don’t fit in your requirement:

function flush_emojicons() {
    // Remove from comment feed and RSS
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );

    // Remove from Emails
    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );

    // Remove from the head, i.e. wp_head()
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );

    // Remove from Print-related CSS
    remove_action( 'wp_print_styles', 'print_emoji_styles' );

    // Remove from Admin area
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );
}
add_action( 'init', 'flush_emojicons' );

Hope you found it useful. Cheers!

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

There are times when you need to disable comments on your WordPress site. There are two cases contextual to disabling WordPress comments: Disabling comments for individual posts and pages Disabling comments completely Disabling comments for individual WordPr...
Jetpack is a popular WordPress plugin developed by Automattic, the same company behind WordPress.com. It offers various features and tools to enhance the functionality and performance of a WordPress website. However, there might be instances where you want to ...
To deploy a Gatsby site to a WordPress sub-directory, follow these steps:Build your Gatsby site: Use the Gatsby CLI to generate a production-ready version of your site. Run the gatsby build command in your project's root directory. This will create a publi...