Advertisement
fauzanjeg

Disable Feed and Remove wp-emoji-release.min.js

Jan 4th, 2021 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. /**
  2.  * Disable the RSS/Feed
  3.  * Redirect to the homepage all users trying to access feeds.
  4.  */
  5. function disable_feeds() {
  6.     wp_redirect( home_url() );
  7.     die;
  8. }
  9.  
  10. // Disable global RSS, RDF & Atom feeds.
  11. add_action( 'do_feed',      'disable_feeds', -1 );
  12. add_action( 'do_feed_rdf',  'disable_feeds', -1 );
  13. add_action( 'do_feed_rss',  'disable_feeds', -1 );
  14. add_action( 'do_feed_rss2', 'disable_feeds', -1 );
  15. add_action( 'do_feed_atom', 'disable_feeds', -1 );
  16.  
  17. // Disable comment feeds.
  18. add_action( 'do_feed_rss2_comments', 'disable_feeds', -1 );
  19. add_action( 'do_feed_atom_comments', 'disable_feeds', -1 );
  20.  
  21. // Prevent feed links from being inserted in the <head> of the page.
  22. add_action( 'feed_links_show_posts_feed',    '__return_false', -1 );
  23. add_action( 'feed_links_show_comments_feed', '__return_false', -1 );
  24. remove_action( 'wp_head', 'feed_links',       2 );
  25. remove_action( 'wp_head', 'feed_links_extra', 3 );
  26.  
  27. /**
  28.  * Disable the emoji's
  29.  */
  30. function disable_emoji_feature() {
  31.    
  32.     // Prevent Emoji from loading on the front-end
  33.     remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  34.     remove_action( 'wp_print_styles', 'print_emoji_styles' );
  35.  
  36.     // Remove from admin area also
  37.     remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  38.     remove_action( 'admin_print_styles', 'print_emoji_styles' );
  39.  
  40.     // Remove from RSS feeds also
  41.     remove_filter( 'the_content_feed', 'wp_staticize_emoji');
  42.     remove_filter( 'comment_text_rss', 'wp_staticize_emoji');
  43.  
  44.     // Remove from Embeds
  45.     remove_filter( 'embed_head', 'print_emoji_detection_script' );
  46.  
  47.     // Remove from emails
  48.     remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  49.  
  50.     // Disable from TinyMCE editor. Currently disabled in block editor by default
  51.     add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
  52.  
  53.     /** Finally, prevent character conversion too
  54.          ** without this, emojis still work
  55.          ** if it is available on the user's device
  56.      */
  57.  
  58.     add_filter( 'option_use_smilies', '__return_false' );
  59.  
  60. }
  61.  
  62. function disable_emojis_tinymce( $plugins ) {
  63.     if( is_array($plugins) ) {
  64.         $plugins = array_diff( $plugins, array( 'wpemoji' ) );
  65.     }
  66.     return $plugins;
  67. }
  68.  
  69. add_action('init', 'disable_emoji_feature');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement