Aruba HiSpeed Cache - Version 1.2.0

Version Description

  • Discriminant added to REST API requests to include FSE support and remove recurring clear cache requests.
  • Clear function added to the 'post_updated hook' action to include support for the editor with meta-box added by plugins and themes.
  • Log function added to files activated with WP_DEBUG set to true, created in plugin folder. N.B. If disabled, file will be deleted.
  • FILTER_SANITIZE_STRING replaced by FILTER_SANITIZE_URL to ensure compatibility with PHP 8.1.
  • ArubaHiSpeedCache_update_plugins_db() mode added to allow management of future database updates.
  • Action and filter loading system within plugin fixed.
  • Various bug fixes and other improvements.
Download this release

Release Info

Developer arubadev
Plugin Icon 128x128 Aruba HiSpeed Cache
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.2 to 1.2.0

admin/css/aruba-hispeed-cache-admin-notice.css CHANGED
@@ -1,35 +1,35 @@
1
- :root {
2
- --icon-external-link: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> <g style="stroke:rgb(35,82,124);stroke-width:1"> <line x1="5" y1="5" x2="5" y2="14" /> <line x1="14" y1="9" x2="14" y2="14" /> <line x1="5" y1="14" x2="14" y2="14" /> <line x1="5" y1="5" x2="9" y2="5" /> <line x1="10" y1="2" x2="17" y2="2" /> <line x1="17" y1="2" x2="17" y2="9" /> <line x1="10" y1="9" x2="17" y2="2" style="stroke-width:1.5" /></g></svg>');
3
- }
4
-
5
- #ahsc-service-error {
6
- background: rgba(208, 2, 27, 0.1);
7
- -webkit-box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #d0021b;
8
- box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #d0021b;
9
- }
10
-
11
- #ahsc-service-warning {
12
- background: rgba(245, 166, 35, 0.1);
13
- -webkit-box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #f5a623;
14
- box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #f5a623;
15
- }
16
-
17
- #ahsc-service-error,
18
- #ahsc-service-warning {
19
- border: none;
20
- margin: 15px 0;
21
- padding: 15px;
22
- }
23
-
24
- #ahsc-service-error a,
25
- #ahsc-service-warning a {
26
- text-decoration: none;
27
- font-weight: 500;
28
- }
29
-
30
- #ahsc-service-error a::after,
31
- #ahsc-service-warning a::after {
32
- content: "";
33
- background: no-repeat var(--icon-external-link);
34
- padding-right: 1em;
35
- }
1
+ :root {
2
+ --icon-external-link: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> <g style="stroke:rgb(35,82,124);stroke-width:1"> <line x1="5" y1="5" x2="5" y2="14" /> <line x1="14" y1="9" x2="14" y2="14" /> <line x1="5" y1="14" x2="14" y2="14" /> <line x1="5" y1="5" x2="9" y2="5" /> <line x1="10" y1="2" x2="17" y2="2" /> <line x1="17" y1="2" x2="17" y2="9" /> <line x1="10" y1="9" x2="17" y2="2" style="stroke-width:1.5" /></g></svg>');
3
+ }
4
+
5
+ #ahsc-service-error {
6
+ background: rgba(208, 2, 27, 0.1);
7
+ -webkit-box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #d0021b;
8
+ box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #d0021b;
9
+ }
10
+
11
+ #ahsc-service-warning {
12
+ background: rgba(245, 166, 35, 0.1);
13
+ -webkit-box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #f5a623;
14
+ box-shadow: 0 1px 2px 0 rgba(63, 63, 68, 0.25), inset 0 3px 0 0 #f5a623;
15
+ }
16
+
17
+ #ahsc-service-error,
18
+ #ahsc-service-warning {
19
+ border: none;
20
+ margin: 15px 0;
21
+ padding: 15px;
22
+ }
23
+
24
+ #ahsc-service-error a,
25
+ #ahsc-service-warning a {
26
+ text-decoration: none;
27
+ font-weight: 500;
28
+ }
29
+
30
+ #ahsc-service-error a::after,
31
+ #ahsc-service-warning a::after {
32
+ content: "";
33
+ background: no-repeat var(--icon-external-link);
34
+ padding-right: 1em;
35
+ }
admin/css/aruba-hispeed-cache-admin.css CHANGED
@@ -1,36 +1,36 @@
1
- .clearfix {
2
- }
3
- .clearfix:before,
4
- .clearfix:after {
5
- content: " ";
6
- display: table;
7
- }
8
- .clearfix:after {
9
- clear: both;
10
- }
11
-
12
- .form-table th,
13
- .form-wrap label {
14
- vertical-align: middle;
15
- }
16
-
17
- .form-table th {
18
- width: 25% !important;
19
- }
20
-
21
- .ahsc-options-wrapper tr td label {
22
- width: 100%;
23
- }
24
-
25
- h2,
26
- h3 {
27
- color: #1d2327 !important;
28
- font-size: 1.3em !important;
29
- margin: 1em 0 !important;
30
- padding: 8px 12px 8px 0px !important;
31
- }
32
-
33
- small::before {
34
- content: "\a";
35
- white-space: pre;
36
- }
1
+ .clearfix {
2
+ }
3
+ .clearfix:before,
4
+ .clearfix:after {
5
+ content: " ";
6
+ display: table;
7
+ }
8
+ .clearfix:after {
9
+ clear: both;
10
+ }
11
+
12
+ .form-table th,
13
+ .form-wrap label {
14
+ vertical-align: middle;
15
+ }
16
+
17
+ .form-table th {
18
+ width: 25% !important;
19
+ }
20
+
21
+ .ahsc-options-wrapper tr td label {
22
+ width: 100%;
23
+ }
24
+
25
+ h2,
26
+ h3 {
27
+ color: #1d2327 !important;
28
+ font-size: 1.3em !important;
29
+ margin: 1em 0 !important;
30
+ padding: 8px 12px 8px 0px !important;
31
+ }
32
+
33
+ small::before {
34
+ content: "\a";
35
+ white-space: pre;
36
+ }
admin/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- /**
3
- * Silence.
4
- */
1
+ <?php
2
+ /**
3
+ * Silence.
4
+ */
admin/js/aruba-hispeed-cache-admin.js CHANGED
@@ -1,33 +1,33 @@
1
- (() => {
2
- "use strict";
3
-
4
- const ahsc_show_option = () => {
5
- let ahsc_enable_purge = document.querySelector("input#ahsc_enable_purge");
6
-
7
- ahsc_enable_purge.addEventListener("change", (e) => {
8
- let form_parts = document.querySelector("form#post_form > div > div").children;
9
-
10
- if (form_parts[1].style.display === "none" && form_parts[2].style.display === "none") {
11
- form_parts[1].style.removeProperty("display");
12
- form_parts[2].style.removeProperty("display");
13
- } else {
14
- form_parts[1].style.display = "none";
15
- form_parts[2].style.display = "none";
16
- }
17
- });
18
- };
19
-
20
- document.addEventListener("DOMContentLoaded", function (event) {
21
- const purge_btn = document.querySelector("a#purgeall");
22
-
23
- purge_btn.addEventListener("click", (e) => {
24
- if (confirm(aruba_hispeed_cache.purge_confirm_string) === true) {
25
- // Continue submitting form.
26
- } else {
27
- e.preventDefault();
28
- }
29
- });
30
-
31
- ahsc_show_option();
32
- });
33
- })();
1
+ (() => {
2
+ "use strict";
3
+
4
+ const ahsc_show_option = () => {
5
+ let ahsc_enable_purge = document.querySelector("input#ahsc_enable_purge");
6
+
7
+ ahsc_enable_purge.addEventListener("change", (e) => {
8
+ let form_parts = document.querySelector("form#post_form > div > div").children;
9
+
10
+ if (form_parts[1].style.display === "none" && form_parts[2].style.display === "none") {
11
+ form_parts[1].style.removeProperty("display");
12
+ form_parts[2].style.removeProperty("display");
13
+ } else {
14
+ form_parts[1].style.display = "none";
15
+ form_parts[2].style.display = "none";
16
+ }
17
+ });
18
+ };
19
+
20
+ document.addEventListener("DOMContentLoaded", function (event) {
21
+ const purge_btn = document.querySelector("a#purgeall");
22
+
23
+ purge_btn.addEventListener("click", (e) => {
24
+ if (confirm(aruba_hispeed_cache.purge_confirm_string) === true) {
25
+ // Continue submitting form.
26
+ } else {
27
+ e.preventDefault();
28
+ }
29
+ });
30
+
31
+ ahsc_show_option();
32
+ });
33
+ })();
admin/partials/admin-display.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
- global $pagenow;
3
- ?>
4
-
5
- <!-- This file should primarily consist of HTML with a little bit of PHP. -->
6
-
7
- <div class="wrap ahsc-wrapper">
8
- <h1 class="ahsc-option-title">
9
- <?php \esc_html_e('Aruba HiSpeed Cache Settings ', 'aruba-hispeed-cache'); ?>
10
- </h1>
11
-
12
- <div id="poststuff">
13
- <div id="post-body" class="metabox-holder columns-2">
14
- <div id="post-body-content">
15
- <?php
16
- require ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-general-options.php';
17
- ?>
18
- </div> <!-- End of #post-body-content -->
19
- <div id="postbox-container-1" class="postbox-container">
20
- <!-- empty sidebar -->
21
- </div> <!-- End of #postbox-container-1 -->
22
- </div> <!-- End of #post-body -->
23
- </div> <!-- End of #poststuff -->
24
- </div> <!-- End of .wrap .ahsc-wrapper -->
1
+ <?php
2
+ global $pagenow;
3
+ ?>
4
+
5
+ <!-- This file should primarily consist of HTML with a little bit of PHP. -->
6
+
7
+ <div class="wrap ahsc-wrapper">
8
+ <h1 class="ahsc-option-title">
9
+ <?php \esc_html_e('Aruba HiSpeed Cache Settings ', 'aruba-hispeed-cache'); ?>
10
+ </h1>
11
+
12
+ <div id="poststuff">
13
+ <div id="post-body" class="metabox-holder columns-2">
14
+ <div id="post-body-content">
15
+ <?php
16
+ require ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-general-options.php';
17
+ ?>
18
+ </div> <!-- End of #post-body-content -->
19
+ <div id="postbox-container-1" class="postbox-container">
20
+ <!-- empty sidebar -->
21
+ </div> <!-- End of #postbox-container-1 -->
22
+ </div> <!-- End of #post-body -->
23
+ </div> <!-- End of #poststuff -->
24
+ </div> <!-- End of .wrap .ahsc-wrapper -->
admin/partials/admin-notice-not-aruba-server.php CHANGED
@@ -1,10 +1,10 @@
1
- <div id="ahsc-service-error" class="notice notice-error">
2
- <p>
3
- <?php
4
- printf(
5
- \wp_kses(__('<strong>The Aruba HiSpeed Cache plugin cannot be used because your WordPress website is not hosted on an Aruba hosting platform.</strong> Buy an <a href="%s" rel="nofollow" target="_blank">Aruba hosting</a> service and migrate your website to use the plugin.', 'aruba-hispeed-cache'), array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array()) )),
6
- esc_url(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_hosting_truck'))
7
- );
8
- ?>
9
- </p>
10
- </div>
1
+ <div id="ahsc-service-error" class="notice notice-error">
2
+ <p>
3
+ <?php
4
+ printf(
5
+ \wp_kses(__('<strong>The Aruba HiSpeed Cache plugin cannot be used because your WordPress website is not hosted on an Aruba hosting platform.</strong> Buy an <a href="%s" rel="nofollow" target="_blank">Aruba hosting</a> service and migrate your website to use the plugin.', 'aruba-hispeed-cache'), array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array()) )),
6
+ esc_url(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_hosting_truck'))
7
+ );
8
+ ?>
9
+ </p>
10
+ </div>
admin/partials/admin-notice-purge-completed.php CHANGED
@@ -1,7 +1,7 @@
1
- <div class="updated">
2
- <p>
3
- <?php
4
- \esc_html_e('Purge completed', 'aruba-hispeed-cache');
5
- ?>
6
- </p>
7
- </div>
1
+ <div class="updated">
2
+ <p>
3
+ <?php
4
+ \esc_html_e('Purge completed', 'aruba-hispeed-cache');
5
+ ?>
6
+ </p>
7
+ </div>
admin/partials/admin-notice-service-unavailable.php CHANGED
@@ -1,10 +1,10 @@
1
-
2
- <div id="ahsc-service-error" class="notice notice-error">
3
- <p>
4
- <?php printf(
5
- \wp_kses(__('<strong>The HiSpeed Cache feature, with which the plugin interfaces, is not available on the server that hosts your website.</strong> To use HiSpeed Cache and the plugin, contact <a href="%s" rel="nofollow" target="_blank">support</a>.', 'aruba-hispeed-cache'), array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array()) )),
6
- esc_url(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_assistance'))
7
- );
8
- ?>
9
- </p>
10
- </div>
1
+
2
+ <div id="ahsc-service-error" class="notice notice-error">
3
+ <p>
4
+ <?php printf(
5
+ \wp_kses(__('<strong>The HiSpeed Cache feature, with which the plugin interfaces, is not available on the server that hosts your website.</strong> To use HiSpeed Cache and the plugin, contact <a href="%s" rel="nofollow" target="_blank">support</a>.', 'aruba-hispeed-cache'), array( 'strong' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array()) )),
6
+ esc_url(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_assistance'))
7
+ );
8
+ ?>
9
+ </p>
10
+ </div>
admin/partials/admin-notice-settings-saved.php CHANGED
@@ -1,7 +1,7 @@
1
- <div class="updated">
2
- <p>
3
- <?php
4
- \esc_html_e('Settings saved.', 'aruba-hispeed-cache');
5
- ?>
6
- </p>
7
- </div>
1
+ <div class="updated">
2
+ <p>
3
+ <?php
4
+ \esc_html_e('Settings saved.', 'aruba-hispeed-cache');
5
+ ?>
6
+ </p>
7
+ </div>
admin/partials/admin-notice-version.php CHANGED
@@ -1,15 +1,15 @@
1
-
2
- <div id="message" class="error">
3
- <p>
4
- <strong>
5
- <?php
6
- /**
7
- * Printf
8
- */
9
- \printf(
10
- \esc_html__('Sorry, Aruba HiSpeed Cache requires WordPress %s or higher.', 'aruba-hispeed-cache'),
11
- \esc_html(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('MINIMUM_WP'))
12
- ); ?>
13
- </strong>
14
- </p>
15
- </div>
1
+
2
+ <div id="message" class="error">
3
+ <p>
4
+ <strong>
5
+ <?php
6
+ /**
7
+ * Printf
8
+ */
9
+ \printf(
10
+ \esc_html__('Sorry, Aruba HiSpeed Cache requires WordPress %s or higher.', 'aruba-hispeed-cache'),
11
+ \esc_html(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('MINIMUM_WP'))
12
+ ); ?>
13
+ </strong>
14
+ </p>
15
+ </div>
aruba-hispeed-cache.php CHANGED
@@ -1,17 +1,18 @@
1
  <?php
2
  /**
3
  * Aruba HiSpeed Cache
 
4
  *
5
  * @category Wordpress-plugin
6
  * @package Aruba-HiSpeed-Cache
7
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
8
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
9
- * @link Null
10
  * @since 1.0.0
11
  *
12
  * @wordpress-plugin
13
  * Plugin Name: Aruba HiSpeed Cache
14
- * Version: 1.1.2
15
  * Plugin URI: https://hosting.aruba.it/wordpress.aspx
16
  * Description: Aruba HiSpeed Cache interfaces directly with an Aruba hosting platform's HiSpeed Cache service and automates its management.
17
  * Author: Aruba.it
1
  <?php
2
  /**
3
  * Aruba HiSpeed Cache
4
+ * php version 5.6
5
  *
6
  * @category Wordpress-plugin
7
  * @package Aruba-HiSpeed-Cache
8
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
9
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
10
+ * @link null
11
  * @since 1.0.0
12
  *
13
  * @wordpress-plugin
14
  * Plugin Name: Aruba HiSpeed Cache
15
+ * Version: 1.2.0
16
  * Plugin URI: https://hosting.aruba.it/wordpress.aspx
17
  * Description: Aruba HiSpeed Cache interfaces directly with an Aruba hosting platform's HiSpeed Cache service and automates its management.
18
  * Author: Aruba.it
includes/ArubaHiSpeedCacheBootstrap.php CHANGED
@@ -17,12 +17,14 @@ use \esc_html;
17
  use \esc_html__;
18
  use \is_multisite;
19
  use \version_compare;
 
20
 
21
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCachei18n;
22
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin;
23
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheLoader;
24
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
25
  use ArubaHiSpeedCache\includes\HiSpeedCacheServiceChecker;
 
26
 
27
  if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
28
  class ArubaHiSpeedCacheBootstrap
@@ -74,6 +76,14 @@ if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
74
 
75
  include_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'HiSpeedCacheServiceChecker.php';
76
 
 
 
 
 
 
 
 
 
77
  $this->loader = new ArubaHiSpeedCacheLoader();
78
  }
79
 
@@ -96,7 +106,7 @@ if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
96
  */
97
  private function _define_admin_hooks()
98
  {
99
- global $aruba_hispeed_cache_admin, $aruba_hispeed_cache_purger;
100
 
101
  $aruba_hispeed_cache_admin = new ArubaHiSpeedCacheAdmin();
102
  $aruba_hispeed_cache_purger = new ArubaHiSpeedCacheWpPurger($aruba_hispeed_cache_admin);
@@ -139,14 +149,56 @@ if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
139
  $this->loader->add_action('delete_term', $aruba_hispeed_cache_purger, 'ahsc_delete_term', 20, 4);
140
 
141
  $this->loader->add_action('check_ajax_referer', $aruba_hispeed_cache_purger, 'ahsc_check_ajax_referer', 20);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
 
144
  $this->loader->add_action('admin_bar_init', $aruba_hispeed_cache_purger, 'ahsc_admin_bar_init');
145
 
146
  //the chech on activation of plugin
147
- //$this->loader->add_action('activated_plugin', $this, 'check_hispeed_cache_services', 20, 1);
148
- //the activation notification in the established cases
149
  $this->loader->add_action('admin_notices', $aruba_hispeed_cache_admin, 'check_hispeed_cache_notices');
 
 
 
150
  }
151
 
152
  /**
@@ -246,3 +298,31 @@ if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
246
  }
247
  }
248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  use \esc_html__;
18
  use \is_multisite;
19
  use \version_compare;
20
+ use \wp_delete_file;
21
 
22
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCachei18n;
23
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin;
24
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheLoader;
25
  use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
26
  use ArubaHiSpeedCache\includes\HiSpeedCacheServiceChecker;
27
+ use ArubaHiSpeedCache\includes\ArubaHispeeCacheLogger as Logger;
28
 
29
  if (! class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheBootstrap')) {
30
  class ArubaHiSpeedCacheBootstrap
76
 
77
  include_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'HiSpeedCacheServiceChecker.php';
78
 
79
+ if (\file_exists(\plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHispeedCacheLogger.php') && WP_DEBUG) {
80
+ include_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHispeedCacheLogger.php';
81
+ } else {
82
+ if (file_exists(\plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'ahscLog.log')) {
83
+ \wp_delete_file(\plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'ahscLog.log');
84
+ }
85
+ }
86
+
87
  $this->loader = new ArubaHiSpeedCacheLoader();
88
  }
89
 
106
  */
107
  private function _define_admin_hooks()
108
  {
109
+ global $aruba_hispeed_cache_admin, $aruba_hispeed_cache_purger, $pagenow;
110
 
111
  $aruba_hispeed_cache_admin = new ArubaHiSpeedCacheAdmin();
112
  $aruba_hispeed_cache_purger = new ArubaHiSpeedCacheWpPurger($aruba_hispeed_cache_admin);
149
  $this->loader->add_action('delete_term', $aruba_hispeed_cache_purger, 'ahsc_delete_term', 20, 4);
150
 
151
  $this->loader->add_action('check_ajax_referer', $aruba_hispeed_cache_purger, 'ahsc_check_ajax_referer', 20);
152
+
153
+ /**
154
+ * If you are on the menu management page, remove the hooks queuing.
155
+ *
156
+ * @since 1.2.0
157
+ */
158
+ if (is_admin() && 'nav-menus.php' === $pagenow) {
159
+ $this->loader->remove_action('edit_term');
160
+ $this->loader->remove_action('transition_post_status');
161
+ $this->loader->add_action('wp_update_nav_menu', $aruba_hispeed_cache_purger, 'ahsc_wp_update_nav_menu', 20, 1);
162
+ }
163
+
164
+ /**
165
+ * FES support.
166
+ *
167
+ * @since 1.2.0
168
+ */
169
+ if (is_admin()) {
170
+ $this->loader->add_action('admin_init', $aruba_hispeed_cache_purger, 'ahsc_deferred_purge_by_transient', 200);
171
+ //
172
+ $this->loader->add_action('check_admin_referer', $aruba_hispeed_cache_purger, 'ahsc_bulk_manager', 20, 2);
173
+
174
+ $this->loader->add_action('post_updated', $aruba_hispeed_cache_purger, 'ahsc_post_updated', 200);
175
+ //$this->loader->add_action('wp_after_insert_post', $aruba_hispeed_cache_purger, 'ahsc_post_updated', 200);
176
+ }
177
+
178
+ /**
179
+ * Plugin actions
180
+ *
181
+ * @since 1.2.0
182
+ */
183
+ $this->loader->add_action('activated_plugin', $aruba_hispeed_cache_purger, 'ahsc_purge_on_plugin_actions', 200, 1);
184
+ $this->loader->add_action('deactivate_plugin', $aruba_hispeed_cache_purger, 'ahsc_purge_on_plugin_actions', 200, 1);
185
+ $this->loader->add_action('delete_plugin', $aruba_hispeed_cache_purger, 'ahsc_purge_on_plugin_actions', 200, 1);
186
+
187
+ /**
188
+ * Theme action
189
+ *
190
+ * @since 1.2.0
191
+ */
192
+ $this->loader->add_action('switch_theme', $aruba_hispeed_cache_purger, 'ahsc_purge_on_theme_actions', 200, 3);
193
  }
194
 
195
  $this->loader->add_action('admin_bar_init', $aruba_hispeed_cache_purger, 'ahsc_admin_bar_init');
196
 
197
  //the chech on activation of plugin
 
 
198
  $this->loader->add_action('admin_notices', $aruba_hispeed_cache_admin, 'check_hispeed_cache_notices');
199
+
200
+ //init
201
+ $this->loader->add_action('admin_init', '\ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs', 'ArubaHiSpeedCache_update_plugins_db');
202
  }
203
 
204
  /**
298
  }
299
  }
300
  }
301
+
302
+
303
+ //--------------
304
+ // Logger function
305
+ //--------------
306
+ function logger($message, string $name = '', string $livel = 'debug')
307
+ {
308
+ if (!class_exists(__NAMESPACE__ . '\ArubaHispeeCacheLogger')) {
309
+ return;
310
+ }
311
+
312
+ switch ($livel) {
313
+ case 'debug':
314
+ Logger::debug($message, $name);
315
+ break;
316
+ case 'info':
317
+ Logger::info($message, $name);
318
+ break;
319
+ case 'warning':
320
+ Logger::warning($message, $name);
321
+ break;
322
+ case 'error':
323
+ Logger::error($message, $name);
324
+ break;
325
+ }
326
+
327
+ return;
328
+ }
includes/ArubaHiSpeedCacheConfigs.php CHANGED
@@ -36,6 +36,7 @@ if (! \class_exists('ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs')) {
36
  /**
37
  * USER_CAP array
38
  */
 
39
  public static $USER_CAP = array(
40
  'Aruba Hispeed Cache | Config',
41
  'Aruba Hispeed Cache | Purge cache'
@@ -49,7 +50,7 @@ if (! \class_exists('ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs')) {
49
  /**
50
  * PLUGIN_VERSION string
51
  */
52
- public static $PLUGIN_VERSION = '1.1.2';
53
 
54
  /**
55
  * MINIMUM_WP string
@@ -205,6 +206,27 @@ if (! \class_exists('ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs')) {
205
  \update_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME, $options);
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  /**
209
  * ArubaHiSpeedCache_deactivate
210
  *
36
  /**
37
  * USER_CAP array
38
  */
39
+ //@todo to remove?
40
  public static $USER_CAP = array(
41
  'Aruba Hispeed Cache | Config',
42
  'Aruba Hispeed Cache | Purge cache'
50
  /**
51
  * PLUGIN_VERSION string
52
  */
53
+ public static $PLUGIN_VERSION = '1.2.0';
54
 
55
  /**
56
  * MINIMUM_WP string
206
  \update_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME, $options);
207
  }
208
 
209
+ /**
210
+ * Undocumented ArubaHiSpeedCache_register_setting
211
+ *
212
+ * @return void
213
+ */
214
+ public static function ArubaHiSpeedCache_update_plugins_db()
215
+ {
216
+ //get the option
217
+ $current_options = \get_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME);
218
+ $new_options = self::ArubaHiSpeedCache_get_default_settings();
219
+
220
+ $option_to_update = array_diff_key($new_options, $current_options);
221
+
222
+ if (!empty($option_to_update)) {
223
+ $option_merge = array_merge($new_options, $current_options);
224
+ \update_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME, $option_merge);
225
+ }
226
+
227
+ return;
228
+ }
229
+
230
  /**
231
  * ArubaHiSpeedCache_deactivate
232
  *
includes/ArubaHiSpeedCacheLoader.php CHANGED
@@ -1,10 +1,14 @@
1
  <?php
2
  /**
 
 
 
3
  * @category Wordpress-plugin
4
  * @package Aruba-HiSpeed-Cache
5
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
6
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
7
  * @link run_aruba_hispeed_cache
 
8
  */
9
 
10
 
@@ -15,109 +19,197 @@ use \Throwable;
15
  use \add_action;
16
  use \add_filter;
17
 
18
- /**
19
- * Undocumented class
20
- */
21
- class ArubaHiSpeedCacheLoader
22
- {
23
- /**
24
- * Actions
25
- *
26
- * @var array
27
- */
28
- protected $actions = array();
29
 
30
  /**
31
- * Filters
32
  *
33
- * @var array
34
- */
35
- protected $filters = array();
36
-
37
- // public function __construct()
38
- // {}
39
-
40
- /**
41
- * Add_action
42
- * Wrap for the wp method add_action
43
  *
44
- * @see https://developer.wordpress.org/reference/functions/add_action/
45
- *
46
- * @param string $hook
47
- * @param object $component
48
- * @param string $callback
49
- * @param integer $priority
50
- * @param integer $accepted_args
51
- * @return void
52
  */
53
- public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
54
  {
55
- $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
56
- }
 
 
 
 
57
 
58
- /**
59
- * Add_filter
60
- *
61
- * Wrap for the wp method add_filter
62
- *
63
- * @see https://developer.wordpress.org/reference/functions/add_filter/
64
- *
65
- * @param string $hook
66
- * @param object $component
67
- * @param string $callback
68
- * @param integer $priority
69
- * @param integer $accepted_args
70
- * @return void
71
- */
72
- public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
73
- {
74
- $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
75
- }
76
 
77
- /**
78
- * Add
79
- *
80
- * Helper method for populating arrays filters and actions
81
- *
82
- * @param string $hooks
83
- * @param string $hook
84
- * @param object $component
85
- * @param string $callback
86
- * @param integer $priority
87
- * @param integer $accepted_args
88
- * @return array
89
- */
90
- private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
91
- {
92
- $hooks[] = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  'hook' => $hook,
94
  'component' => $component,
95
  'callback' => $callback,
96
  'priority' => $priority,
97
  'accepted_args' => $accepted_args,
98
- );
99
 
100
- return $hooks;
101
- }
102
 
103
- /**
104
- * Run
105
- *
106
- * Runner method for queuing actions and filters
107
- *
108
- * @return void
109
- */
110
- public function run()
111
- {
112
- if (!empty($this->filters)) {
113
- foreach ($this->filters as $hook) {
114
- \add_filter($hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args']);
 
 
 
 
 
 
115
  }
116
- }
117
 
118
- if (!empty($this->actions)) {
119
- foreach ($this->actions as $hook) {
120
- \add_action($hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args']);
 
 
 
 
 
 
121
  }
122
  }
123
  }
1
  <?php
2
  /**
3
+ * ArubaHiSpeedCacheLoader.php contains an abstraction of the wordpress hook system.
4
+ * php version 5.6
5
+ *
6
  * @category Wordpress-plugin
7
  * @package Aruba-HiSpeed-Cache
8
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
9
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
10
  * @link run_aruba_hispeed_cache
11
+ * @since 1.0.0
12
  */
13
 
14
 
19
  use \add_action;
20
  use \add_filter;
21
 
22
+ if (!class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheLoader')) {
 
 
 
 
 
 
 
 
 
 
23
 
24
  /**
25
+ * ArubaHiSpeedCacheLoader
26
  *
27
+ * Contains an abstraction of the wordpress hook system
 
 
 
 
 
 
 
 
 
28
  *
29
+ * @category Wordpress-plugin
30
+ * @package Aruba-HiSpeed-Cache
31
+ * @author Aruba Developer <hispeedcache.developer@aruba.it>
32
+ * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
33
+ * @link run_aruba_hispeed_cache
34
+ * @since 1.0.0
 
 
35
  */
36
+ class ArubaHiSpeedCacheLoader
37
  {
38
+ /**
39
+ * Actions
40
+ *
41
+ * @var array
42
+ */
43
+ protected $actions = array();
44
 
45
+ /**
46
+ * Filters
47
+ *
48
+ * @var array
49
+ */
50
+ protected $filters = array();
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ /**
53
+ * Add_action - Wrap for the wp method add_action
54
+ *
55
+ * @param string $hook Hook name
56
+ * @param object $component Calss targhet
57
+ * @param string $callback Function to fire on action
58
+ * @param integer $priority The priority of action
59
+ * @param integer $accepted_args Number of var passed to function.
60
+ *
61
+ * @see https://developer.wordpress.org/reference/functions/add_action/
62
+ *
63
+ * @since 1.0.0
64
+ *
65
+ * @return void
66
+ */
67
+ public function add_action(
68
+ $hook,
69
+ $component,
70
+ $callback,
71
+ $priority = 10,
72
+ $accepted_args = 1
73
+ ) {
74
+ $this->actions = $this->_add(
75
+ $this->actions,
76
+ $hook,
77
+ $component,
78
+ $callback,
79
+ $priority,
80
+ $accepted_args
81
+ );
82
+ }
83
+
84
+ /**
85
+ * Remove_action
86
+ * Removes the action element of the indicated list if it is present.
87
+ *
88
+ * @param string $hook Hook name
89
+ *
90
+ * @since 1.0.3
91
+ *
92
+ * @return void
93
+ */
94
+ public function remove_action($hook)
95
+ {
96
+ if (array_key_exists($hook, $this->actions)) {
97
+ unset($this->actions[$hook]);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Add_filter
103
+ * Wrap for the wp method add_filter
104
+ *
105
+ * @param string $hook Hook name
106
+ * @param object $component Calss targhet
107
+ * @param string $callback Function to fire on action
108
+ * @param integer $priority The priority of action
109
+ * @param integer $accepted_args Number of var passed to function.
110
+ *
111
+ * @see https://developer.wordpress.org/reference/functions/add_filter/
112
+ *
113
+ * @since 1.0.0
114
+ *
115
+ * @return void
116
+ */
117
+ public function add_filter(
118
+ $hook,
119
+ $component,
120
+ $callback,
121
+ $priority = 10,
122
+ $accepted_args = 1
123
+ ) {
124
+ $this->filters = $this->_add(
125
+ $this->filters,
126
+ $hook,
127
+ $component,
128
+ $callback,
129
+ $priority,
130
+ $accepted_args
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Remove_filter
136
+ * Removes the filter element of the indicated list if it is present.
137
+ *
138
+ * @param string $hook Hook name
139
+ *
140
+ * @since 1.0.3
141
+ *
142
+ * @return void
143
+ */
144
+ public function remove_filter($hook)
145
+ {
146
+ if (array_key_exists($hook, $this->filters)) {
147
+ unset($this->filters[$hook]);
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Add
153
+ *
154
+ * Helper method for populating filters and actions arrays
155
+ *
156
+ * @param string $hooks Array targhet
157
+ * @param string $hook Hook name
158
+ * @param object $component Calss
159
+ * @param string $callback Class::methos
160
+ * @param integer $priority The priority
161
+ * @param integer $accepted_args Number of var passed by wp hook
162
+ *
163
+ * @return array
164
+ */
165
+ private function _add(
166
+ $hooks,
167
+ $hook,
168
+ $component,
169
+ $callback,
170
+ $priority,
171
+ $accepted_args
172
+ ) {
173
+ $hooks[] = array(
174
  'hook' => $hook,
175
  'component' => $component,
176
  'callback' => $callback,
177
  'priority' => $priority,
178
  'accepted_args' => $accepted_args,
179
+ );
180
 
181
+ return $hooks;
182
+ }
183
 
184
+ /**
185
+ * Run
186
+ *
187
+ * Runner method for queuing actions and filters
188
+ *
189
+ * @return void
190
+ */
191
+ public function run()
192
+ {
193
+ if (!empty($this->filters)) {
194
+ foreach ($this->filters as $hook) {
195
+ \add_filter(
196
+ $hook['hook'],
197
+ array( $hook['component'], $hook['callback'] ),
198
+ $hook['priority'],
199
+ $hook['accepted_args']
200
+ );
201
+ }
202
  }
 
203
 
204
+ if (!empty($this->actions)) {
205
+ foreach ($this->actions as $hook) {
206
+ \add_action(
207
+ $hook['hook'],
208
+ array( $hook['component'], $hook['callback'] ),
209
+ $hook['priority'],
210
+ $hook['accepted_args']
211
+ );
212
+ }
213
  }
214
  }
215
  }
includes/ArubaHiSpeedCachePurger.php CHANGED
@@ -1,16 +1,27 @@
1
  <?php
2
  /**
 
 
 
3
  * @category Project
4
- * @package Aruba-HiSpeed-Cache
5
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
6
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
 
 
7
  */
8
 
9
-
10
  namespace ArubaHiSpeedCache;
11
 
12
  /**
13
- * Undocumented class
 
 
 
 
 
 
 
14
  */
15
  abstract class ArubaHiSpeedCachePurger
16
  {
@@ -39,7 +50,8 @@ abstract class ArubaHiSpeedCachePurger
39
  /**
40
  * Purge the cache of a single page
41
  *
42
- * @param string $url
 
43
  * @return void
44
  */
45
  abstract public function purgeUrl($url);
@@ -47,7 +59,8 @@ abstract class ArubaHiSpeedCachePurger
47
  /**
48
  * Purge the cache of a list of pages
49
  *
50
- * @param array $urls
 
51
  * @return void
52
  */
53
  abstract public function purgeUrls($urls);
@@ -63,12 +76,11 @@ abstract class ArubaHiSpeedCachePurger
63
  /**
64
  * DoRemoteGet
65
  *
66
- * @param string $path path to purge
67
- * @param string $host the host name for log reason
68
  *
69
  * @return void
70
  */
71
- abstract public function doRemoteGet($path = '/', $host = '');
72
 
73
  /**
74
  * PreparePurgeRequestUri
@@ -96,7 +108,8 @@ abstract class ArubaHiSpeedCachePurger
96
  * 'server_port' => string '8889'
97
  * ];
98
  *
99
- * @param array $configs
 
100
  * @return void
101
  */
102
  public function setPurger($configs)
1
  <?php
2
  /**
3
+ * ArubaHiSpeedCacheWpPurger
4
+ * php version 5.6
5
+ *
6
  * @category Project
7
+ * @package ArubaHiSpeedCachePurger
8
  * @author Aruba Developer <hispeedcache.developer@aruba.it>
9
  * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
10
+ * @link null
11
+ * @since 1.0.0
12
  */
13
 
 
14
  namespace ArubaHiSpeedCache;
15
 
16
  /**
17
+ * ArubaHiSpeedCachePurger
18
+ *
19
+ * @category Project
20
+ * @package ArubaHiSpeedCache
21
+ * @author Aruba Developer <hispeedcache.developer@aruba.it>
22
+ * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
23
+ * @link null
24
+ * @since 1.0.0
25
  */
26
  abstract class ArubaHiSpeedCachePurger
27
  {
50
  /**
51
  * Purge the cache of a single page
52
  *
53
+ * @param string $url The url to purge
54
+ *
55
  * @return void
56
  */
57
  abstract public function purgeUrl($url);
59
  /**
60
  * Purge the cache of a list of pages
61
  *
62
+ * @param array $urls The urls to purge
63
+ *
64
  * @return void
65
  */
66
  abstract public function purgeUrls($urls);
76
  /**
77
  * DoRemoteGet
78
  *
79
+ * @param string $target path to purge
 
80
  *
81
  * @return void
82
  */
83
+ abstract public function doRemoteGet($target = '/');
84
 
85
  /**
86
  * PreparePurgeRequestUri
108
  * 'server_port' => string '8889'
109
  * ];
110
  *
111
+ * @param array $configs The configs
112
+ *
113
  * @return void
114
  */
115
  public function setPurger($configs)
includes/ArubaHiSpeedCacheWpPurger.php CHANGED
@@ -11,8 +11,6 @@
11
  * @since 1.0.0
12
  */
13
 
14
-
15
-
16
  namespace ArubaHiSpeedCache\includes;
17
 
18
  use ArubaHiSpeedCache\ArubaHiSpeedCachePurger;
@@ -46,84 +44,119 @@ use \icl_get_home_url;
46
  use \is_multisite;
47
  use \get_current_blog_id;
48
  use \get_site_url;
49
-
50
  use \str_replace;
51
  use \in_array;
52
  use \array_reverse;
53
  use \implode;
54
  use \filter_input;
55
  use \filter_var;
 
56
  use \sprintf;
57
 
58
- if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
 
 
 
 
 
 
 
 
 
 
 
59
  class ArubaHiSpeedCacheWpPurger extends ArubaHiSpeedCachePurger
60
  {
61
  /**
62
- * Undocumented variable
63
  *
64
- * @var array
 
65
  */
 
66
  private $settings;
67
 
68
  /**
69
- * Undocumented variable
 
 
70
  *
71
- * @var [type]
72
  */
 
73
  private $admin;
74
 
 
 
 
 
 
 
 
 
75
 
76
  /**
77
- * Undocumented function
78
  *
79
- * @param \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs $configs
80
- * @param \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin $aruba_hispeed_cache
81
  */
82
- public function __construct($aruba_hispeed_cache)
83
  {
84
  $this->setPurger(
85
  array(
86
- 'time_out' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_TIME_OUT'),
87
- 'server_host' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_HOST'),
88
- 'server_port' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_PORT')
89
  )
90
  );
91
 
92
- $this->admin = $aruba_hispeed_cache;
93
- $this->settings = $aruba_hispeed_cache->options;
 
94
  }
95
 
96
  /**
97
  * PurgeUrl
98
  * Purge the cache of url passed.
99
  *
100
- * @param string $url
 
101
  * @return void
102
  */
103
  public function purgeUrl($url)
104
  {
105
- $site_url = $this->getParseSiteUrl();
106
- $host = $site_url['host'];
107
 
108
  $_url = \filter_var($url, FILTER_SANITIZE_URL);
109
 
110
- return $this->doRemoteGet($_url, $host);
 
 
 
 
111
  }
112
 
113
  /**
114
  * PurgeUrls
115
  * Purge the cache of urls passed
116
  *
117
- * @param array $urls
 
118
  * @return void
119
  */
120
  public function purgeUrls($urls)
121
  {
122
- $site_url = $this->getParseSiteUrl();
123
- $host = $site_url['host'];
124
 
125
- foreach ($urls as $kurl => $url) {
126
- $this->doRemoteGet($_url, $host);
 
 
 
 
127
  }
128
  }
129
 
@@ -135,22 +168,36 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
135
  */
136
  public function purgeAll()
137
  {
138
- $site_url = $this->getParseSiteUrl();
139
- $host = $site_url['host'];
140
- return $this->doRemoteGet('/', $host);
 
 
 
 
 
141
  }
142
 
143
  /**
144
  * DoRemoteGet
145
  * Make request to purger
146
  *
147
- * @param string $path
148
- * @param string $host
149
  * @return void
150
  */
151
- public function doRemoteGet($path = '/', $host = '')
152
  {
153
- $purgeUrl = $this->preparePurgeRequestUri($path);
 
 
 
 
 
 
 
 
 
154
 
155
  $response = \wp_remote_get(
156
  $purgeUrl,
@@ -184,8 +231,9 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
184
  /**
185
  * ParseUrl
186
  *
187
- * @param string $url
188
- * @return path of url
 
189
  */
190
  public function parseUrl($url)
191
  {
@@ -205,13 +253,14 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
205
  */
206
  public function getHomepage()
207
  {
208
- return \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getSiteHome();
209
  }
210
 
211
  /**
212
  * Is_enable_setting
213
  *
214
- * @param string $setting
 
215
  * @return boolean
216
  */
217
  public function is_enable_setting($setting)
@@ -237,45 +286,59 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
237
  // return;
238
  // }
239
 
240
- $method = \filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
- if ('POST' === $method) {
243
- $action = \filter_input(INPUT_POST, 'aruba_hispeed_cache_action', FILTER_SANITIZE_STRING);
244
- } else {
245
- $action = \filter_input(INPUT_GET, 'aruba_hispeed_cache_action', FILTER_SANITIZE_STRING);
246
- }
247
 
248
  if (empty($action)) {
249
  return;
250
  }
251
 
252
- /**
253
- * @see https://developer.wordpress.org/reference/functions/wp_die/
254
- */
255
  if (! \current_user_can('manage_options')) {
256
  \wp_die(
257
  \sprintf(
258
  '<h3>%s</h3><p>%s</p>',
259
  \_e('An error has occurred.', 'aruba-hispeed-cache'),
260
- \_e('Sorry, you do not have the necessary privileges to edit these options.', 'aruba-hispeed-cache')
261
  ),
262
  '',
263
  array(
264
- 'link_url' => \esc_url(ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_assistance')),
265
- 'link_text' => \_e('Contact customer service', 'aruba-hispeed-cache')
266
  )
267
  );
268
  }
269
 
270
  if ('done' === $action) {
271
- \add_action('admin_notices', array( $this->admin, 'display_notices_purge_initied' ));
272
- \add_action('network_admin_notices', array( $this->admin, 'display_notices_purge_initied' ));
273
  return;
274
  }
275
 
276
- /**
277
- * @see https://developer.wordpress.org/reference/functions/check_admin_referer/
278
- */
279
  \check_admin_referer('aruba_hispeed_cache-purge_all');
280
 
281
  // current url if permalink is set to simple
@@ -286,11 +349,14 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
286
  $current_url = \user_trailingslashit(\home_url($wp->request));
287
  }
288
 
 
 
 
 
 
289
  if (! \is_admin()) {
290
  $action = 'purge_current_page';
291
  $redirect_url = $current_url;
292
- } else {
293
- $redirect_url = \add_query_arg(array( 'aruba_hispeed_cache_action' => 'done' ));
294
  }
295
 
296
  switch ($action) {
@@ -303,22 +369,24 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
303
  $this->purgeAll();
304
  } else {
305
  $parse_url = \wp_parse_url($current_url);
306
- $url_to_purge = (!isset($parse_url['query'])) ? $parse_url['path'] : '/?' . $parse_url['query'];
307
  $this->purgeUrl($url_to_purge);
308
  }
309
 
310
  break;
311
  }
312
 
313
- \wp_redirect(\esc_url_raw($redirect_url));
314
- exit();
 
315
  }
316
 
317
  /**
318
  * Ahsc_check_ajax_referer
319
  * Purge the cache on 'save-sidebar-widgets' ajax request
320
  *
321
- * @param int|string $action
 
322
  * @return void
323
  */
324
  public function ahsc_check_ajax_referer($action)
@@ -328,14 +396,18 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
328
  }
329
 
330
  switch ($action) {
331
-
332
  case 'save-sidebar-widgets':
333
  $this->purgeUrl($this->getHomepage());
 
 
 
 
 
 
 
334
  break;
335
-
336
  default:
337
  break;
338
-
339
  }
340
  }
341
 
@@ -343,9 +415,10 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
343
  * Ahsc_edit_term
344
  * Purge the cache of term item or home on term edit.
345
  *
346
- * @param int $term_id
347
- * @param int $tt_id
348
- * @param string $taxon
 
349
  * @return void
350
  */
351
  public function ahsc_edit_term($term_id, $tt_id, $taxon)
@@ -354,28 +427,44 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
354
  return;
355
  }
356
 
357
- $term_link = \get_term_link($term_id, $taxon);
358
-
359
  if (!$this->is_enable_setting('ahsc_purge_archive_on_edit')) {
360
  return;
361
  }
362
 
363
- $this->purgeUrl($this->parseUrl($term_link));
364
-
365
  if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
366
  $this->purgeUrl($this->parseUrl($this->getHomepage()));
 
 
 
 
 
 
 
 
367
  }
 
 
 
 
 
 
 
 
 
 
 
 
368
  return true;
369
  }
370
 
371
  /**
372
- * ahsc_delete_term
 
 
 
 
 
373
  *
374
- * @param integer $term
375
- * @param integer $tt_id
376
- * @param string $taxonomy
377
- * @param \WP_Term $deleted_term
378
- * @param array $object_ids
379
  * @return void
380
  */
381
  public function ahsc_delete_term($term, $tt_id, $taxonomy, $deleted_term)
@@ -399,23 +488,33 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
399
 
400
  if (! empty($t->rewrite['hierarchical'])) {
401
  $hierarchical_slugs = array();
402
- $ancestors = \get_ancestors($deleted_term->term_id, $taxonomy, 'taxonomy');
403
  foreach ((array) $ancestors as $ancestor) {
404
  $ancestor_term = \get_term($ancestor, $taxonomy);
405
  $hierarchical_slugs[] = $ancestor_term->slug;
406
  }
407
  $hierarchical_slugs = array_reverse($hierarchical_slugs);
408
  $hierarchical_slugs[] = $slug;
409
- $termlink = \str_replace("%$taxonomy%", \implode('/', $hierarchical_slugs), $termlink);
410
  }
411
 
412
  $termlink = \user_trailingslashit($termlink, 'category');
413
 
414
  // purge the term cache.
415
  $this->purgeUrl($termlink);
 
 
 
416
 
417
  if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
418
  $this->purgeUrl($this->parseUrl($this->getHomepage()));
 
 
 
 
 
 
 
419
  }
420
 
421
  return true;
@@ -425,9 +524,10 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
425
  * Ahsc_transition_post_status
426
  * Purge the cache of item or site on transition post status
427
  *
428
- * @param int|string $new_status
429
- * @param int|string $old_status
430
- * @param \WP_Post $post
 
431
  * @return void
432
  */
433
  public function ahsc_transition_post_status($new_status, $old_status, $post)
@@ -436,48 +536,176 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
436
  return;
437
  }
438
 
439
- if ($this->is_enable_setting('ahsc_purge_page_on_mod') || $this->is_enable_setting('ahsc_purge_archive_on_edit')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  $status = array( 'publish', 'future' );
441
 
442
  if (in_array($new_status, $status, true)) {
443
  $post_url = \get_permalink($post->ID);
444
  $this->purgeUrl($this->parseUrl($post_url));
 
 
 
 
 
 
 
 
 
445
 
446
- if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
447
- $this->purgeUrl($this->parseUrl($this->getHomepage()));
448
- }
 
 
 
 
 
 
 
 
 
 
 
 
449
  }
 
 
 
 
 
 
 
 
 
 
 
450
  }
 
451
 
452
- if ($this->is_enable_setting('ahsc_purge_archive_on_del')) {
453
- if ('trash' === $new_status) {
454
- $slug = \str_replace('__trashed', '', $post->post_name);
455
- $post_url = \home_url($slug);
456
- $this->purgeUrl($this->parseUrl($post_url));
 
457
 
458
- if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
459
- $this->purgeUrl($this->parseUrl($this->getHomepage()));
460
- }
 
 
 
 
 
 
 
 
 
 
 
461
  }
462
  }
463
  }
464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  /**
466
  * Ahsc_transition_comment_status
467
  * Purge the cache of item or site on canghe status of the comment
468
  *
469
- * @param int|string $new_status
470
- * @param int|string $old_status
471
- * @param \WP_Comment $comment
 
472
  * @return void
473
  */
474
- public function ahsc_transition_comment_status($new_status, $old_status, $comment)
475
  {
476
  if (!$this->is_enable_setting('ahsc_enable_purge')) {
477
  return;
478
  }
479
 
480
- if ($this->is_enable_setting('ahsc_purge_page_on_new_comment') || $this->is_enable_setting('ahsc_purge_page_on_deleted_comment')) {
481
  $_post_id = $comment->comment_post_ID;
482
 
483
  $post_url = \get_permalink($_post_id);
@@ -486,26 +714,43 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
486
  case 'approved':
487
  if ($this->is_enable_setting('ahsc_purge_page_on_new_comment')) {
488
  $this->purgeUrl($this->parseUrl($post_url));
 
 
 
 
 
 
 
489
  }
490
  break;
491
 
492
  case 'spam':
493
  case 'unapproved':
494
  case 'trash':
495
- if ('approved' === $old_status && $this->is_enable_setting('ahsc_purge_page_on_deleted_comment')) {
496
  $this->purgeUrl($this->parseUrl($post_url));
 
 
 
 
 
 
 
497
  }
498
  break;
499
  }
500
  }
 
 
501
  }
502
 
503
  /**
504
  * Ahsc_wp_insert_comment
505
  * Purge the cache of item on insert the comment
506
  *
507
- * @param integer $id
508
- * @param \WP_Comment $comment
 
509
  * @return void
510
  */
511
  public function ahsc_wp_insert_comment($id, $comment)
@@ -518,14 +763,246 @@ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
518
  return;
519
  }
520
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  $_post_id = $comment->comment_post_ID;
522
  $post_url = \get_permalink($_post_id);
523
 
524
  $this->purgeUrl($this->parseUrl($post_url));
 
 
 
 
 
 
 
 
525
 
526
- if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
 
 
 
 
 
 
 
 
 
 
 
527
  $this->purgeUrl($this->parseUrl($this->getHomepage()));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  }
530
  }
531
  }
11
  * @since 1.0.0
12
  */
13
 
 
 
14
  namespace ArubaHiSpeedCache\includes;
15
 
16
  use ArubaHiSpeedCache\ArubaHiSpeedCachePurger;
44
  use \is_multisite;
45
  use \get_current_blog_id;
46
  use \get_site_url;
47
+ use \wp_is_post_autosave;
48
  use \str_replace;
49
  use \in_array;
50
  use \array_reverse;
51
  use \implode;
52
  use \filter_input;
53
  use \filter_var;
54
+ use PHP_CodeSniffer\Files\DummyFile;
55
  use \sprintf;
56
 
57
+ if (!class_exists(__NAMESPACE__ . '\ArubaHiSpeedCacheWpPurger')) {
58
+
59
+ /**
60
+ * ArubaHiSpeedCacheWpPurger
61
+ *
62
+ * @category ArubaHiSpeedCache
63
+ * @package ArubaHiSpeedCache
64
+ * @author Aruba Developer <hispeedcache.developer@aruba.it>
65
+ * @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
66
+ * @link null
67
+ * @since 1.0.0
68
+ */
69
  class ArubaHiSpeedCacheWpPurger extends ArubaHiSpeedCachePurger
70
  {
71
  /**
72
+ * Settings The plugin settings.
73
  *
74
+ * @since 1.0.0
75
+ * @var array
76
  */
77
+ // phpcs:ignore
78
  private $settings;
79
 
80
  /**
81
+ * Adimin utils
82
+ *
83
+ * @since 1.0.0
84
  *
85
+ * @var \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin
86
  */
87
+ // phpcs:ignore
88
  private $admin;
89
 
90
+ /**
91
+ * Control variable. Check if the cache has already
92
+ * been cleaned by the same process.
93
+ *
94
+ * @var bool
95
+ */
96
+ // phpcs:ignore
97
+ private $is_purged = false;
98
 
99
  /**
100
+ * ArubaHiSpeedCacheWpPurger
101
  *
102
+ * @param \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin $admin admin utils
 
103
  */
104
+ public function __construct($admin)
105
  {
106
  $this->setPurger(
107
  array(
108
+ 'time_out' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_TIME_OUT'), // phpcs:ignore
109
+ 'server_host' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_HOST'), // phpcs:ignore
110
+ 'server_port' => ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs('PURGE_PORT') // phpcs:ignore
111
  )
112
  );
113
 
114
+ //@todo We should think about how to remove this dispensation.
115
+ $this->admin = $admin;
116
+ $this->settings = $admin->options;
117
  }
118
 
119
  /**
120
  * PurgeUrl
121
  * Purge the cache of url passed.
122
  *
123
+ * @param string $url page to purge.
124
+ *
125
  * @return void
126
  */
127
  public function purgeUrl($url)
128
  {
129
+ // $site_url = $this->getParseSiteUrl();
130
+ // $host = $site_url['host'];
131
 
132
  $_url = \filter_var($url, FILTER_SANITIZE_URL);
133
 
134
+ //Logger
135
+ logger('targhet ' . $_url, 'purgeUrl()', 'info');
136
+ ///Logger
137
+
138
+ return $this->doRemoteGet($_url);
139
  }
140
 
141
  /**
142
  * PurgeUrls
143
  * Purge the cache of urls passed
144
  *
145
+ * @param array $urls urls to purge
146
+ *
147
  * @return void
148
  */
149
  public function purgeUrls($urls)
150
  {
151
+ // $site_url = $this->getParseSiteUrl();
152
+ // $host = $site_url['host'];
153
 
154
+ foreach ($urls as $url) {
155
+ $this->doRemoteGet($url);
156
+
157
+ //Logger
158
+ logger('targhet ' . $url, 'purgeUrls()', 'info');
159
+ ///Logger
160
  }
161
  }
162
 
168
  */
169
  public function purgeAll()
170
  {
171
+ // $site_url = $this->getParseSiteUrl();
172
+ // $host = $site_url['host'];
173
+
174
+ //Logger
175
+ logger('targhet /', 'purgeAll()', 'info');
176
+ ///Logger
177
+
178
+ return $this->doRemoteGet('/');
179
  }
180
 
181
  /**
182
  * DoRemoteGet
183
  * Make request to purger
184
  *
185
+ * @param string $target The subdomine of page to purge
186
+ *
187
  * @return void
188
  */
189
+ public function doRemoteGet($target = '/')
190
  {
191
+ $purgeUrl = $this->preparePurgeRequestUri($target);
192
+
193
+ $blog_id = null;
194
+
195
+ if (!is_multisite()) {
196
+ $blog_id = \get_current_blog_id();
197
+ }
198
+
199
+ $host = \wp_parse_url(\get_site_url($blog_id));
200
+ $host = $host['host'];
201
 
202
  $response = \wp_remote_get(
203
  $purgeUrl,
231
  /**
232
  * ParseUrl
233
  *
234
+ * @param string $url Url to parse
235
+ *
236
+ * @return string
237
  */
238
  public function parseUrl($url)
239
  {
253
  */
254
  public function getHomepage()
255
  {
256
+ return \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getSiteHome(); // phpcs:ignore
257
  }
258
 
259
  /**
260
  * Is_enable_setting
261
  *
262
+ * @param string $setting Setting to check
263
+ *
264
  * @return boolean
265
  */
266
  public function is_enable_setting($setting)
286
  // return;
287
  // }
288
 
289
+ // $method = \filter_input(
290
+ // INPUT_SERVER,
291
+ // 'REQUEST_METHOD',
292
+ // FILTER_SANITIZE_URL
293
+ // );
294
+
295
+ // if ('POST' === $method) {
296
+ // $action = \filter_input(
297
+ // INPUT_POST,
298
+ // 'aruba_hispeed_cache_action',
299
+ // FILTER_SANITIZE_URL
300
+ // );
301
+ // } else {
302
+ // $action = \filter_input(
303
+ // INPUT_GET,
304
+ // 'aruba_hispeed_cache_action',
305
+ // FILTER_SANITIZE_URL
306
+ // );
307
+ // }
308
 
309
+ $action = \filter_input(
310
+ INPUT_GET,
311
+ 'aruba_hispeed_cache_action',
312
+ FILTER_SANITIZE_URL
313
+ );
314
 
315
  if (empty($action)) {
316
  return;
317
  }
318
 
319
+ //@see https://developer.wordpress.org/reference/functions/wp_die/
 
 
320
  if (! \current_user_can('manage_options')) {
321
  \wp_die(
322
  \sprintf(
323
  '<h3>%s</h3><p>%s</p>',
324
  \_e('An error has occurred.', 'aruba-hispeed-cache'),
325
+ \_e('Sorry, you do not have the necessary privileges to edit these options.', 'aruba-hispeed-cache') // phpcs:ignore
326
  ),
327
  '',
328
  array(
329
+ 'link_url' => \esc_url(\ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs::getLocalizedLink('link_assistance')), // phpcs:ignore
330
+ 'link_text' => \_e('Contact customer service', 'aruba-hispeed-cache') // phpcs:ignore
331
  )
332
  );
333
  }
334
 
335
  if ('done' === $action) {
336
+ \add_action('admin_notices', array( $this->admin, 'display_notices_purge_initied' )); // phpcs:ignore
337
+ \add_action('network_admin_notices', array( $this->admin, 'display_notices_purge_initied' )); // phpcs:ignore
338
  return;
339
  }
340
 
341
+ //@see https://developer.wordpress.org/reference/functions/check_admin_referer/
 
 
342
  \check_admin_referer('aruba_hispeed_cache-purge_all');
343
 
344
  // current url if permalink is set to simple
349
  $current_url = \user_trailingslashit(\home_url($wp->request));
350
  }
351
 
352
+ //add done
353
+ $redirect_url = \add_query_arg(
354
+ array( 'aruba_hispeed_cache_action' => 'done' )
355
+ );
356
+
357
  if (! \is_admin()) {
358
  $action = 'purge_current_page';
359
  $redirect_url = $current_url;
 
 
360
  }
361
 
362
  switch ($action) {
369
  $this->purgeAll();
370
  } else {
371
  $parse_url = \wp_parse_url($current_url);
372
+ $url_to_purge = (!isset($parse_url['query'])) ? $parse_url['path'] : '/?' . $parse_url['query']; // phpcs:ignore
373
  $this->purgeUrl($url_to_purge);
374
  }
375
 
376
  break;
377
  }
378
 
379
+ if (\wp_redirect(\esc_url_raw($redirect_url))) {
380
+ exit;
381
+ }
382
  }
383
 
384
  /**
385
  * Ahsc_check_ajax_referer
386
  * Purge the cache on 'save-sidebar-widgets' ajax request
387
  *
388
+ * @param int|string $action Action name
389
+ *
390
  * @return void
391
  */
392
  public function ahsc_check_ajax_referer($action)
396
  }
397
 
398
  switch ($action) {
 
399
  case 'save-sidebar-widgets':
400
  $this->purgeUrl($this->getHomepage());
401
+ //Logger
402
+ logger(
403
+ 'targhet ' . $this->getHomepage(),
404
+ 'hook:check_ajax_referer',
405
+ 'info'
406
+ );
407
+ ///Logger
408
  break;
 
409
  default:
410
  break;
 
411
  }
412
  }
413
 
415
  * Ahsc_edit_term
416
  * Purge the cache of term item or home on term edit.
417
  *
418
+ * @param int $term_id The term id
419
+ * @param int $tt_id The taxnomi id
420
+ * @param string $taxon Taxon
421
+ *
422
  * @return void
423
  */
424
  public function ahsc_edit_term($term_id, $tt_id, $taxon)
427
  return;
428
  }
429
 
 
 
430
  if (!$this->is_enable_setting('ahsc_purge_archive_on_edit')) {
431
  return;
432
  }
433
 
 
 
434
  if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
435
  $this->purgeUrl($this->parseUrl($this->getHomepage()));
436
+ //Logger
437
+ logger(
438
+ 'targhet ' . $this->parseUrl($this->getHomepage()),
439
+ 'hook:edit_term::home',
440
+ 'info'
441
+ );
442
+ ///Logger
443
+ return;
444
  }
445
+
446
+ $term_link = \get_term_link($term_id, $taxon);
447
+
448
+ $this->purgeUrl($this->parseUrl($term_link));
449
+ //Logger
450
+ logger(
451
+ 'targhet ' . $this->parseUrl($term_link),
452
+ 'hook:edit_term',
453
+ 'info'
454
+ );
455
+ ///Logger
456
+
457
  return true;
458
  }
459
 
460
  /**
461
+ * Ahsc_delete_term
462
+ *
463
+ * @param integer $term Term
464
+ * @param integer $tt_id Taxon id
465
+ * @param string $taxonomy Taxon
466
+ * @param \WP_Term $deleted_term Delete Taxon
467
  *
 
 
 
 
 
468
  * @return void
469
  */
470
  public function ahsc_delete_term($term, $tt_id, $taxonomy, $deleted_term)
488
 
489
  if (! empty($t->rewrite['hierarchical'])) {
490
  $hierarchical_slugs = array();
491
+ $ancestors = \get_ancestors($deleted_term->term_id, $taxonomy, 'taxonomy'); // phpcs:ignore
492
  foreach ((array) $ancestors as $ancestor) {
493
  $ancestor_term = \get_term($ancestor, $taxonomy);
494
  $hierarchical_slugs[] = $ancestor_term->slug;
495
  }
496
  $hierarchical_slugs = array_reverse($hierarchical_slugs);
497
  $hierarchical_slugs[] = $slug;
498
+ $termlink = \str_replace("%$taxonomy%", \implode('/', $hierarchical_slugs), $termlink); // phpcs:ignore
499
  }
500
 
501
  $termlink = \user_trailingslashit($termlink, 'category');
502
 
503
  // purge the term cache.
504
  $this->purgeUrl($termlink);
505
+ //Logger
506
+ logger('targhet ' . $termlink, 'hook:delete_term', 'info');
507
+ ///Logger
508
 
509
  if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
510
  $this->purgeUrl($this->parseUrl($this->getHomepage()));
511
+ //Logger
512
+ logger(
513
+ 'targhet ' . $this->parseUrl($this->getHomepage()),
514
+ 'hook:delete_term::home',
515
+ 'info'
516
+ );
517
+ ///Logger
518
  }
519
 
520
  return true;
524
  * Ahsc_transition_post_status
525
  * Purge the cache of item or site on transition post status
526
  *
527
+ * @param int|string $new_status new status
528
+ * @param int|string $old_status old status
529
+ * @param \WP_Post $post Post object
530
+ *
531
  * @return void
532
  */
533
  public function ahsc_transition_post_status($new_status, $old_status, $post)
536
  return;
537
  }
538
 
539
+ /**
540
+ * Prevent multiple calls
541
+ */
542
+ if ($this->is_purged) {
543
+ return;
544
+ }
545
+
546
+ $this->is_purged = true;
547
+ // Prevent multiple calls
548
+
549
+ /**
550
+ * Disable on autosave
551
+ */
552
+ if (\wp_is_post_autosave($post)) {
553
+ return;
554
+ }
555
+
556
+ /**
557
+ * For json call
558
+ */
559
+ if (\wp_is_json_request()) {
560
+ // $is_multisite = \is_multisite();
561
+ // $do_purge = ($is_multisite) ? \get_site_transient('ahsc_do_purge') : \get_transient('ahsc_do_purge'); // phpcs:ignore
562
+
563
+ // if (!$do_purge) {
564
+ // logger('transint non presente presente lo imposto', 'deffer');
565
+ // if ($is_multisite) {
566
+ // \set_site_transient('ahsc_do_purge', true, 15);
567
+ // } else {
568
+ // \set_transient('ahsc_do_purge', true, 15);
569
+ // }
570
+ // }
571
+
572
+ // logger('transint presente', 'deffer');
573
+ return;
574
+ }
575
+
576
+ /**
577
+ * Edit item
578
+ */
579
+ if ($this->is_enable_setting('ahsc_purge_page_on_mod') || $this->is_enable_setting('ahsc_purge_archive_on_edit')) { // phpcs:ignore
580
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
581
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
582
+ //Logger
583
+ logger(
584
+ 'targhet ' . $this->parseUrl($this->getHomepage()),
585
+ 'hook:transition_post_status:edit::home',
586
+ 'info'
587
+ );
588
+ ///Logger
589
+ return;
590
+ }
591
+
592
+
593
  $status = array( 'publish', 'future' );
594
 
595
  if (in_array($new_status, $status, true)) {
596
  $post_url = \get_permalink($post->ID);
597
  $this->purgeUrl($this->parseUrl($post_url));
598
+ //Logger
599
+ logger(
600
+ 'targhet ' . $this->parseUrl($post_url),
601
+ 'hook:Iif:transition_post_status',
602
+ 'info'
603
+ );
604
+ ///Logger
605
+ }
606
+ }
607
 
608
+ /**
609
+ * Move item to trash
610
+ */
611
+ if ($this->is_enable_setting('ahsc_purge_archive_on_del') && 'trash' === $new_status) { // phpcs:ignore
612
+
613
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
614
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
615
+ //Logger
616
+ logger(
617
+ 'targhet ' . $this->parseUrl($this->getHomepage()),
618
+ 'hook:transition_post_status:del::home',
619
+ 'info'
620
+ );
621
+ ///Logger
622
+ return;
623
  }
624
+
625
+ $slug = \str_replace('__trashed', '', $post->post_name);
626
+ $post_url = \home_url($slug);
627
+ $this->purgeUrl($this->parseUrl($post_url));
628
+ //Logger
629
+ logger(
630
+ 'targhet ' . $this->parseUrl($post_url),
631
+ 'hook:transition_post_status::trashPost',
632
+ 'info'
633
+ );
634
+ ///Logger
635
  }
636