Turn off WordPress Emoji

Last Revised: October 2, 2021

WordPress has been integrating Emoji for many versions, turning icons from text to image. But this system involves some version detection problems that, if you do not use them in your texts, it does not make much sense to leave active. To deactivate them you can apply:

<?php
/**
 * Remove emoji support
 *
 * @link https://wordpress.org/support/article/using-smilies/
 */
add_action(
  'init',
  function () {

    // Front-end
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
    remove_action( 'wp_print_styles', 'print_emoji_styles' );

    // Admin
    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    remove_action( 'admin_print_styles', 'print_emoji_styles' );

    // Feeds
    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );

    // Embeds
    remove_filter( 'embed_head', 'print_emoji_detection_script' );

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

    // Disable from TinyMCE editor. Disabled in block editor by default
    add_filter(
      'tiny_mce_plugins',
      function ( $plugins ) {
        if ( is_array( $plugins ) ) {
          $plugins = array_diff( $plugins, array( 'wpemoji' ) );
        }
        return $plugins;
      }
    );

    /**
     * Finally, disable it from the database also, to prevent characters from converting
     *  There used to be a setting under Writings to do this
     *  Not ideal to get & update it here - but it works :/
     */
    if ( (int) get_option( 'use_smilies' ) === 1 ) {
      update_option( 'use_smilies', 0 );
    }

  }
);

Seguir con Seguridad para WordPress


About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.