WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 5 months ago

#35498 closed enhancement (maybelater)

Add a filter to enable twemoji all the time

Reported by: iseulde Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Emoji Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

Regardless of browser support.

Change History (6)

#1 @iseulde
4 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

#2 @peterwilsoncc
4 years ago

Such a filter could be used for disabling too, and return force_enable, disable (with the alias force_disable) or, the default, detect.

#3 @iseulde
4 years ago

Sure. The reason I want this is because I want my content to be the same regardless of the browser. Also then you don't need this chunk of inline JS in the head. But an easy way to disable would also be good! Not sure if there is right now.

#4 @voldemortensen
4 years ago

The simplest way I know of to disable currently is with this.


/**
 * 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_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();
        }
}

Taken from the disable-emojis plugin on the repo.

#5 @swissspidy
3 years ago

  • Component changed from General to Emoji

#6 @pento
5 months ago

  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from new to closed

This can be done fairly easily without needing a special filter for it: remove the print_emoji_detection_script action, then load the wp-includes/js/wp-emoji-release.min.js file.

I'm going to close this ticket as maybelater: if there are additional difficulties which require a core solution, we can reopen it.

Note: See TracTickets for help on using tickets.