PluginProbe ʕ •ᴥ•ʔ
Aruba HiSpeed Cache / 3.0.15
Aruba HiSpeed Cache v3.0.15
3.0.15 3.0.14 3.0.13 1.2.4 1.2.5 1.2.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.19 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3
aruba-hispeed-cache / admin / AHSC_Admin_Bar.php
aruba-hispeed-cache / admin Last commit date
assets 3 months ago pages 3 days ago AHSC_Admin_Bar.php 5 months ago AHSC_Admin_Menu.php 5 months ago index.php 5 months ago
AHSC_Admin_Bar.php
109 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 \add_action( 'admin_bar_menu', 'AHSC_add_admin_bar_menu_links' , 100 );
6
7 //die(var_export(__( 'Purge Cache','aruba-hispeed-cache' ),true));
8 const AHSC_MENUBAR_PARENT_ITEM = 'aruba_spa';
9 //$topurge = 'current-url';
10 //$AHSC_AB_title =esc_html(__( 'Purge page cache', 'aruba-hispeed-cache' ));
11 //var_dump(esc_html(__( 'Purge page cache', 'aruba-hispeed-cache' )));
12 /*
13 if ( \is_admin() ) {
14 $topurge = 'all';
15 $AHSC_AB_title = esc_html(__( 'Purge Cache', 'aruba-hispeed-cache' )) ;
16 //esc_html(__( 'Purge Cache', 'aruba-hispeed-cache' ));
17 }*/
18
19
20
21
22 /**
23 * Netodo che aggiunge action link alla admin bar.
24 *
25 * @doc see https://developer.wordpress.org/reference/hooks/admin_bar_menu/
26 *
27 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
28 * @return void
29 */
30 function AHSC_add_admin_bar_menu_links( $wp_admin_bar ) {
31 //global $AHSC_AB_title,$topurge;
32 $AHSC_AB_title =esc_html(__( 'Purge page cache', 'aruba-hispeed-cache' ));
33 //var_dump(esc_html(__( 'Purge page cache', 'aruba-hispeed-cache' )));
34
35 if ( \is_admin() ) {
36 $topurge = 'all';
37 $AHSC_AB_title = esc_html(__( 'Purge Cache', 'aruba-hispeed-cache' )) ;
38 //esc_html(__( 'Purge Cache', 'aruba-hispeed-cache' ));
39 }else{
40 $topurge = 'current-url';
41 }
42 if ( is_user_logged_in() && current_user_can( 'manage_options' )){
43 $wp_admin_bar->add_menu(
44 array(
45 'id' => 'ahsc-purge-link',
46 'parent' => ( ! \is_null( $wp_admin_bar->get_node( AHSC_MENUBAR_PARENT_ITEM ) ) ) ? AHSC_MENUBAR_PARENT_ITEM : false,
47 'title' => AHSC_Menu_get_title(),
48 'meta' => array(
49 'title' => $AHSC_AB_title,
50 'data-topurge' => $topurge,
51 'onclick' => 'ahscBtnPurger(); return;'
52 ),
53 )
54 );
55
56 $wp_admin_bar->add_menu(
57 array(
58 'id' => 'ahsc-transient-purge',
59 'parent' => ( ! \is_null( $wp_admin_bar->get_node( AHSC_MENUBAR_PARENT_ITEM ) ) ) ? AHSC_MENUBAR_PARENT_ITEM : false,
60 'title' =>'<span class="ab-icon ahsc-ab-icon" aria-hidden="true"></span><span class="ab-label">'.esc_html(__( 'Purge Expired Transient', 'aruba-hispeed-cache' )).'</span>',
61 'meta' => array(
62 'title' => esc_html(__( 'Purge Expired Transient', 'aruba-hispeed-cache' )),
63 'onclick' => 'ahscBtnTransientPurger(); return;'
64 ),
65 )
66 );
67
68 }
69 }
70
71
72 /**
73 * This method adds and localizes the toolbar.js on both the frontend and backend.
74 *
75 * @return void
76 */
77 function AHSC_localize_toolbar_js() {
78
79 if ( \is_admin() ) {
80 $topurge = 'all';
81 }else{
82 $topurge = 'current-url';
83 }
84 if ( is_user_logged_in() && current_user_can( 'manage_options' )) {
85 //global $topurge;
86 $js_param = array(
87 'ahsc_ajax_url' => \admin_url('admin-ajax.php'),
88 'ahsc_topurge' => $topurge,
89 'ahsc_nonce' => \wp_create_nonce('ahsc-purge-cache'),
90 );
91 \wp_add_inline_script('ahcs-toolbar', 'const AHSC_TOOLBAR = ' . \wp_json_encode($js_param), 'before');
92 }
93 }
94
95 /**
96 * Get the title whit icon.
97 *
98 * @return string
99 */
100 function AHSC_Menu_get_title() {
101 //global $AHSC_AB_title;
102 $AHSC_AB_title =esc_html(__( 'Purge page cache', 'aruba-hispeed-cache' ));
103
104 if ( \is_admin() ) {
105 $AHSC_AB_title = esc_html(__( 'Purge Cache', 'aruba-hispeed-cache' )) ;
106 }
107 $title = '<span class="ab-icon ahsc-ab-icon" aria-hidden="true"></span><span class="ab-label">' . $AHSC_AB_title . '</span>';
108 return $title;
109 }