Remove excess from wp_head()


By default, a large amount of optional information is output through the wp_head() function, for example, the version of WordPress you are using. This information should be hidden not only for the cleanliness of the html code, but also for the security of your site, because knowing the version of CMS, it is easier to find gaps in its work. Next, we’ll list the code that removes all unnecessary things from the “header” of the site when adding it to function.php:

<?php 
    /* Clear wp_head(); */
    function remove_recent_comments_style() { 
        global $wp_widget_factory; 
        remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );  
    }  
    add_action( 'widgets_init', 'remove_recent_comments_style' );  
    remove_action( 'wp_head', 'feed_links_extra', 3 ); 
    remove_action( 'wp_head', 'feed_links', 2 );
    remove_action( 'wp_head', 'rsd_link' );
    remove_action( 'wp_head', 'wlwmanifest_link' );
    remove_action( 'wp_head', 'index_rel_link' );
    remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); 
    remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
    remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
    remove_action( 'wp_head', 'wp_generator' );
?>

Be careful, adding this code can affect the operation of systems by automatically posting records in WordPress, such as Windows Live Writer.


Требуется подобная доработка? Напишите нам.


Name

Email


Website


Messagge