View difference between Paste ID: VK2ETzVY and 9LdZvT3N
SHOW: | | - or go back to the newest paste.
1
remove_action('admin_bar_menu', array('Swift_Performance', 'toolbar_items'),100);
2-
	if (current_user_can('edit_posts')){
2+
3
add_action('admin_bar_menu', function ($admin_bar){
4
	if (!defined('SWIFT_PERFORMANCE_PLUGIN_NAME')){
5
		return;
6
	}
7
	if (current_user_can('manage_options')){
8
		$current_page = site_url(str_replace(site_url(), '', 'http'.(isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
9
		list($current_page_nq,) = explode('?',$current_page);
10
11
		$admin_bar->add_menu(array(
12
			'id'    => 'swift-performance',
13
			'title' => SWIFT_PERFORMANCE_PLUGIN_NAME,
14
			'href'  => '#'
15
		 ));
16
17
		if(Swift_Performance::check_option('enable-caching', 1)){
18
			$admin_bar->add_menu(array(
19
				'id'    => 'clear-swift-cache',
20
				'parent' => 'swift-performance',
21
				'title' => esc_html__('Clear All Cache', 'swift-performance'),
22
				'href'  => esc_url(wp_nonce_url(add_query_arg('swift-performance-action', 'clear-all-cache', $current_page), 'clear-swift-cache')),
23
			));
24
25
			if (!is_admin() && Swift_Performance_Cache::is_cached($current_page_nq)){
26
				$admin_bar->add_menu(array(
27
					'id'    => 'swift-cache-single',
28
					'parent' => 'swift-performance',
29
					'title' => esc_html__('Clear Page Cache', 'swift-performance'),
30
					'href'  => esc_url(wp_nonce_url(add_query_arg(array('swift-performance-action' => 'clear-page-cache', 'permalink' => urlencode($current_page_nq)), $current_page), 'clear-swift-cache')),
31
				));
32
				$admin_bar->add_menu(array(
33
					'id'    => 'swift-view-cached',
34
					'parent' => 'swift-performance',
35-
		if(Swift_Performance::check_option('enable-caching', 1, '!=') && (Swift_Performance::check_option('merge-scripts', 1) || Swift_Performance::check_option('merge-styles', 1))){
35+
36
					'href'  => esc_url(add_query_arg('force-cached', '1', $current_page_nq)),
37-
				'id'    => 'clear-swift-assets-cache',
37+
38
			}
39-
				'title' => esc_html__('Clear Assets Cache', 'swift-performance'),
39+
40-
				'href'  => esc_url(wp_nonce_url(add_query_arg('swift-performance-action', 'clear-assets-cache', $current_page), 'clear-swift-assets-cache')),
40+
41
},100);