Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active October 5, 2023 09:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glueckpress/0fcd12a8ada43e37e400facd987016a1 to your computer and use it in GitHub Desktop.
Save glueckpress/0fcd12a8ada43e37e400facd987016a1 to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket] Remove Cache Options meta box from Edit screens.
<?php
/**
* PLEASE SEE COMMENT BELOW:
* https://gist.github.com/glueckpress/0fcd12a8ada43e37e400facd987016a1#gistcomment-3009533
*/
defined( 'ABSPATH' ) or die();
/**
* Plugin Name: WP Rocket | Remove Cache Options Meta Boxx
* Description: Removes the Cache Options meta box from Edit screens.
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_action( 'wp_rocket_loaded', function () {
remove_action( 'add_meta_boxes', 'rocket_cache_options_meta_boxes' );
});
@harryqt
Copy link

harryqt commented Aug 17, 2019

Does not work with latest version but hooking to admin_menu works fine.

/**
 * Removes WP Rocket Cache Options metabox from Edit screens.
 */
add_action( 'admin_menu', function() {
    remove_action( 'add_meta_boxes', 'rocket_cache_options_meta_boxes' );
});

@glueckpress
Copy link
Author

Thanks for the heads up, @Dibbyo456! I don’t think admin_menu is a particularly appropriate hook for this purpose, but admin_init probably will be if wp_rocket_loaded doesn’t do the trick. (Not tested, though.)

That said, I should probably archive this Gist. WP Rocket has a whole GitHub repo full of helper plugins, and if people need further support, it’s best to open a ticket.

@Frique
Copy link

Frique commented Oct 5, 2023

This doesn't work anymore (since version 3.15), so this is an alternative:
add_filter( 'rocket_metabox_options_post_types', '__return_empty_array' );
It indicates that you want the metabox to be shown on 0 post types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment