Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clears PHP OpCache when visiting the Plugins admin screen (wp-admin/plugins.php).
<?php
/**
* Clear OpCache Simple.
*
* @author Felix Arntz, Google
* @license Apache 2.0
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
* Plugin Name: Clear OpCache Simple
* Description: Clears PHP OpCache when visiting the Plugins admin screen (wp-admin/plugins.php).
* Plugin URI: https://gist.github.com/felixarntz/cc2a33e9dc01874c6a4cffffc1b19efb
* Version: 0.1.0
* Author: Felix Arntz, Google
* Author URI: https://felix-arntz.me
* License: Apache License 2.0
* License URI: https://www.apache.org/licenses/LICENSE-2.0
*/
add_action(
'current_screen',
function( $screen ) {
if ( 'plugins' !== $screen->id ) {
return;
}
if ( ! function_exists( 'opcache_reset' ) ) {
return;
}
opcache_reset();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment