hp-cleaner.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /*************************************************
  3. // ######### cleanup migration ################ //
  4. **************************************************/
  5. define('TRIBE_DISABLE_TOOLBAR_ITEMS', true);
  6. function srh_admin_bar_render() {
  7. global $wp_admin_bar;
  8. $wp_admin_bar->remove_menu('comments');
  9. $wp_admin_bar->remove_menu('customize');
  10. $wp_admin_bar->remove_menu('new-content');
  11. $wp_admin_bar->remove_menu('wp-logo');
  12. }
  13. add_action( 'wp_before_admin_bar_render', 'srh_admin_bar_render' );
  14. function hp_remove_admin_menus() {
  15. remove_menu_page( 'edit-comments.php' );
  16. }
  17. add_action( 'admin_menu', 'hp_remove_admin_menus' );
  18. function remove_comment_support() {
  19. remove_post_type_support( 'post', 'comments' );
  20. remove_post_type_support( 'page', 'comments' );
  21. }
  22. add_action('init', 'remove_comment_support', 100);
  23. function filter_media_comment_status( $open, $post_id ) {
  24. $post = get_post( $post_id );
  25. if( $post->post_type == 'attachment' ) {
  26. return false;
  27. }
  28. return $open;
  29. }
  30. add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
  31. function remove_default_img_sizes( $sizes ) {
  32. $targets = ['medium_large', 'large', '1536x1536', '2048x2048'];
  33. foreach($sizes as $size_index=>$size) {
  34. if(in_array($size, $targets)) {
  35. unset($sizes[$size_index]);
  36. }
  37. }
  38. return $sizes;
  39. }
  40. add_filter( 'intermediate_image_sizes', 'remove_default_img_sizes', 10, 1);
  41. /*************************************************
  42. // ############### wp_head ################## //
  43. **************************************************/
  44. remove_action('wp_head', 'index_rel_link' );
  45. remove_action('wp_head', 'rel_canonical');
  46. remove_action('wp_head', 'start_post_rel_link', 10);
  47. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);
  48. remove_action('wp_head', 'wp_shortlink_wp_head', 10);
  49. remove_action('wp_head', 'parent_post_rel_link', 10);
  50. remove_action('wp_head', 'rsd_link');
  51. remove_action('wp_head', 'wlwmanifest_link');
  52. remove_action('wp_head', 'wp_generator');
  53. remove_action('wp_head', 'feed_links_extra', 3 );
  54. remove_action('wp_head', 'feed_links', 2 );
  55. remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
  56. remove_action('wp_head', 'wp_oembed_add_host_js', 10);
  57. remove_action('wp_head', 'rest_output_link_wp_head', 10);
  58. remove_action('template_redirect', 'rest_output_link_header', 11, 0);
  59. function gw_remove_wp_ver_css_js( $src ) {
  60. if ( strpos( $src, 'ver=' ) )
  61. $src = remove_query_arg( 'ver', $src );
  62. return $src;
  63. }
  64. add_filter( 'style_loader_src', 'gw_remove_wp_ver_css_js', 9999 );
  65. add_filter( 'script_loader_src', 'gw_remove_wp_ver_css_js', 9999 );
  66. add_filter( 'xmlrpc_enabled', '__return_false' );
  67. add_filter( 'wp_headers', 'gw_disable_x_pingback' );
  68. function gw_disable_x_pingback( $headers ) {
  69. unset( $headers['X-Pingback'] );
  70. return $headers;
  71. }
  72. /*************************************************
  73. // ############### Emojis ################## //
  74. **************************************************/
  75. function gw_disable_emojis() {
  76. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  77. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  78. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  79. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  80. remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  81. remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  82. remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  83. //add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
  84. add_filter( 'emoji_svg_url', '__return_false' );
  85. }
  86. add_action( 'init', 'gw_disable_emojis' );