Check if emojis is disabled

How can check if the emoji is disabled on the site or not?

I have searched for an official function but I haven’t found anything officially, We are creating a theme and will publish it soon and need to check if the customer has disabled the emojis by adding any function or by any another way.

1 Answer
1

To completely remove emojis this is the code:

    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' );

So to check if any of those are active you could use has_action() like this:

    $emoji_script front = has_action( 'wp_head', 'print_emoji_detection_script' );
    if( $emoji_script_front ) {
      // The emoji script is loaded on the front end
    } 

You could do different things for each of the actions. has_action does not care about priority, and this should work in the functions.php file since it runs later than all of those actions.

More about has_action() on WordPress.org

Leave a Comment