Title: FYI: Flush button script breaks update
Last modified: July 14, 2020

---

# FYI: Flush button script breaks update

 *  Resolved [Jagster_](https://wordpress.org/support/users/jagster_/)
 * (@jagster_)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/)
 * I know this is not your issue, but it is UX-way 😉
 * Quite widely used script that shows flush-button at admin-bar will break updates
   beginning v2.
 * Have you considered to do something similar? Every now and then must flush the
   cache and route cia settings isn’t… stylish
 * And I ment this one:
 *     ```
       # Check: https://onexa.nl/wordpress/toolbar-link-redis-object-cache/
       /**
        * Add a link to the Admin Toolbar to easily flush the Redis cache (Redis Object Cache plugin)
        * 
        * @author Hiranthi Herlaar, onexa.nl
        * 
        * @var $wp_admin_bar > https://codex.wordpress.org/Class_Reference/WP_Admin_Bar
       **/
       function redis_add_toolbar_link( $wp_admin_bar )
       {
       	if ( current_user_can( 'manage_options' ) && is_plugin_active( 'redis-cache/redis-cache.php' ) )
       	{
       		$RedisObjectCache = new RedisObjectCache;
   
       		if ( $RedisObjectCache->get_redis_status() )
       		{
   
       			$RedisPage = is_multisite() ? 'settings.php?page=redis-cache' : 'options-general.php?page=redis-cache';
   
       			// Flush Redis Cache trough WP Rocket Admin Bar Menu
       			$args = array(
       				'id'     => 'flush-redis-cache',
       				'title'  => __( 'Flush Redis Cache' ) . '',
       				'parent' => false,
       				'href'  => wp_nonce_url( network_admin_url( add_query_arg( 'action', 'flush-cache', $RedisPage ) ), 'flush-cache' )
       			);
   
       			$wp_admin_bar->add_node( $args );
   
       		} // end REDIS
       	}
       } // end add_toolbar_link
       add_action( 'admin_bar_menu', 'redis_add_toolbar_link', 999 );
       ```
   
    -  This topic was modified 5 years, 11 months ago by [Jagster_](https://wordpress.org/support/users/jagster_/).
    -  This topic was modified 5 years, 11 months ago by [Jagster_](https://wordpress.org/support/users/jagster_/).
    -  This topic was modified 5 years, 11 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Formatting

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [naxvog](https://wordpress.org/support/users/naxvog/)
 * (@naxvog)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13121765)
 * The class `RedisObjectCache` does not exist in version 2.x as we switched to 
   namespaces.
 * Could you please try the following?
    Change the line `$RedisObjectCache = new
   RedisObjectCache;` … to … `$RedisObjectCache = Rhubarb\RedisCache::instance();`
 * And
    `'href' => wp_nonce_url( network_admin_url( add_query_arg( 'action', 'flush-
   cache', $RedisPage ) ), 'flush-cache' )` … to … `'href' => $RedisObjectCache-
   >action_link( 'flush-cache' )`
 * Sadly I am unable to test it a but there is a good chance that this might just
   work.
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122118)
 * Hi [@jagster_](https://wordpress.org/support/users/jagster_/),
 * is this causing your site to crash, or is the button just not working.
 * Feel free to submit a pull request:
    [https://github.com/rhubarbgroup/redis-cache/issues/224](https://github.com/rhubarbgroup/redis-cache/issues/224)
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122264)
 * [@jagster_](https://wordpress.org/support/users/jagster_/):
 * Could you try adding this snippet above your `redis_add_toolbar_link()` function
   and see if it works again?
 *     ```
       if ( ! isset( $GLOBALS[ 'redisObjectCache' ] ) ) {
           $GLOBALS[ 'redisObjectCache' ] = Rhubarb\RedisCache\Plugin::instance();
       }
   
       if ( ! class_exists( 'RedisObjectCache' ) ) :
   
       class RedisObjectCache {
           public function get_redis_status() {
               return Rhubarb\RedisCache\Plugin::instance()->get_redis_status();
           }
       }
   
       endif;
       ```
   
 *  Thread Starter [Jagster_](https://wordpress.org/support/users/jagster_/)
 * (@jagster_)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122559)
 * I had this script in use in 14 slightly different WordPress installs and all 
   of them crashed.
 * Sure, I’ll give a try.
 *  Thread Starter [Jagster_](https://wordpress.org/support/users/jagster_/)
 * (@jagster_)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122590)
 * It worked. Well, I don’t know what will happend with that if trying do update
   from 1.6.x because all of my sites use already 2.0.2.
 * BTW, metrics works just fine. Did you fix that or am I just lucky 😉
    -  This reply was modified 5 years, 11 months ago by [Jagster_](https://wordpress.org/support/users/jagster_/).
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122782)
 * The metrics worked, just some weird corner cases failed. That’s fixed in v2.0.3,
   which was just released.
 * I’ll include an Adminbar node with the next version, you can use the snippet 
   above until then to fix your existing code.
 * Feel free to chime in here: [https://github.com/rhubarbgroup/redis-cache/issues/224](https://github.com/rhubarbgroup/redis-cache/issues/224)
 *  Thread Starter [Jagster_](https://wordpress.org/support/users/jagster_/)
 * (@jagster_)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122800)
 * Thanks!
 * I’m really bad at git and Github. But I’ll comment something there.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘FYI: Flush button script breaks update’ is closed to new replies.

 * ![](https://ps.w.org/redis-cache/assets/icon-256x256.gif?rev=2568513)
 * [Redis Object Cache](https://wordpress.org/plugins/redis-cache/)
 * [Support Threads](https://wordpress.org/support/plugin/redis-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/redis-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redis-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redis-cache/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [Jagster_](https://wordpress.org/support/users/jagster_/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/fyi-flush-button-script-breaks-update/#post-13122800)
 * Status: resolved