Open bpongy opened 5 years ago
Up.
Here is my patch:
<?php
if ( is_multisite() && function_exists('wp_cache_clear_cache') && current_user_can('manage_options') && isset($_GET['ax_delete_cache']) ) {
wp_cache_clear_cache(get_current_blog_id());
wp_redirect( home_url() );
}
add_action( 'admin_bar_menu', function($wp_admin_bar) {
if ( !is_super_admin() && is_multisite() && function_exists('wp_cache_clear_cache') && current_user_can('manage_options') ) {
$args = array(
'id' => 'ax_vidercache',
'title' => 'Vider le cache',
'href' => add_query_arg( array('ax_delete_cache' => '1') ),
'parent' => 'site-name'
);
$wp_admin_bar->add_node($args);
}
}, 900 );
Thanks @redpik! Thats handy workaround. I've adapted slightly to
Call to undefined function wp_get_current_user()
" error caused by function current_user_can()
called before initialized.<?php
add_action('init', 'init_delete_cache');
function init_delete_cache()
{
if (function_exists('wp_cache_clear_cache') && current_user_can('manage_options') && isset($_GET['ax_delete_cache'])) {
if (is_multisite()) {
wp_cache_clear_cache(get_current_blog_id());
} else {
wp_cache_clear_cache();
}
}
add_action('admin_bar_menu', function ($wp_admin_bar) {
if (function_exists('wp_cache_clear_cache') && current_user_can('manage_options')) {
$args = array(
'id' => 'ax_delete_cache',
'parent' => '',
'title' => 'Delete Site Cache',
'href' => add_query_arg(['ax_delete_cache' => '1']),
);
$wp_admin_bar->add_node($args);
}
}, 900);
}
:+1:
If WPSC is network activated, administrators can’t see the delete cache button. Only the superadmin can see the button. Is there a way to change this behavior?
WordPress 5.0.3 WP Super Cache 1.6.4