Skip to content

Instantly share code, notes, and snippets.

@lunaroja
Created December 9, 2013 18:57
Show Gist options
  • Save lunaroja/7878542 to your computer and use it in GitHub Desktop.
Save lunaroja/7878542 to your computer and use it in GitHub Desktop.
Clean WordPress wp_head() output
<?php
if ( ! function_exists( 'clean_header' ) ):
/*
* Clean the WordPress Header
*/
function clean_header() {
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_wp_head', 10, 0);
remove_action( 'wp_head', 'locale_stylesheet');
remove_action( 'wp_head', 'noindex');
remove_action( 'wp_head', 'wp_print_styles');
remove_action( 'wp_head', 'wp_print_head_scripts');
remove_action( 'wp_head', 'wp_generator');
}
clean_header();
endif;
if ( ! function_exists( 'remove_recent_comments_style' ) ) :
/*
* Clean Widget Output
*/
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' );
endif;
if ( ! function_exists( 'remove_more_jump_link' ) ) :
/*
* Remove the unsightly 'jump' from the read-more link
*/
function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');
endif;
/*
* Remove miscellaneous items
*/
add_filter( 'use_default_gallery_style', '__return_false' );
add_filter( 'login_errors', '__return_false' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment