Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggreagtion Enquires Welcome

Disable Emoji in WordPress

WordPress has supported Emoji since version 4.2. The following function will disable Emoji for those that sensibly want nothing to do with them. Interestingly, Emoji support was released as a "trojan horse" to address a critical (database) security vulnerability. If interested in the back-story, check out this video from WordPress developer Andrew Nacin.

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
    Disable Emoji in WordPress
4
    http://www.beliefmedia.com/code/wp-snippets/disable-emoji-wordpress
5
*/
6
 
7
 
8
function beliefmedia_disable_emoji() {
9
  remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
10
  remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
11
  remove_action( 'wp_print_styles', 'print_emoji_styles' );
12
  remove_action( 'admin_print_styles', 'print_emoji_styles' );    
13
  remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
14
  remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );    
15
  remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
16
  add_filter( 'tiny_mce_plugins', 'beliefmedia_disable_tinymce_emoji' );
17
}
18
add_action('init', 'beliefmedia_disable_emoji', 1);
19
 
20
 
21
/* filter function used to remove the tinymce emoji plugin */
22
function beliefmedia_disable_tinymce_emoji( $plugins ) {
23
  return array_diff( $plugins, array( 'wpemoji' ) );
24
}

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment