-
Notifications
You must be signed in to change notification settings - Fork 68
Home
Viktor Szépe edited this page Jun 26, 2017
·
4 revisions
Welcome to the wp-redis wiki!
add_action( 'wp_footer', function () {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$GLOBALS['wp_object_cache']->stats();
} );
if ( function_exists( 'wp_cache_flush' ) ) {
add_action( 'admin_bar_menu', 'o1_flush_cache_button', 100 );
}
function o1_flush_cache_button( $wp_admin_bar ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( isset( $_GET['flush-cache-button'] )
&& 'flush' === $_GET['flush-cache-button']
&& wp_verify_nonce( $_GET['_wpnonce'], 'flush-cache-button' )
) {
wp_cache_flush();
add_action( 'admin_notices', function () {
echo '<div class="notice notice-success is-dismissible"><p>Object Cache flushed.</p></div>';
} );
}
$dashboard_url = admin_url( add_query_arg( 'flush-cache-button', 'flush', 'index.php' ) );
$args = array(
'id' => 'flush_cache_button',
'title' => 'Flush Object Cache',
'href' => wp_nonce_url( $dashboard_url, 'flush-cache-button' ),
'meta' => array( 'class' => 'flush-cache-button' )
);
$wp_admin_bar->add_node( $args );
}