Advertisement
Guest User

WP - DISABLE EMOJI & DEFER ALL JS

a guest
Apr 26th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 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. }
  14. add_action( 'init', 'disable_emojis' );
  15.  
  16. /**
  17.  * Filter function used to remove the tinymce emoji plugin.
  18.  *
  19.  * @param    array  $plugins  
  20.  * @return   array             Difference betwen the two arrays
  21.  */
  22. function disable_emojis_tinymce( $plugins ) {
  23.     if ( is_array( $plugins ) ) {
  24.         return array_diff( $plugins, array( 'wpemoji' ) );
  25.     } else {
  26.         return array();
  27.     }
  28. }
  29.  
  30. if ( ! is_admin() ) {
  31. function defer_parsing_of_js ( $url ) {
  32. if ( FALSE === strpos( $url, '.js' ) ) return $url;
  33. if ( strpos( $url, 'jquery.js' ) ) return $url;
  34. return "$url' defer ";
  35. }
  36. add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement