Dejunking WordPress

Wordpress is the perfectly imperfect CMS, loved by many, used by millions, myself included. What makes WP so awesome, aside from open-source development with a great community behind it, is the flexibility and ease of use. Unfortunately what we get out of box is anything but perfect. So without further ado – let’s start dejunking..


/* ==================================

* REMOVE DEFAULT WORDPRESS JUNK *

* ================================= */

REMOVE 1 – unregister all default WP Widgets

function unregister_default_wp_widgets() {

unregister_widget(‘WP_Widget_Pages’);

unregister_widget(‘WP_Widget_Archives’);

unregister_widget(‘WP_Widget_Links’);

unregister_widget(‘WP_Widget_Search’);

}

add_action(‘widgets_init’, ‘unregister_default_wp_widgets’, 1);

// REMOVE 2 – remove WP head junk

remove_action(‘wp_head’, ‘rsd_link’);

remove_action(‘wp_head’, ‘wp_generator’);

remove_action(‘wp_head’, ‘index_rel_link’);

remove_action(‘wp_head’, ‘wlwmanifest_link’);

remove_action(‘wp_head’, ‘start_post_rel_link’, 10, 0);

remove_action(‘wp_head’, ‘parent_post_rel_link’, 10, 0);

remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0);

remove_action( ‘admin_head’, ‘id_wordpress_version_warning’ );

remove_action( ‘save_post’, ‘id_save_post’ );

remove_action( ‘wp_set_comment_status’, ‘id_comment_status’, 10, 2 );

remove_action( ‘trashed_comment’, ‘id_comment_trashed’, 10 );

remove_action( ‘untrashed_comment’, ‘id_comment_untrashed’, 10 );

//  REMOVE 3 – Disable WP Auto-update Checks

if (!current_user_can(‘edit_users’)) {

add_action(‘init’, create_function(‘$a’, ‘remove_action(‘init’, ‘wp_version_check’);’), 2);

add_filter(‘pre_option_update_core’, create_function(‘$a’, “return null;”));

}

//  REMOVE 4 – Disable WP UPDATE MESSAGE

if ( ! function_exists( ‘no_wp_update_annoyance’ ) ) :

/*** Disable WordPress Message** @since 1.2*/

function no_wp_update_annoyance() {

remove_action( ‘admin_notices’, ‘update_nag’, 3 );

}

endif;

add_action( ‘admin_init’, ‘no_wp_update_annoyance’ );

//  REMOVE 5 – Disable WordPress Plugin Updates

add_action( ‘admin_menu’, create_function( ‘$a’, ‘remove_action( ‘load-plugins.php’, ‘wp_update_plugins’ );’) );

# Why use the admin_menu hook? It’s the only one available between the above hook being added and being applied

add_action( ‘admin_init’, create_function( ‘$a’, ‘remove_action( ‘admin_init’, ‘wp_update_plugins’ );’), 2 );

add_action( ‘init’, create_function( ‘$a’, ‘remove_action( ‘init’, ‘wp_update_plugins’ );’), 2 );

add_filter( ‘pre_option_update_plugins’, create_function( ‘$a’, “return null;” ) );

remove_action( ‘load-plugins.php’, ‘wp_update_plugins’ );

remove_action( ‘load-update.php’, ‘wp_update_plugins’ );

remove_action( ‘admin_init’, ‘_maybe_update_plugins’ );

remove_action( ‘wp_update_plugins’, ‘wp_update_plugins’ );

add_filter( ‘pre_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );

remove_action( ‘load-update-core.php’, ‘wp_update_plugins’ );

add_filter( ‘pre_site_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );

3,532 Responses to “Dejunking WordPress”