WP Rocket & WordPress 7.1: A critical error together
August 20, 2026
WordPress 7.1 has released with a few internal changes, one of which causes the popular WP Rocket plugin to be broken with, at the time of writing, no update available to fix a broken website. Hopefully due to severity of the issue of complete incompatibility the WP Rocket team releases a patch very soon, but in the meantime your website needs to work properly.
We’ve been able to identify where the issue lies, and how to apply a patch for those who rely on this plugin. You will need either FTP access, or cPanel access to your website outside of the WordPress admin.
Step 1: Locate the correct file
If you open a file browser with all of the files on your website and navigate towards wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/CDN you will locate a file called Cloudflare.php, and prepare to choose to edit within the file browsing tool you are using. cPanel users can choose the code editor and click next through any encoding box you may come across.
Note: there is a folder also called 3rd-party, which is the wrong ThirdParty. It needs to be spelt out with words.
Step 2: Apply the fix
Make sure you edit the code with a code editor. Do not use a tool like Microsoft Word as this will likely not work as expected.
Towards the bottom of the file you will come across code which looks like the following:
/**
* Unregister a callback.
*
* @param string $hook Hook on which to unregister.
* @param string $method The callback to unregister.
* @param int $priority the priority from the callback.
* @return void
*/
protected function unregister_callback( string $hook, string $method, int $priority = 10 ) {
global $wp_filter;
if ( ! key_exists( $hook, $wp_filter ) ) {
return;
}
$original_wp_filter = $wp_filter[ $hook ]->callbacks;
if ( ! key_exists( $priority, $original_wp_filter ) ) {
return;
}
foreach ( $original_wp_filter[ $priority ] as $key => $config ) {
if ( substr( $key, - strlen( $method ) ) !== $method ) {
continue;
}
unset( $wp_filter[ $hook ]->callbacks[ $priority ][ $key ] );
}
}Code language: PHP (php)
On this bit of code, locate the line with if ( substr( $key, - strlen( $method ) ) !== $method ) and change this to be if ( is_string($key) && substr( $key, - strlen( $method ) ) !== $method )
You do not need to make any other changes to this file.
Save the file and your website should spring back to life automatically. Depending on the tool you are using you may need to upload your changed file.
Conclusion
This is intended as a roughly technical guide to help get your website back online after this critical issue likely affecting thousands of websites. If your website is affected, and you do not feel comfortable applying this fix yourself, please feel free to get in touch and we can quote to apply the fix for you. Or if you have a web developer, feel free to send them this guide so they may follow this and get your site back online quickly.
We do hope the WP Rocket team learns from this and tests with pre-release versions of WordPress and able to alert customers ahead of time of a potentially required update to their plugin before WordPress lands.