How to disable emojis in WordPress

Last updated December 6th, 2023 06:04

Emojis were first introduced in WordPress version 4.2. They are small images designed to convey the writer’s current emotions in a post. Sadness, joy, happiness, or tears… However, by displaying emojis, WordPress unnecessarily loads additional CSS styles and JavaScripts. Therefore, for a website where there is no need for this functionality, we can easily turn off emojis and save time in loading the website. Emojis can be disabled just like almost anything in WordPress using a plugin. But it can also be done without one. And since I don’t like using plugins to solve any “problem” in WordPress, today we’ll show you both ways. So if you’re wondering how to disable emojis in WordPress, this article and its content are just for you.

How to disable emojis in WordPress with code

As I mentioned earlier, I’m not a big fan of solving WordPress problems using plugins. It leads to a general belief that there is no other way to do it. The results are often visible across the internet – websites that use 25 or more plugins at their bare minimum. It’s good to find solutions that don’t involve using a plugin, as it saves hosting memory on which you operate your WordPress.

To turn off emojis using code without risking damaging your website, you will need one plugin. However, you will use this plugin practically whenever you need to insert any code into your website safely. Therefore, it can be said that with this plugin, you can later solve more problems and get rid of the need to have four plugins instead of one.

Instalation WPCode

In the left menu, go to the “Plugins” section and move to the plugin installation. Enter the phrase “WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager” in the search using keywords. The direct link to the plugin is here: WPCode. Install and activate the plugin.

How to disable emojis in WordPress

Once you activate the plugin, a new item called “Code Snippets” will appear in the left menu. Click on it, and in its submenu, select the item named the same, i.e., “Code Snippets” again. Click the “Add New” button to add new code to insert into your website. Then select the “Add Your Custom Code (New Snippet)” option. Choose “PHP snippet” as the “Code Type“.

Insert the following code into the new PHP snippet. Leave the “Insertion” and “Device type” settings as they are, i.e., “Auto insert” and “Any device type“. Then click “Save snippet“.

				
					/**
 * Disable the emoji's
 */
function disable_emojis() {
 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_action( 'admin_print_styles', 'print_emoji_styles' ); 
 remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 
 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
 add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
 add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_emojis' );
 
/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param array $plugins 
 * @return array Difference betwen the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 return array();
 }
}
 
/**
 * Remove emoji CDN hostname from DNS prefetching hints.
 *
 * @param array $urls URLs to print for resource hints.
 * @param string $relation_type The relation type the URLs are printed for.
 * @return array Difference between the two arrays.
 */
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
 if ( 'dns-prefetch' == $relation_type ) {
 /** This filter is documented in wp-includes/formatting.php */
 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
 
$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }
 
return $urls;
}
				
			

And that’s all you need to do to disable emojis. As mentioned earlier, this plugin will come in handy for solving multiple issues as it can solve many functionalities by adding snippets.

How to Disable Emojis in WordPress using a Plugin

This part will be considerably easier. Like everything else, you can also disable emojis using a plugin. However, I would only recommend this to people who have a panic fear of PHP code and are genuinely afraid of snippets for some reason. Nevertheless, I don’t think this part will be of much concern to WordPress users who don’t want emojis. But let’s be complete and say that this is also an option. Our plugin is called “Disable Emojis (GDPR friendly)” and you can install it the same way as the snippet plugin mentioned above. The official page for downloading is here: Disable Emojis (GDPR friendly). The plugin does not require any configuration, so there is no need to specify anything further in the instructions. Just install it, and you can say goodbye to emojis.

Conclusion

As you can see, getting rid of emojis is not really that difficult. You now know how to disable emojis in WordPress. This action will take up to five minutes of your time.

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Nejstarší
Nejnovější Nejvíce hlasováno
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje