How to Disable Emoticons in WordPress

0

Emoticons introduced in WordPress 4.2 version, to check out the actions and filters code used, open this file /wp-includes/default-filters.php and search for emoji. If you want to remove or disable emoji code, Then you will have to go through each of these and remove them in your own code by using the functions remove_filter and remove_action.

WordPress 4.2 version added emoticons, which are really unnecessary if you are not using the emojis or cool smilies. Moreover, these Emojicons will slow down your WordPress page speed by adding the JavaScript to your every page and post. By default emoticons, CSS and JavaScript enqueued in the header of your WordPress theme, which is unnecessary when you are not using emoticons.

function pw_remove_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 head tag
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );

    // Remove from print related styling
    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', 'pw_remove_emojicons' );

Alternately, you can use Disable Emojis WordPress plugin to completely remove/disable emojis. This plugin disables the new emoji functionality in WordPress.

Leave A Reply

Your email address will not be published.