Skip to content

Instantly share code, notes, and snippets.

@anythinggraphic
Last active January 29, 2017 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anythinggraphic/31ec0bcefba3b94cb6e6a8a8173da09d to your computer and use it in GitHub Desktop.
Save anythinggraphic/31ec0bcefba3b94cb6e6a8a8173da09d to your computer and use it in GitHub Desktop.
Remove WordPress emojis without a plugin.
<?php
/* @link https://anythinggraphic.net/disable-emojis-in-wordpress-without-a-plugin
/* Remove emoji scripts and dns prefetch
----------------------------------------------------------------------------------------*/
add_action( 'init', 'ag_disable_wp_emojicons' );
function ag_disable_wp_emojicons() {
// all actions related to emojis
remove_action( 'admin_print_styles', 'print_emoji_styles' );
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_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
// filter to remove TinyMCE emojis, below
add_filter( 'tiny_mce_plugins', 'ag_disable_emojicons_tinymce' );
}
function ag_disable_emojicons_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
// Lastly, remove the DNS Prefetch
add_filter( 'emoji_svg_url', '__return_false' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment