Wordpress - Disable emojicons introduced with WP 4.2
We will hook into init
and remove actions as followed:
function 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
add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
}
add_action( 'init', 'disable_wp_emojicons' );
We will need the following filter function to disable TinyMCE emojicons:
function disable_emojicons_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
Now we breathe and pretend this feature was never added to core... particularly while tons of resolved bugs are yet to be implemented.
This is available as a plugin, Disable Emojis.
Alternatively, you can replace the smilies with the original versions from previous versions of WordPress using Classic Smilies.
Update
We can also remove the DNS prefetch by returning false on filter emoji_svg_url
(thanks @yobddigi):
add_filter( 'emoji_svg_url', '__return_false' );
Better solution if you want to disable this: use a plugin.
Same code as from Christine's comments: https://wordpress.org/plugins/disable-emojis/
Same code that also fixes the smilies to be the older ones: https://wordpress.org/plugins/classic-smilies/
Source: Me, since I wrote that code in the first place. https://plugins.trac.wordpress.org/changeset/1142480/classic-smilies
This is the simple way to remove emoji. Add bellow code to your function.php
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );