admin-toolbar.php
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
class WpFastestCacheAdminToolbar{
public function __construct(){}
public function add(){
if(is_admin()){
add_action('wp_before_admin_bar_render', array($this, "wpfc_tweaked_toolbar_on_admin_panel"));
add_action('admin_enqueue_scripts', array($this, 'load_toolbar_js'));
add_action('admin_enqueue_scripts', array($this, 'load_toolbar_css'));
}else{
if(is_admin_bar_showing()){
add_action('wp_before_admin_bar_render', array($this, "wpfc_tweaked_toolbar_on_frontpage"));
add_action('wp_enqueue_scripts', array($this, 'load_toolbar_js'));
add_action('wp_enqueue_scripts', array($this, 'load_toolbar_css'));
add_action('wp_footer', array($this, 'print_my_inline_script'));
}
}
}
public function load_toolbar_js(){
wp_enqueue_script("wpfc-toolbar", plugins_url("wp-fastest-cache/js/toolbar.js"), array(), time(), true);
}
public function load_toolbar_css(){
wp_enqueue_style("wp-fastest-cache-toolbar", plugins_url("wp-fastest-cache/css/toolbar.css"), array(), time(), "all");
}
public function print_my_inline_script() {
?>
<script type="text/javascript">var wpfc_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";</script>
<?php
}
public function wpfc_tweaked_toolbar_on_frontpage() {
global $wp_admin_bar;
$wp_admin_bar->add_node(array(
'id' => 'wpfc-toolbar-parent',
'title' => 'Clear Cache'
));
$wp_admin_bar->add_menu( array(
'id' => 'wpfc-toolbar-parent-clear-cache-of-this-page',
'title' => 'Clear Cache of This Page',
'parent'=> 'wpfc-toolbar-parent',
'meta' => array("class" => "wpfc-toolbar-child")
));
$wp_admin_bar->add_menu( array(
'id' => 'wpfc-toolbar-parent-delete-cache',
'title' => 'Delete Cache',
'parent'=> 'wpfc-toolbar-parent',
'meta' => array("class" => "wpfc-toolbar-child")
));
$wp_admin_bar->add_menu( array(
'id' => 'wpfc-toolbar-parent-delete-cache-and-minified',
'title' => 'Delete Cache and Minified CSS/JS',
'parent'=> 'wpfc-toolbar-parent',
'meta' => array("class" => "wpfc-toolbar-child")
));
}
public function wpfc_tweaked_toolbar_on_admin_panel() {
global $wp_admin_bar;
$wp_admin_bar->add_node(array(
'id' => 'wpfc-toolbar-parent',
'title' => __("Delete Cache", "wp-fastest-cache"),
));
$wp_admin_bar->add_menu( array(
'id' => 'wpfc-toolbar-parent-delete-cache',
'title' => __("Clear All Cache", "wp-fastest-cache"),
'parent'=> 'wpfc-toolbar-parent',
'meta' => array("class" => "wpfc-toolbar-child")
));
$wp_admin_bar->add_menu( array(
'id' => 'wpfc-toolbar-parent-delete-cache-and-minified',
'title' => __("Delete Cache and Minified CSS/JS", "wp-fastest-cache"),
'parent'=> 'wpfc-toolbar-parent',
'meta' => array("class" => "wpfc-toolbar-child")
));
}
}
?>