Last active
January 21, 2020 10:18
-
-
Save felixarntz/cc2a33e9dc01874c6a4cffffc1b19efb to your computer and use it in GitHub Desktop.
Clears PHP OpCache when visiting the Plugins admin screen (wp-admin/plugins.php).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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