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 / assets / js / editor.js
aruba-hispeed-cache / admin / assets / js Last commit date
editor.js 5 months ago option-page.js 5 months ago
editor.js
108 lines
1 ( function ( wp, React ) {
2 var registerPlugin = wp.plugins.registerPlugin;
3 var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
4 var Button = wp.components.Button;
5 // var CheckboxControl= wp.components.CheckboxControl;
6
7
8 var el = wp.element.createElement;
9 var __ = wp.i18n.__;
10 // var PluginSidebar = wp.editPost.PluginSidebar;
11
12
13 function MyDocumentSettingPlugin() {
14 return el(
15
16 PluginDocumentSettingPanel,
17 {
18 name: 'my-document-setting-plugin',
19 title: 'Aruba HiSpeed Cache',
20 icon: 'database',
21 },
22 /*__( 'My Document Setting Panel Content', 'aruba-hispeed-cache' ),*/
23
24 el(
25 Button,
26 {
27 className: 'ahsc-cleaner',
28 variant: 'secondary',
29 onClick: ahscBtnPurger,
30 },
31 __( 'Cancella Cache', 'aruba-hispeed-cache' ),
32 ),
33 el('div',{ className: 'ahsc-loader'},"")
34
35 );
36 }
37
38 registerPlugin( 'my-document-setting-plugin', {
39 render: MyDocumentSettingPlugin,
40 } );
41
42 const ahscBtnPurger = async () => {
43 if (typeof AHSC_TOOLBAR.ahsc_nonce == "undefined") {
44 console.warn("No nonce is set for this action. This action has been aborted.");
45 return;
46 }
47
48 document.getElementsByClassName('ahsc-loader')[0].style.fontWeight="Bold";
49 //loader.style.display = "block";
50 document.getElementsByClassName('ahsc-loader')[0].insertAdjacentHTML("beforeend", __( 'Cancellazione in corso', 'aruba-hispeed-cache' ) )
51 let to_purge = "current-url" === AHSC_TOOLBAR.ahsc_topurge ? window.location.pathname : "all";
52
53 const data = new FormData();
54 data.append("action", "ahcs_clear_cache");
55 data.append("ahsc_nonce", AHSC_TOOLBAR.ahsc_nonce);
56 data.append("ahsc_to_purge", encodeURIComponent(to_purge));
57
58 const request = await fetch(AHSC_TOOLBAR.ahsc_ajax_url, {
59 method: "POST",
60 credentials: "same-origin",
61 body: data,
62 })
63 .then((r) => r.json())
64 .then((result) => {
65 if (result.code >= 200) {
66 let style = "";
67 let message_color="";
68 switch (result.type) {
69 case "success":
70 style = "color:green";
71 message_color="green";
72 break;
73 case "error":
74 style = "color:red";
75 message_color="red";
76 break;
77 default:
78 style = "color:blue";
79 message_color="blue";
80 break;
81 }
82 console.log(`%c${result.message}`, style);
83 document.getElementsByClassName('ahsc-loader')[0].innerHTML="";
84 document.getElementsByClassName('ahsc-loader')[0].style.color=message_color;
85 document.getElementsByClassName('ahsc-loader')[0].insertAdjacentHTML("beforeend", __( result.message, 'aruba-hispeed-cache' ) );
86 setTimeout(function() {
87 document.getElementsByClassName('ahsc-loader')[0].innerHTML="";
88 }, 3000); // <-- time in milliseconds
89
90 }
91 })
92 .catch((error) => {
93 console.log("[Aruba HiSpeed Cache Plugin]");
94 console.error(error);
95 document.getElementsByClassName('ahsc-loader')[0].innerHTML="";
96 document.getElementsByClassName('ahsc-loader')[0].style.color=message_color;
97 document.getElementsByClassName('ahsc-loader')[0].insertAdjacentHTML("beforeend",error);
98 });
99
100 return;
101 };
102
103 /* The line `window.ahscBtnPurger = ahscBtnPurger;` is assigning the `ahscBtnPurger` function to the
104 `ahscBtnPurger` property of the `window` object. This makes the function accessible globally in the
105 browser environment. */
106 window.ahscBtnPurger = ahscBtnPurger;
107
108 } )( window.wp, window.React );