digital-workshop

Disable Emojis

Sep 11th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. /**
  2.  * Disable the emoji's
  3.  */
  4. function disable_emojis() {
  5.  remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  6.  remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  7.  remove_action( 'wp_print_styles', 'print_emoji_styles' );
  8.  remove_action( 'admin_print_styles', 'print_emoji_styles' );
  9.  remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  10.  remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  11.  remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  12.  add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
  13.  add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
  14. }
  15. add_action( 'init', 'disable_emojis' );
  16.  
  17. /**
  18.  * Filter function used to remove the tinymce emoji plugin.
  19.  *
  20.  * @param array $plugins
  21.  * @return array Difference betwen the two arrays
  22.  */
  23. function disable_emojis_tinymce( $plugins ) {
  24.  if ( is_array( $plugins ) ) {
  25.  return array_diff( $plugins, array( 'wpemoji' ) );
  26.  } else {
  27.  return array();
  28.  }
  29. }
  30.  
  31. /**
  32.  * Remove emoji CDN hostname from DNS prefetching hints.
  33.  *
  34.  * @param array $urls URLs to print for resource hints.
  35.  * @param string $relation_type The relation type the URLs are printed for.
  36.  * @return array Difference betwen the two arrays.
  37.  */
  38. function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
  39.  if ( 'dns-prefetch' == $relation_type ) {
  40.  /** This filter is documented in wp-includes/formatting.php */
  41.  $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
  42.  
  43. $urls = array_diff( $urls, array( $emoji_svg_url ) );
  44.  }
  45.  
  46. return $urls;
  47. }
Add Comment
Please, Sign In to add comment