Cleaning up after W3 Total Cache

Thoughts from the team
By    | September 3, 2012 | Tips & Tricks,

We’re running W3 Total Cache on a few client websites.  It’s fantastic at speeding things up, but it does leave a few confusing interface elements around the place for the client to deal with.  I like keeping things as simple and focused as possible for clients, so I’ve come up with a few ways to clean up after Total Cache.

1. Remove Performance menu from Admin Bar

This removes the link for all roles, put it in functions.php

function remove_purge_from_page_cache_link($actions, $post){
  unset($actions['pgcache_purge']);

  return $actions;
}

add_filter('post_row_actions', 'remove_purge_from_page_cache_link',1000,2);
add_filter('page_row_actions', 'remove_purge_from_page_cache_link',1000,2);

To make it only remove for authors you’ll want to use something like this

if (!current_user_can('publish_posts')) {
    unset($actions['pgcache_purge']);
}

You can tweak the logic to target the user group(s) you want.

2. Remove Purge From Page Cache link on Posts and Pages

I like a clean admin bar, so I’m pretty aggressive removing stuff I dont think the client needs.  This function removes the standard cruft and the Performance menu added by W3 Total Cache.

function custom_admin_bar_remove() {
  global $wp_admin_bar;

  $wp_admin_bar->remove_menu('wp-logo');
  $wp_admin_bar->remove_menu('comments');
  $wp_admin_bar->remove_menu('new-media');
  $wp_admin_bar->remove_menu('new-link');
  $wp_admin_bar->remove_menu('new-user');
  $wp_admin_bar->remove_menu('new-theme');
  $wp_admin_bar->remove_menu('new-plugin');
  $wp_admin_bar->remove_menu('appearance');
  $wp_admin_bar->remove_menu('search');

  // total cache
  $wp_admin_bar->remove_menu('w3tc');
}

add_action('wp_before_admin_bar_render', 'custom_admin_bar_remove', 0);

3. Remove dashboard widgets

This one’s simpler.  Just go into the General Settings tab of W3 Total Cache, scroll right to the bottom and in the Miscellaneous section you’ll find two options to hide the News and Page Speed widgets.

More like this