cidus

remover códigos desnecessáriosdo HTML

Apr 2nd, 2018
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. /**
  2. * Odin optimize functions.
  3. */
  4. /**
  5. * Cleanup wp_head().
  6. */
  7. function odin_head_cleanup() {
  8. // Category feeds.
  9. remove_action( 'wp_head', 'feed_links_extra', 3 );
  10. // Post and comment feeds.
  11. remove_action( 'wp_head', 'feed_links', 2 );
  12. // EditURI link.
  13. remove_action( 'wp_head', 'rsd_link' );
  14. // Windows live writer.
  15. remove_action( 'wp_head', 'wlwmanifest_link' );
  16. // Index link.
  17. remove_action( 'wp_head', 'index_rel_link' );
  18. // Previous link.
  19. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
  20. // Start link.
  21. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
  22. // Links for adjacent posts.
  23. remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
  24. // WP version.
  25. remove_action( 'wp_head', 'wp_generator' );
  26. // Emoji's
  27. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  28. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  29. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  30. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  31. remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  32. remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  33. remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  34. }
  35. add_action( 'init', 'odin_head_cleanup' );
  36. /**[] [/]
  37. * Remove WP version from RSS.
  38. */
  39. add_filter( 'the_generator', '__return_false' );
  40. /**
  41. * Remove injected CSS for recent comments widget.
  42. */
  43. function odin_remove_wp_widget_recent_comments_style() {
  44. if ( has_filter( 'wp_head', 'wp_widget_recent_comments_style' ) ) {
  45. remove_filter( 'wp_head', 'wp_widget_recent_comments_style' );
  46. }
  47. }
  48. add_filter( 'wp_head', 'odin_remove_wp_widget_recent_comments_style', 1);
  49. /**
  50. * Remove injected CSS from recent comments widget.
  51. */
  52. function odin_remove_recent_comments_style() {
  53. global $wp_widget_factory;
  54. if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) {
  55. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  56. }
  57. }
  58. add_action( 'wp_head', 'odin_remove_recent_comments_style', 1 );
  59. /**
  60. * Remove injected CSS from gallery.
  61. */
  62. add_filter( 'use_default_gallery_style', '__return_false' );
  63. /**
  64. * Add rel="nofollow" and remove rel="category".
  65. */
  66. function odin_modify_category_rel( $text ) {
  67. $search = array( 'rel="category"', 'rel="category tag"' );
  68. $text = str_replace( $search, 'rel="nofollow"', $text );
  69. return $text;
  70. }
  71. add_filter( 'wp_list_categories', 'odin_modify_category_rel' );
  72. add_filter( 'the_category', 'odin_modify_category_rel' );
  73. /**
  74. * Add rel="nofollow" and remove rel="tag".
  75. */
  76. function odin_modify_tag_rel( $taglink ) {
  77. return str_replace( 'rel="tag">', 'rel="nofollow">', $taglink );
  78. }
  79. add_filter( 'wp_tag_cloud', 'odin_modify_tag_rel' );
  80. add_filter( 'the_tags', 'odin_modify_tag_rel' );
  81. /**
  82. * Filter function used to remove the tinymce emoji plugin.
  83. *
  84. * @param array $plugins
  85. *
  86. * @return array Difference betwen the two arrays
  87. */
  88. function disable_emojis_tinymce( $plugins ) {
  89. return is_array( $plugins ) ? array_diff( $plugins, array( 'wpemoji' ) ) : array();
  90. }
  91. add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
Advertisement
Add Comment
Please, Sign In to add comment