add_menu( array( 'id' => 'all-cache-purge', 'title' => __( 'Purge All Cache', 'powered-cache' ), 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=powered_cache_purge_all_cache' ), 'powered_cache_purge_all_cache' ), 'parent' => 'powered-cache', ) ); } /** * Purges all cache related things * * @since 1.1 */ public function purge_all_cache() { if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'powered_cache_purge_all_cache' ) ) { wp_nonce_ays( '' ); } if ( is_multisite() && ! current_user_can( 'manage_network' ) ) { Powered_Cache_Admin_Helper::set_flash_message( __( "You don't have permission to perform this action!", 'powered-cache' ), 'error' ); wp_safe_redirect( wp_get_referer() ); die(); } powered_cache_flush();// cleans object cache + page cache dir // extensions should use this action do_action( 'powered_cache_purge_all_cache' ); $msg = __( 'Cache flushed successfully', 'powered-cache' ); Powered_Cache_Admin_Helper::set_flash_message( $msg ); wp_safe_redirect( wp_get_referer() ); die(); } /** * @since 1.1 * @return Powered_Cache_Hooks */ public static function factory() { static $instance; if ( ! $instance ) { $instance = new self(); $instance->setup(); } return $instance; } }