| @@ -96,11 +96,9 @@ | ||
| 96 | 96 | * @param array $menu_items |
| 97 | 97 | * @return array |
| 98 | 98 | */ |
| 99 | 99 | public function admin_bar_menu($menu_items) { |
| 100 | - $wpo_minify_options = wp_optimize_minify_config()->get(); | |
| 101 | - | |
| 102 | - if (!$wpo_minify_options['enabled'] || !WP_Optimize()->current_user_can('manage_options') || !($wpo_minify_options['enable_css'] || $wpo_minify_options['enable_js'])) return $menu_items; | |
| 100 | + if (!$this->enabled || !$this->can_purge_cache()) return $menu_items; | |
| 103 | 101 | |
| 104 | 102 | $act_url = WP_Optimize_Utils::get_url_without_cache_purge_params(); |
| 105 | 103 | $cache_path = WP_Optimize_Minify_Cache_Functions::cache_path(); |
| 106 | 104 | $cache_size_info = '<h4>'.__('Minify cache', 'wp-optimize').'</h4><span><span class="label">'.__('Cache size:', 'wp-optimize').'</span> <span class="stats">'.esc_html(WP_Optimize_Minify_Cache_Functions::get_cachestats($cache_path['cachedir'])).'</span></span>'; |
| @@ -126,20 +124,22 @@ | ||
| 126 | 124 | /** |
| 127 | 125 | * Check if purge single page action sent and purge cache. |
| 128 | 126 | */ |
| 129 | 127 | public function handle_purge_minify_cache() { |
| 130 | - $wpo_minify_options = wp_optimize_minify_config()->get(); | |
| 131 | - if (!$wpo_minify_options['enabled'] || !WP_Optimize()->current_user_can('manage_options')) return; | |
| 128 | + if (!$this->enabled || !$this->can_purge_cache()) return; | |
| 132 | 129 | |
| 133 | 130 | $is_cache_purged = TeamUpdraft\WP_Optimize\Includes\Fragments\fetch_superglobal('get', 'wpo_minify_cache_purged'); |
| 134 | 131 | if (null !== $is_cache_purged) { |
| 135 | 132 | if (is_admin()) { |
| 133 | + $admin_notices_hook = is_network_admin() ? 'network_admin_notices' : 'admin_notices'; | |
| 136 | 134 | $notice_function = 'notice_purge_minify_cache_' . ('false' === $is_cache_purged ? 'failure' : 'success'); |
| 137 | - add_action('admin_notices', array($this, $notice_function)); | |
| 135 | + add_action($admin_notices_hook, array($this, $notice_function)); | |
| 136 | + add_action('admin_head', array('WP_Optimize_Utils', 'script_to_remove_cache_purge_params_from_url')); | |
| 138 | 137 | return; |
| 139 | 138 | } else { |
| 140 | 139 | $message = 'false' === $is_cache_purged ? __('Failed to purge the minify cache.', 'wp-optimize') : __('Minify cache purged', 'wp-optimize'); |
| 141 | 140 | printf('<script>window.onload = function() {alert("%s");}</script>', esc_js($message)); |
| 141 | + WP_Optimize_Utils::script_to_remove_cache_purge_params_from_url(); | |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |