Disabling the Views_Bulk_Operations default view

Tags: 

The Views_Bulk_Operations module for Drupal is really pretty awesome, out of the box it solves one of the top 5 problems newcomers have with Drupal - the standard content admin page, /admin/content/node, does not include a field to search for content by the title, instead you have to do a search in the main search engine and then click the edit link, presuming you haven't hidden it or something. Further, you can customize it by adding additional fields to the display or adding more filters, e.g. the taxonomy tree, and, more commonly, change the page path to be "admin/content/node" so it replaces the built-in admin page rather than compliment it.

That said, on every site I've used it I've customized it, but when I have that view loading through a custom module the default view still shows. As a result the Views list page (/admin/build/views) ends up with two different entries - the custom one and the default VBO one. Being a bit of a neat-freak when it comes to my Drupal installs, this doesn't work for me so I fix it. Here's how:

  // Disable the built-in Views_Bulk_Operations node admin view.
  $views_status = variable_get('views_defaults', array());
  $views_status['admin_content'] = TRUE; // True is disabled
  variable_set('views_defaults', $views_status);
  views_invalidate_cache();
  
  // Update the menu router information.
  menu_rebuild();

Stick that in your module's install script and you're good to go.