Aruba HiSpeed Cache - Version 1.0.0

Version Description

  • First stable version released.

=

Download this release

Release Info

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

Version 1.0.0

admin/css/aruba-hispeed-cache-admin.css ADDED
@@ -0,0 +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
+ }
admin/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence.
admin/js/aruba-hispeed-cache-admin.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(
9
+ "form#post_form > div > div"
10
+ ).children;
11
+
12
+ if (
13
+ form_parts[1].style.display === "none" &&
14
+ form_parts[2].style.display === "none"
15
+ ) {
16
+ form_parts[1].style.removeProperty("display");
17
+ form_parts[2].style.removeProperty("display");
18
+ } else {
19
+ form_parts[1].style.display = "none";
20
+ form_parts[2].style.display = "none";
21
+ }
22
+ });
23
+ };
24
+
25
+ document.addEventListener("DOMContentLoaded", function (event) {
26
+ const purge_btn = document.querySelector("a#purgeall");
27
+
28
+ purge_btn.addEventListener("click", (e) => {
29
+ if (confirm(aruba_hispeed_cache.purge_confirm_string) === true) {
30
+ // Continue submitting form.
31
+ } else {
32
+ e.preventDefault();
33
+ }
34
+ });
35
+
36
+ ahsc_show_option();
37
+ });
38
+ })();
admin/partials/admin-display.php ADDED
@@ -0,0 +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
+ include 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-general-options.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @see ArubaHiSpeedCache\includes\_settings_manager function
4
+ */
5
+ $aruba_hispeed_cache_settings = $this->_settings_manager();
6
+
7
+ ?>
8
+
9
+ <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
10
+
11
+ <div class="ahsc-options-wrapper">
12
+ <div class="inside">
13
+ <table class="form-table ahsc-table">
14
+ <?php foreach ($this->_form_fields() as $fieldSets_key => $fieldSets_data): ?>
15
+ <?php if (isset($fieldSets_data['title'])) : ?>
16
+ </table>
17
+ <h2 class="title"><?php echo esc_html($fieldSets_data['title']); ?>
18
+ </h2>
19
+ <table class="form-table ahsc-table">
20
+ <?php continue; ?>
21
+ <?php endif; ?>
22
+
23
+ <tr class="<?php echo esc_html($fieldSets_key); ?>">
24
+ <th scope="row">
25
+ <?php echo esc_html($fieldSets_data['th']); ?>
26
+ <small><?php echo (isset($fieldSets_data['small'])) ? esc_html($fieldSets_data['small']) : '' ?></small>
27
+ </th>
28
+ <td>
29
+ <fieldset>
30
+ <legend class="screen-reader-text">
31
+ <span><?php echo esc_html($fieldSets_data['legend_text']); ?></span>
32
+ </legend>
33
+ <?php foreach ($fieldSets_data['fields'] as $field_key => $field): ?>
34
+ <label
35
+ for="<?php echo esc_html($field_key); ?>">
36
+ <input type="hidden"
37
+ name="<?php echo esc_html($field['name']); ?>"
38
+ value="0" />
39
+ <input
40
+ type="<?php echo esc_html($field['type']) ?>"
41
+ value="1"
42
+ name="<?php echo esc_html($field['name']); ?>"
43
+ id="<?php esc_html_e($field['id']); ?>"
44
+ <?php \checked($aruba_hispeed_cache_settings[$field_key], 1); ?>
45
+ />
46
+ <?php _e($field['lable_text']); ?>
47
+ </label>
48
+ <?php endforeach; ?>
49
+ </fieldset>
50
+ </td>
51
+ </tr>
52
+
53
+ <?php endforeach;?>
54
+ </table>
55
+ </div>
56
+ </div>
57
+
58
+ <input type="hidden" name="smart_http_expire_form_nonce"
59
+ value="<?php _e($this->_generate_settings_form_nonce()); ?>" />
60
+
61
+ </form> <!-- End of #post_form -->
62
+
63
+ <div class="ahsc-actions-wrapper">
64
+ <table class="form-table ahst-table">
65
+ <tr>
66
+ <th></th>
67
+ <td>
68
+ <?php
69
+ \submit_button(__('Save changes', 'aruba-hispeed-cache'), 'primary', 'smart_http_expire_save', false, array('form' => 'post_form'));
70
+ ?>
71
+ <a id="purgeall"
72
+ href="<?php echo \esc_url($this->_generate_purge_nonce()); ?>"
73
+ class="button button-primary">
74
+ <?php \esc_html_e('Purge entire cache', 'aruba-hispeed-cache'); ?>
75
+ </a>
76
+ </td>
77
+ </tr>
78
+ </table>
79
+ </div>
admin/partials/admin-notice-purge-completed.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
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-settings-saved.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="message" class="error">
2
+ <p>
3
+ <strong>
4
+ <?php
5
+ /**
6
+ * Printf
7
+ */
8
+ \printf(
9
+ \esc_html__('Sorry, Aruba HiSpeed Cache requires WordPress %s or higher.', 'aruba-hispeed-cache'),
10
+ \esc_html($this->config::MINIMUM_WP)
11
+ ); ?>
12
+ </strong>
13
+ </p>
14
+ </div>
aruba-hispeed-cache.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 run_aruba_hispeed_cache
10
+ *
11
+ * @wordpress-plugin
12
+ * Plugin Name: Aruba HiSpeed Cache
13
+ * Version: 1.0.0
14
+ * Plugin URI: https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx
15
+ * Description: Purges the cache whenever a post is edited or published.
16
+ * Author: Aruba.it
17
+ * Author URI: https://www.aruba.it/
18
+ * Text Domain: aruba-hispeed-cache
19
+ * License: GPL v2
20
+ * Requires at least: 5.7
21
+ * Tested up to: 6.0
22
+ * Requires PHP: 7.4
23
+ *
24
+ *
25
+ * This program is free software: you can redistribute it and/or modify
26
+ * it under the terms of the GNU General Public License as published by
27
+ * the Free Software Foundation, either version 2 of the License, or
28
+ * (at your option) any later version.
29
+ *
30
+ * This program is distributed in the hope that it will be useful,
31
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
+ * GNU General Public License for more details.
34
+ *
35
+ * You should have received a copy of the GNU General Public License
36
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
37
+ */
38
+
39
+ declare(strict_types=1);
40
+
41
+ namespace ArubaHiSpeedCache;
42
+
43
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
44
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheBootstrap;
45
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCache_WP_CLI_Command;
46
+
47
+ use \register_activation_hook;
48
+ use \register_deactivation_hook;
49
+ use \defined;
50
+ use \WP_CLI;
51
+
52
+ if (!defined('WPINC')) {
53
+ die;
54
+ }
55
+
56
+ /**
57
+ * Require class-aruba-hispeed-cache-config.php to boostrasp the confing of plugin
58
+ * execution of the method ArubaHiSpeedCache_set_default_constant for the generation
59
+ * of the environment variables
60
+ */
61
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' .DIRECTORY_SEPARATOR. 'ArubaHiSpeedCacheConfigs.php';
62
+ ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_set_default_constant(__FILE__);
63
+
64
+ /**
65
+ * Adding methods to "activate" and "deactivate" hooks
66
+ */
67
+ \register_activation_hook(ARUBA_HISPEED_CACHE_FILE, function () {
68
+ ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_activate();
69
+ });
70
+
71
+ \register_deactivation_hook(ARUBA_HISPEED_CACHE_FILE, function () {
72
+ ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_deactivate();
73
+ });
74
+
75
+ if (!function_exists(__NAMESPACE__ . 'run_aruba_hispeed_cache')) {
76
+ include_once ARUBA_HISPEED_CACHE_BASEPATH . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheBootstrap.php';
77
+
78
+ /**
79
+ * run_aruba_hispeed_cache
80
+ *
81
+ * @return void
82
+ */
83
+ function run_aruba_hispeed_cache()
84
+ {
85
+ global $aruba_hispeed_cache;
86
+
87
+ $aruba_hispeed_cache = new ArubaHiSpeedCacheBootstrap();
88
+ $aruba_hispeed_cache->run();
89
+ }
90
+
91
+ /**
92
+ * Runner
93
+ */
94
+ run_aruba_hispeed_cache();
95
+ }
includes/ArubaHiSpeedCacheAdmin.php ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
14
+ use \WP_Admin_Bar;
15
+
16
+ use \array_unshift;
17
+ use \sprintf;
18
+
19
+ use \wp_enqueue_style;
20
+ use \wp_enqueue_script;
21
+ use \wp_localize_script;
22
+ use \esc_html__;
23
+ use \__;
24
+ use \is_multisite;
25
+ use \is_network_admin;
26
+ use \add_submenu_page;
27
+ use \network_admin_url;
28
+ use \get_site_option;
29
+ use \wp_parse_args;
30
+ use \current_user_can;
31
+ use \is_admin;
32
+ use \add_query_arg;
33
+ use \wp_nonce_url;
34
+ use \wp_is_post_revision;
35
+ use \update_site_option;
36
+ use \wp_die;
37
+ use \wp_redirect;
38
+ use \esc_url_raw;
39
+ use \do_action;
40
+ use \check_admin_referer;
41
+ use \user_trailingslashit;
42
+ use \home_url;
43
+ use \wp_verify_nonce;
44
+ use \checked;
45
+ use \wp_kses;
46
+
47
+ if (! \class_exists('ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin')) {
48
+
49
+ /**
50
+ * ArubaHiSpeedCacheAdmin
51
+ */
52
+ class ArubaHiSpeedCacheAdmin
53
+ {
54
+
55
+ /**
56
+ * $options
57
+ *
58
+ * @var array
59
+ */
60
+ public array $options;
61
+
62
+ public ArubaHiSpeedCacheConfigs $configs;
63
+
64
+ /**
65
+ * ArubaHiSpeedCacheAdmin\__construct
66
+ *
67
+ * @param mixed $name
68
+ */
69
+ public function __construct(ArubaHiSpeedCacheConfigs $configs)
70
+ {
71
+ $this->configs = $configs;
72
+ $this->options = $this->aruba_hispeed_cache_settings();
73
+ }
74
+
75
+ /**
76
+ * Enqueue_styles
77
+ *
78
+ * @param string $hook the currente acp hookname
79
+ * @return void
80
+ */
81
+ public function enqueue_styles(string $hook)
82
+ {
83
+ if ('settings_page_aruba-hispeed-cache' !== $hook) {
84
+ return;
85
+ }
86
+
87
+ \wp_enqueue_style(
88
+ $this->configs::PLUGIN_NAME,
89
+ ARUBA_HISPEED_CACHE_BASEURL . 'admin/css/aruba-hispeed-cache-admin.css',
90
+ array(),
91
+ $this->configs::PLUGIN_VERSION
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Enqueue_scripts
97
+ *
98
+ * @param string $hook the currente acp hookname
99
+ * @return void
100
+ */
101
+ public function enqueue_scripts(string $hook)
102
+ {
103
+ if ('settings_page_aruba-hispeed-cache' !== $hook) {
104
+ return;
105
+ }
106
+
107
+ \wp_enqueue_script(
108
+ $this->configs::PLUGIN_NAME,
109
+ ARUBA_HISPEED_CACHE_BASEURL . 'admin/js/aruba-hispeed-cache-admin.js',
110
+ array(),
111
+ $this->configs::PLUGIN_VERSION
112
+ );
113
+
114
+ \wp_localize_script($this->configs::PLUGIN_NAME, 'aruba_hispeed_cache', [
115
+ 'purge_confirm_string' => \esc_html__('You are about to purge the entire cache. Do you want to continue?', 'aruba-hispeed-cache'),
116
+ ]);
117
+ }
118
+
119
+ /**
120
+ * Aruba_hispeed_cache_admin_menu
121
+ *
122
+ * @return void
123
+ */
124
+ public function aruba_hispeed_cache_admin_menu()
125
+ {
126
+ if (\is_multisite()) {
127
+ \add_submenu_page(
128
+ 'settings.php',
129
+ __('Aruba HiSpeed Cache', 'aruba-hispeed-cache'),
130
+ __('Aruba HiSpeed Cache', 'aruba-hispeed-cache'),
131
+ 'manage_options',
132
+ 'aruba-hispeed-cache',
133
+ array( &$this, 'aruba_hispeed_cache_setting_page_cb' )
134
+ );
135
+ } else {
136
+ \add_submenu_page(
137
+ 'options-general.php',
138
+ __('Aruba HiSpeed Cache', 'aruba-hispeed-cache'),
139
+ __('Aruba HiSpeed Cache', 'aruba-hispeed-cache'),
140
+ 'manage_options',
141
+ 'aruba-hispeed-cache',
142
+ array( &$this, 'aruba_hispeed_cache_setting_page_cb' )
143
+ );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Undocumented function
149
+ *
150
+ * @return void
151
+ */
152
+ public function aruba_hispeed_cache_setting_page_cb()
153
+ {
154
+ include ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-display.php';
155
+ }
156
+
157
+ /**
158
+ * Aruba_hispeed_cache_toolbar_purge_link
159
+ *
160
+ * @param WP_Admin_Bar $wp_admin_bar
161
+ * @return void
162
+ */
163
+ public function aruba_hispeed_cache_toolbar_purge_link(WP_Admin_Bar $wp_admin_bar)
164
+ {
165
+ if (! \current_user_can('manage_options')) {
166
+ return;
167
+ }
168
+
169
+ $aruba_hispeed_cache_urls = 'current-url';
170
+ $link_title = __('Purge the page cache', 'aruba-hispeed-cache');
171
+
172
+ if (\is_admin()) {
173
+ $aruba_hispeed_cache_urls = 'all';
174
+ $link_title = __('Purge Cache', 'aruba-hispeed-cache');
175
+ }
176
+
177
+ $purge_url = \add_query_arg(
178
+ array(
179
+ 'aruba_hispeed_cache_action' => 'purge',
180
+ 'aruba_hispeed_cache_urls' => $aruba_hispeed_cache_urls,
181
+ )
182
+ );
183
+
184
+ $nonced_url = \wp_nonce_url($purge_url, 'aruba_hispeed_cache-purge_all');
185
+
186
+ $wp_admin_bar->add_menu(
187
+ array(
188
+ 'id' => 'aruba-hispeed-cache-purge-all',
189
+ 'title' => $link_title,
190
+ 'href' => $nonced_url,
191
+ 'meta' => array( 'title' => $link_title ),
192
+ )
193
+ );
194
+ }
195
+
196
+ /**
197
+ * Aruba_hispeed_cache_settings
198
+ *
199
+ * @return array $data
200
+ */
201
+ public function aruba_hispeed_cache_settings(): array
202
+ {
203
+ $options = \get_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME);
204
+
205
+ $data = \wp_parse_args(
206
+ $options,
207
+ $this->configs::ArubaHiSpeedCache_get_default_settings()
208
+ );
209
+
210
+ return $data;
211
+ }
212
+
213
+ /**
214
+ * Aruba_hispeed_cache_settings_link
215
+ *
216
+ * @param array $links
217
+ * @return array $links
218
+ */
219
+ public function aruba_hispeed_cache_settings_link(array $links): array
220
+ {
221
+ $setting_page = (!\is_network_admin()) ? 'options-general.php' : 'settings.php';
222
+
223
+ $settings_link = \sprintf(
224
+ '<a href="%s">%s</a>',
225
+ \network_admin_url($setting_page . '?page=aruba-hispeed-cache'),
226
+ \__('Settings', 'aruba-hispeed-cache')
227
+ );
228
+
229
+ \array_unshift($links, $settings_link);
230
+
231
+ return $links;
232
+ }
233
+
234
+ /**
235
+ * Display_notices
236
+ *
237
+ * @return void
238
+ */
239
+ public function display_notices_settings_saved()
240
+ {
241
+ require_once ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-notice-settings-saved.php';
242
+ }
243
+
244
+ /**
245
+ * Display_notices
246
+ *
247
+ * @return void
248
+ */
249
+ public function display_notices_purge_initied()
250
+ {
251
+ require_once ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-notice-purge-completed.php';
252
+ }
253
+
254
+ /**
255
+ * _generate_purge_nonce
256
+ *
257
+ * @return wp_nonce_url
258
+ */
259
+ private function _generate_purge_nonce()
260
+ {
261
+ $purge_url = \add_query_arg(
262
+ [
263
+ 'aruba_hispeed_cache_action' => 'purge',
264
+ 'aruba_hispeed_cache_urls' => 'all',
265
+ ]
266
+ );
267
+ return \wp_nonce_url($purge_url, 'aruba_hispeed_cache-purge_all');
268
+ }
269
+
270
+ /**
271
+ * private _generate_settings_form_nonce
272
+ *
273
+ * @return string wp_create_nonce
274
+ */
275
+ private function _generate_settings_form_nonce()
276
+ {
277
+ return \wp_create_nonce('smart-http-expire-form-nonce');
278
+ }
279
+
280
+ /**
281
+ * private _save_settings
282
+ *
283
+ * @return void
284
+ */
285
+ private function _save_settings()
286
+ {
287
+ //get the current option stored in db.
288
+ $current_options = $this->aruba_hispeed_cache_settings();
289
+
290
+ //prepare the filter to escape the inputs
291
+ $form_options = \array_merge($this->configs::OPTIONS, ['is_submit', 'smart_http_expire_save', 'smart_http_expire_form_nonce']);
292
+ $form_options = \array_fill_keys($form_options, FILTER_SANITIZE_STRING);
293
+
294
+ /**
295
+ * @see https://www.php.net/manual/en/function.filter-input-array.php
296
+ */
297
+ $all_inputs = filter_input_array(INPUT_POST, $form_options, false);
298
+
299
+ if (isset($all_inputs['smart_http_expire_save']) &&
300
+ \wp_verify_nonce($all_inputs['smart_http_expire_form_nonce'], 'smart-http-expire-form-nonce')) {
301
+ unset($all_inputs['smart_http_expire_save']);
302
+ unset($all_inputs['smart_http_expire_form_nonce']);
303
+ unset($all_inputs['is_submit']);
304
+
305
+ $new_settings = \wp_parse_args(
306
+ $all_inputs,
307
+ $current_options
308
+ );
309
+
310
+ if (\update_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME, $new_settings)) {
311
+ // \add_action('admin_notices', array( &$this, 'display_notices_settings_saved' ));
312
+ // \add_action('network_admin_notices', array( &$this, 'display_notices_settings_saved' ));
313
+ $this->display_notices_settings_saved();
314
+ }
315
+ }
316
+ }
317
+
318
+ /**
319
+ * private _settings_manager()
320
+ *
321
+ * @return array settings
322
+ */
323
+ private function _settings_manager()
324
+ {
325
+ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
326
+ $this->_save_settings();
327
+ }
328
+ return $this->aruba_hispeed_cache_settings();
329
+ }
330
+
331
+ /**
332
+ * private function _form_fields
333
+ *
334
+ * @return array $fieldsSets
335
+ */
336
+ private function _form_fields()
337
+ {
338
+ $fieldsSets = [];
339
+
340
+ $fieldsSets['ahsc_enable_purge'] = [
341
+ 'th' => \esc_html__('Purging options', 'aruba-hispeed-cache'),
342
+ 'legend_text' => \esc_html__('Purging options', 'aruba-hispeed-cache'),
343
+ 'fields' => [
344
+ 'ahsc_enable_purge' => [
345
+ 'type' => 'checkbox',
346
+ 'id' => 'ahsc_enable_purge',
347
+ 'name' => 'ahsc_enable_purge',
348
+ 'lable_for' => 'ahsc_enable_purge',
349
+ 'lable_text' => \esc_html__('Enable automatic purge', 'aruba-hispeed-cache'),
350
+ ]
351
+ ],
352
+ ];
353
+
354
+ /**
355
+ * @see https://developer.wordpress.org/reference/functions/is_network_admin/
356
+ * True if inside WordPress network administration pages
357
+ *
358
+ * @see https://developer.wordpress.org/reference/functions/is_multisite/
359
+ * True if Multisite is enabled, false otherwise.
360
+ */
361
+ if (! (!\is_network_admin() && \is_multisite())) {
362
+ if ($this->aruba_hispeed_cache_settings()['ahsc_enable_purge'] != 0) {
363
+
364
+ //infos string
365
+ $fieldsSets['ahsc_info'] = [
366
+ 'title' => \esc_html__('Automatically purge entire cache when:', 'aruba-hispeed-cache'),
367
+ ];
368
+
369
+ //fieldsSets ahsc_purge_homepage
370
+ $fieldsSets['ahsc_purge_homepage'] = [
371
+ 'th' => \esc_html__('Home page:', 'aruba-hispeed-cache'),
372
+ 'legend_text' => \esc_html__('Home page:', 'aruba-hispeed-cache'),
373
+ 'fields' => [
374
+ 'ahsc_purge_homepage_on_edit' => [
375
+ 'type' => 'checkbox',
376
+ 'id' => 'ahsc_purge_homepage_on_edit',
377
+ 'name' => 'ahsc_purge_homepage_on_edit',
378
+ 'lable_for' => 'ahsc_purge_homepage_on_edit',
379
+ 'lable_text' => \wp_kses(__('a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
380
+ ],
381
+ 'ahsc_purge_homepage_on_del' => [
382
+ 'type' => 'checkbox',
383
+ 'id' => 'ahsc_purge_homepage_on_del',
384
+ 'name' => 'ahsc_purge_homepage_on_del',
385
+ 'lable_for' => 'ahsc_purge_homepage_on_del',
386
+ 'lable_text' => wp_kses(__('a <strong>published post</strong> (or page/custom post) is <strong>cancelled</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
387
+ ],
388
+ ]
389
+ ];
390
+
391
+ //fieldsSets ahsc_purge_page
392
+ $fieldsSets['ahsc_purge_page'] = [
393
+ 'th' => \esc_html__('Post/page/custom post type:', 'aruba-hispeed-cache'),
394
+ 'legend_text' => \esc_html__('Post/page/custom post type:', 'aruba-hispeed-cache'),
395
+ 'fields' => [
396
+ 'ahsc_purge_page_on_mod' => [
397
+ 'type' => 'checkbox',
398
+ 'id' => 'ahsc_purge_page_on_mod',
399
+ 'name' => 'ahsc_purge_page_on_mod',
400
+ 'lable_for' => 'ahsc_purge_page_on_mod',
401
+ 'lable_text' => \wp_kses(__('a <strong>post</strong> is <strong>published</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
402
+ ],
403
+ 'ahsc_purge_page_on_new_comment' => [
404
+ 'type' => 'checkbox',
405
+ 'id' => 'ahsc_purge_page_on_new_comment',
406
+ 'name' => 'ahsc_purge_page_on_new_comment',
407
+ 'lable_for' => 'ahsc_purge_page_on_new_comment',
408
+ 'lable_text' => \wp_kses(__('a <strong>comment</strong> is <strong>approved/published</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
409
+ ],
410
+ 'ahsc_purge_page_on_deleted_comment' => [
411
+ 'type' => 'checkbox',
412
+ 'id' => 'ahsc_purge_page_on_deleted_comment',
413
+ 'name' => 'ahsc_purge_page_on_deleted_comment',
414
+ 'lable_for' => 'ahsc_purge_page_on_deleted_comment',
415
+ 'lable_text' => \wp_kses(__('a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
416
+ ]
417
+ ]
418
+ ];
419
+
420
+ //fieldsSets ahsc_purge_archive
421
+ $fieldsSets['ahsc_purge_archive'] = [
422
+ 'th' => \esc_html__('Archives:', 'aruba-hispeed-cache'),
423
+ 'small' => \esc_html__('(date, category, tag, author, custom taxonomies)', 'aruba-hispeed-cache'),
424
+ 'legend_text' => \esc_html__('Archives:', 'aruba-hispeed-cache'),
425
+ 'fields' => [
426
+ 'ahsc_purge_archive_on_edit' => [
427
+ 'type' => 'checkbox',
428
+ 'id' => 'ahsc_purge_archive_on_edit',
429
+ 'name' => 'ahsc_purge_archive_on_edit',
430
+ 'lable_for' => 'ahsc_purge_archive_on_edit',
431
+ 'lable_text' => \wp_kses(__('a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
432
+ ],
433
+ 'ahsc_purge_archive_on_del' => [
434
+ 'type' => 'checkbox',
435
+ 'id' => 'ahsc_purge_archive_on_del',
436
+ 'name' => 'ahsc_purge_archive_on_del',
437
+ 'lable_for' => 'ahsc_purge_archive_on_del',
438
+ 'lable_text' => \wp_kses(__('a <strong>published post</strong> (or page/custom post) is <strong>cancelled</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
439
+ ]
440
+ ]
441
+ ];
442
+
443
+ //fieldsSets ahsc_purge_archive_on_comment
444
+ $fieldsSets['ahsc_purge_archive_on_comment'] = [
445
+ 'th' => \esc_html__('Comments:', 'aruba-hispeed-cache'),
446
+ 'legend_text' => \esc_html__('Comments:', 'aruba-hispeed-cache'),
447
+ 'fields' => [
448
+ 'ahsc_purge_archive_on_new_comment' => [
449
+ 'type' => 'checkbox',
450
+ 'id' => 'ahsc_purge_archive_on_new_comment',
451
+ 'name' => 'ahsc_purge_archive_on_new_comment',
452
+ 'lable_for' => 'ahsc_purge_archive_on_new_comment',
453
+ 'lable_text' => \wp_kses(__('a <strong>comment</strong> is <strong>approved/published</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
454
+ ],
455
+ 'ahsc_purge_archive_on_deleted_comment' => [
456
+ 'type' => 'checkbox',
457
+ 'id' => 'ahsc_purge_archive_on_deleted_comment',
458
+ 'name' => 'ahsc_purge_archive_on_deleted_comment',
459
+ 'lable_for' => 'ahsc_purge_archive_on_deleted_comment',
460
+ 'lable_text' => \wp_kses(__('a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'aruba-hispeed-cache'), array( 'strong' => array() ))
461
+ ]
462
+ ]
463
+ ];
464
+ }
465
+ }
466
+
467
+ return $fieldsSets;
468
+ }
469
+ }
470
+ }
includes/ArubaHiSpeedCacheBootstrap.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
14
+
15
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin;
16
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCachei18n;
17
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheLoader;
18
+ use ArubaHiSpeedCache\includes\FastCGIPurger;
19
+
20
+ use \version_compare;
21
+ use \esc_html__;
22
+ use \esc_html;
23
+ use \is_multisite;
24
+
25
+ /**
26
+ * Aruba_HiSpeed_Cache
27
+ */
28
+ class ArubaHiSpeedCacheBootstrap
29
+ {
30
+
31
+ /**
32
+ * Undocumented variable
33
+ *
34
+ * @var [type]
35
+ */
36
+ protected $loader;
37
+
38
+ /**
39
+ * Configs
40
+ *
41
+ * @var [type]
42
+ */
43
+ protected $config;
44
+
45
+ /**
46
+ * Undocumented function
47
+ */
48
+ public function __construct()
49
+ {
50
+ $this->config = $this->getConfigs();
51
+
52
+ if (! $this->required_wp_version()) {
53
+ return;
54
+ }
55
+
56
+ $this->_load_dependencies();
57
+ $this->_set_locale();
58
+ $this->_define_admin_hooks();
59
+ }
60
+
61
+ /**
62
+ * Load_dependencies
63
+ *
64
+ * @see ArubaHiSpeedCache_get_dependencies
65
+ * @return void
66
+ */
67
+ private function _load_dependencies()
68
+ {
69
+ require_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheLoader.php';
70
+ require_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHiSpeedCachei18n.php';
71
+ require_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheAdmin.php';
72
+ require_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHiSpeedCachePurger.php';
73
+ require_once \plugin_dir_path(ARUBA_HISPEED_CACHE_FILE) . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheWpPurger.php';
74
+
75
+ $this->loader = new ArubaHiSpeedCacheLoader();
76
+ }
77
+
78
+ /**
79
+ * Set_locale
80
+ *
81
+ * @return void
82
+ */
83
+ private function _set_locale()
84
+ {
85
+ $plugin_i18n = new ArubaHiSpeedCachei18n($this->config::PLUGIN_NAME, ARUBA_HISPEED_CACHE_BASENAME);
86
+
87
+ $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
88
+ }
89
+
90
+ /**
91
+ * Define_admin_hooks
92
+ *
93
+ * @return void
94
+ */
95
+ private function _define_admin_hooks()
96
+ {
97
+ global $aruba_hispeed_cache_admin, $aruba_hispeed_cache_purger;
98
+
99
+ $aruba_hispeed_cache_admin = new ArubaHiSpeedCacheAdmin($this->config);
100
+ $aruba_hispeed_cache_purger = new ArubaHiSpeedCacheWpPurger($this->config, $aruba_hispeed_cache_admin);
101
+
102
+ $this->loader->add_action('admin_enqueue_scripts', $aruba_hispeed_cache_admin, 'enqueue_styles');
103
+ $this->loader->add_action('admin_enqueue_scripts', $aruba_hispeed_cache_admin, 'enqueue_scripts');
104
+
105
+ if (\is_multisite()) {
106
+ $this->loader->add_action('network_admin_menu', $aruba_hispeed_cache_admin, 'aruba_hispeed_cache_admin_menu');
107
+ $this->loader->add_filter('network_admin_plugin_action_links_' . ARUBA_HISPEED_CACHE_BASENAME, $aruba_hispeed_cache_admin, 'aruba_hispeed_cache_settings_link');
108
+ } else {
109
+ $this->loader->add_action('admin_menu', $aruba_hispeed_cache_admin, 'aruba_hispeed_cache_admin_menu');
110
+ $this->loader->add_filter('plugin_action_links_' . ARUBA_HISPEED_CACHE_BASENAME, $aruba_hispeed_cache_admin, 'aruba_hispeed_cache_settings_link');
111
+ }
112
+
113
+ /**
114
+ * I check if the 'ahsc_enable_purge' option is activated and in this case I add the hooks
115
+ */
116
+ if (! empty($aruba_hispeed_cache_admin->options['ahsc_enable_purge']) && ARUBA_HISPEED_CACHE_PLUGIN) {
117
+ $this->loader->add_action('admin_bar_menu', $aruba_hispeed_cache_admin, 'aruba_hispeed_cache_toolbar_purge_link', 100);
118
+
119
+ // Add actions to purge.
120
+ $this->loader->add_action('wp_insert_comment', $aruba_hispeed_cache_purger, 'ahsc_wp_insert_comment', 200, 2);
121
+ $this->loader->add_action('transition_comment_status', $aruba_hispeed_cache_purger, 'ahsc_transition_comment_status', 200, 3);
122
+
123
+ $this->loader->add_action('transition_post_status', $aruba_hispeed_cache_purger, 'ahsc_transition_post_status', 20, 3);
124
+
125
+ $this->loader->add_action('edit_term', $aruba_hispeed_cache_purger, 'ahsc_edit_term', 20, 3);
126
+ $this->loader->add_action('delete_term', $aruba_hispeed_cache_purger, 'ahsc_delete_term', 20, 5);
127
+
128
+ $this->loader->add_action('check_ajax_referer', $aruba_hispeed_cache_purger, 'ahsc_check_ajax_referer', 20);
129
+ }
130
+
131
+ $this->loader->add_action('admin_bar_init', $aruba_hispeed_cache_purger, 'ahsc_admin_bar_init');
132
+ }
133
+
134
+ /**
135
+ * Run
136
+ *
137
+ * Wrap for the Aruba_HiSpeed_Cache_Loader/run method
138
+ *
139
+ * @see Aruba_HiSpeed_Cache_Loader/run
140
+ * @return void
141
+ */
142
+ public function run()
143
+ {
144
+ $this->loader->run();
145
+ }
146
+
147
+ /**
148
+ * Get_loader
149
+ *
150
+ * @return ArubaHiSpeedCache\Aruba_HiSpeed_Cache_Loader
151
+ */
152
+ public function get_loader()
153
+ {
154
+ return $this->loader;
155
+ }
156
+
157
+ /**
158
+ * Undocumented function
159
+ *
160
+ * @return void
161
+ */
162
+ private function getConfigs()
163
+ {
164
+ return ArubaHiSpeedCacheConfigs::ArubaHiSpeedCache_getConfigs();
165
+ }
166
+
167
+ /**
168
+ * Required_wp_version
169
+ * Checking the currently installed version and the minimum required version.
170
+ *
171
+ * @return bool
172
+ */
173
+ public function required_wp_version(): bool
174
+ {
175
+ global $wp_version;
176
+
177
+ if (!\version_compare($wp_version, $this->config::MINIMUM_WP, '>=')) {
178
+ \add_action('admin_notices', array( &$this, 'display_notices' ));
179
+ \add_action('network_admin_notices', array( &$this, 'display_notices' ));
180
+ return false;
181
+ }
182
+
183
+ return true;
184
+ }
185
+
186
+ /**
187
+ * Display_notices
188
+ * Adds the error message in case the function required_wp_version returns false
189
+ *
190
+ * @return void
191
+ */
192
+ public function display_notices()
193
+ {
194
+ include_once ARUBA_HISPEED_CACHE_BASEPATH . 'admin' .AHSC_DS. 'partials' .AHSC_DS. 'admin-notice-version.php';
195
+ }
196
+ }
includes/ArubaHiSpeedCacheConfigs.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use defined;
14
+ use define;
15
+ use plugin_dir_path;
16
+ use current_user_can;
17
+ use update_site_option;
18
+ use get_role;
19
+
20
+ if (! \class_exists('ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs')) {
21
+ /**
22
+ * ArubaHiSpeedCacheConfigs
23
+ */
24
+
25
+ class ArubaHiSpeedCacheConfigs
26
+ {
27
+ /**
28
+ * USER_CAP array
29
+ */
30
+ const USER_CAP = [
31
+ 'Aruba Hispeed Cache | Config',
32
+ 'Aruba Hispeed Cache | Purge cache'
33
+ ];
34
+
35
+ /**
36
+ * PLUGIN_NAME string
37
+ */
38
+ const PLUGIN_NAME = 'aruba-hispeed-cache';
39
+
40
+ /**
41
+ * PLUGIN_VERSION string
42
+ */
43
+ const PLUGIN_VERSION = '1.0.0';
44
+
45
+ /**
46
+ * MINIMUM_WP string
47
+ */
48
+ const MINIMUM_WP = '5.7';
49
+
50
+ /**
51
+ * OPTIONS array
52
+ */
53
+ const OPTIONS = [
54
+ 'ahsc_enable_purge',
55
+ 'ahsc_purge_homepage_on_edit',
56
+ 'ahsc_purge_homepage_on_del',
57
+ 'ahsc_purge_archive_on_edit',
58
+ 'ahsc_purge_archive_on_del',
59
+ 'ahsc_purge_archive_on_new_comment',
60
+ 'ahsc_purge_archive_on_deleted_comment',
61
+ 'ahsc_purge_page_on_mod',
62
+ 'ahsc_purge_page_on_new_comment',
63
+ 'ahsc_purge_page_on_deleted_comment'
64
+ ];
65
+
66
+ /**
67
+ * PURGE_HOST string
68
+ * The host colled to purge the cache
69
+ */
70
+ const PURGE_HOST = '127.0.0.1';
71
+
72
+ /**
73
+ * PURGE_PORT string
74
+ * the port of host.
75
+ */
76
+ const PURGE_PORT = '8889';
77
+
78
+ /**
79
+ * PURGE_TIME_OUT int
80
+ */
81
+ const PURGE_TIME_OUT = 5;
82
+
83
+ /**
84
+ * ArubaHiSpeedCache_set_default_constant
85
+ *
86
+ * @param string $file __FILE__ for the root directory of Aruba HiSpeed Cache .
87
+ * @param string $prefix
88
+ * @return void
89
+ */
90
+ public static function ArubaHiSpeedCache_set_default_constant(string $file, string $prefix = '')
91
+ {
92
+ $plugin_dir_path = \plugin_dir_path($file);
93
+
94
+ $default_constants = [
95
+ 'ARUBA_HISPEED_CACHE_PLUGIN' => true,
96
+ 'ARUBA_HISPEED_CACHE_FILE' => $file,
97
+ 'ARUBA_HISPEED_CACHE_BASEPATH' => $plugin_dir_path,
98
+ 'ARUBA_HISPEED_CACHE_BASEURL' => \plugin_dir_url($file),
99
+ 'ARUBA_HISPEED_CACHE_BASENAME' => \plugin_basename($file),
100
+ 'ARUBA_HISPEED_CACHE_OPTIONS_NAME' => 'aruba_hispeed_cache_options',
101
+ 'HOME_URL' => \get_home_url(null, '/'),
102
+ 'AHSC_DS' => DIRECTORY_SEPARATOR,
103
+ ];
104
+
105
+ foreach ($default_constants as $name => $value) {
106
+ if (! \defined($name)) {
107
+ \define($name, $value);
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * ArubaHiSpeedCache_activate
114
+ *
115
+ * @return void
116
+ */
117
+ public static function ArubaHiSpeedCache_activate()
118
+ {
119
+ if (! \current_user_can('activate_plugins')) {
120
+ return;
121
+ }
122
+
123
+ $role = \get_role('administrator');
124
+
125
+ if (empty($role)) {
126
+ \update_site_option(
127
+ 'wp_aruba_hispeed_cache_init_check',
128
+ __('Sorry, you need to be an administrator to use Aruba HiSpeed Cache.', 'aruba-hispeed-cache')
129
+ );
130
+ return;
131
+ }
132
+
133
+ //add the user cap to admin user
134
+ foreach (self::USER_CAP as $cap) {
135
+ $role->add_cap($cap);
136
+ }
137
+
138
+ //get the option
139
+ $options = \get_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME);
140
+
141
+ if (! $options) {
142
+ $options = self::ArubaHiSpeedCache_get_default_settings();
143
+ }
144
+
145
+ \update_site_option(ARUBA_HISPEED_CACHE_OPTIONS_NAME, $options);
146
+ }
147
+
148
+ /**
149
+ * ArubaHiSpeedCache_get_dependencies
150
+ *
151
+ * @return array list of files
152
+ */
153
+ // public static function ArubaHiSpeedCache_get_dependencies(string $plugin_dir_path = '')
154
+ // {
155
+ // return [
156
+ // $plugin_dir_path . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheLoader.php',
157
+ // $plugin_dir_path . 'includes' .AHSC_DS. 'ArubaHiSpeedCachei18n.php',
158
+ // $plugin_dir_path . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheAdmin.php',
159
+ // $plugin_dir_path . 'includes' .AHSC_DS. 'ArubaHiSpeedCachePurger.php',
160
+ // $plugin_dir_path . 'includes' .AHSC_DS. 'ArubaHiSpeedCacheWpPurger.php'
161
+ // ];
162
+ // }
163
+
164
+ /**
165
+ * ArubaHiSpeedCache_deactivate
166
+ *
167
+ * @return void
168
+ */
169
+ public static function ArubaHiSpeedCache_deactivate()
170
+ {
171
+ if (! \current_user_can('activate_plugins')) {
172
+ return;
173
+ }
174
+
175
+ $role = \get_role('administrator');
176
+
177
+ foreach (self::USER_CAP as $cap) {
178
+ $role->remove_cap($cap);
179
+ }
180
+ }
181
+
182
+ /**
183
+ * ArubaHiSpeedCache_get_default_settings
184
+ *
185
+ * @return array $default_settings
186
+ */
187
+ public static function ArubaHiSpeedCache_get_default_settings()
188
+ {
189
+ $dafault_value = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
190
+
191
+ return \array_combine(self::OPTIONS, $dafault_value);
192
+ }
193
+
194
+ /**
195
+ * ArubaHiSpeedCache_getConfigs
196
+ *
197
+ * @return object self
198
+ */
199
+ public static function ArubaHiSpeedCache_getConfigs()
200
+ {
201
+ return new self;
202
+ }
203
+ }
204
+ }
includes/ArubaHiSpeedCacheLoader.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use \Exception;
14
+ 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 = [];
29
+
30
+ /**
31
+ * Filters
32
+ *
33
+ * @var array
34
+ */
35
+ protected $filters = [];
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(string $hook, object $component, string $callback, int $priority = 10, int $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(string $hook, object $component, string $callback, int $priority = 10, int $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(array $hooks, string $hook, object $component, string $callback, int $priority, int $accepted_args): array
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
+ }
124
+ }
includes/ArubaHiSpeedCachePurger.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
9
+
10
+ namespace ArubaHiSpeedCache;
11
+
12
+ /**
13
+ * Undocumented class
14
+ */
15
+ abstract class ArubaHiSpeedCachePurger
16
+ {
17
+
18
+ /**
19
+ * $servr_host for the requst
20
+ *
21
+ * @var string
22
+ */
23
+ protected string $serverHost;
24
+
25
+ /**
26
+ * $server_port for the request
27
+ *
28
+ * @var string
29
+ */
30
+ protected string $serverPort;
31
+
32
+ /**
33
+ * $time_out of request
34
+ *
35
+ * @var integer
36
+ */
37
+ protected int $timeOut;
38
+
39
+ /**
40
+ * Purge the cache of a single page
41
+ *
42
+ * @param string $url
43
+ * @return void
44
+ */
45
+ abstract public function purgeUrl(string $url);
46
+
47
+ /**
48
+ * Purge the cache of a list of pages
49
+ *
50
+ * @param array $urls
51
+ * @return void
52
+ */
53
+ abstract public function purgeUrls(array $urls);
54
+
55
+ /**
56
+ * Purge the alla chace of site
57
+ *
58
+ * @return void
59
+ */
60
+ abstract public function purgeAll();
61
+
62
+
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(string $path = '/', string $host = '');
72
+
73
+ /**
74
+ * PreparePurgeRequestUri
75
+ *
76
+ * @param string $url Url to prepare
77
+ *
78
+ * @return string for the purge request
79
+ */
80
+ public function preparePurgeRequestUri(string $url)
81
+ {
82
+ return \sprintf(
83
+ "http://%s:%s/purge%s",
84
+ $this->getServerHost(),
85
+ $this->getServerPort(),
86
+ filter_var($url, FILTER_SANITIZE_URL)
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Undocumented function
92
+ *
93
+ * $config [
94
+ * 'time_out' => int 5;
95
+ * 'server_host' => string '127.0.0.1'
96
+ * 'server_port' => string '8889'
97
+ * ];
98
+ *
99
+ * @param array $configs
100
+ * @return void
101
+ */
102
+ public function setPurger(array $configs)
103
+ {
104
+ $this->setTimeOut($configs['time_out']);
105
+ $this->setServerHost($configs['server_host']);
106
+ $this->setServerPort($configs['server_port']);
107
+ }
108
+
109
+ /**
110
+ * Get undocumented variable
111
+ *
112
+ * @return integer
113
+ */
114
+ public function getTimeOut()
115
+ {
116
+ return $this->timeOut;
117
+ }
118
+
119
+ /**
120
+ * Set undocumented variable
121
+ *
122
+ * @param integer $timeOut Undocumented variable
123
+ *
124
+ * @return self
125
+ */
126
+ public function setTimeOut($timeOut)
127
+ {
128
+ $this->timeOut = $timeOut;
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Get undocumented variable
135
+ *
136
+ * @return string
137
+ */
138
+ public function getServerPort()
139
+ {
140
+ return $this->serverPort;
141
+ }
142
+
143
+ /**
144
+ * Set undocumented variable
145
+ *
146
+ * @param string $serverPort Undocumented variable
147
+ *
148
+ * @return self
149
+ */
150
+ public function setServerPort(string $serverPort)
151
+ {
152
+ $this->serverPort = $serverPort;
153
+
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Get undocumented variable
159
+ *
160
+ * @return string
161
+ */
162
+ public function getServerHost()
163
+ {
164
+ return $this->serverHost;
165
+ }
166
+
167
+ /**
168
+ * Set undocumented variable
169
+ *
170
+ * @param string $serverHost Undocumented variable
171
+ *
172
+ * @return self
173
+ */
174
+ public function setServerHost(string $serverHost)
175
+ {
176
+ $this->serverHost = $serverHost;
177
+
178
+ return $this;
179
+ }
180
+ }
includes/ArubaHiSpeedCacheWpPurger.php ADDED
@@ -0,0 +1,514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use ArubaHiSpeedCache\ArubaHiSpeedCachePurger;
14
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheAdmin;
15
+ use ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs;
16
+ use \WP_Comment;
17
+ use \WP_Post;
18
+ use \WP_Term;
19
+
20
+ use \get_permalink;
21
+ use \wp_get_attachment_url;
22
+ use \home_url;
23
+ use \get_taxonomy;
24
+ use \get_ancestors;
25
+ use \get_term;
26
+ use \user_trailingslashit;
27
+ use \trailingslashit;
28
+ use \get_term_link;
29
+ use \current_filter;
30
+ use \current_user_can;
31
+ use \wp_die;
32
+ use \__;
33
+ use \add_action;
34
+ use \check_admin_referer;
35
+ use \add_query_arg;
36
+ use \is_admin;
37
+ use \wp_parse_url;
38
+ use \wp_redirect;
39
+ use \esc_url_raw;
40
+ use \icl_get_home_url;
41
+ use \is_multisite;
42
+ use \get_current_blog_id;
43
+ use \get_site_url;
44
+
45
+ use \str_replace;
46
+ use \in_array;
47
+ use \array_reverse;
48
+ use \implode;
49
+ use \filter_input;
50
+ use \filter_var;
51
+ use \sprintf;
52
+
53
+ if (!class_exists(__NAMESPACE__ . 'ArubaHiSpeedCacheWpPurger')) {
54
+ class ArubaHiSpeedCacheWpPurger extends ArubaHiSpeedCachePurger
55
+ {
56
+ private array $settings;
57
+
58
+ private $admin;
59
+
60
+ /**
61
+ * Undocumented function
62
+ *
63
+ * @param \ArubaHiSpeedCache\includes\ArubaHiSpeedCacheConfigs $configs
64
+ */
65
+ public function __construct(ArubaHiSpeedCacheConfigs $configs, ArubaHiSpeedCacheAdmin $aruba_hispeed_cache)
66
+ {
67
+ $this->setPurger([
68
+ 'time_out' => $configs::PURGE_TIME_OUT,
69
+ 'server_host' => $configs::PURGE_HOST,
70
+ 'server_port' => $configs::PURGE_PORT
71
+ ]);
72
+
73
+ $this->admin = $aruba_hispeed_cache;
74
+ $this->settings = $aruba_hispeed_cache->options;
75
+ }
76
+
77
+ /**
78
+ * PurgeUrl
79
+ * Purge the cache of url passed.
80
+ *
81
+ * @param string $url
82
+ * @return void
83
+ */
84
+ public function purgeUrl(string $url)
85
+ {
86
+ $site_url = $this->getParseSiteUrl();
87
+ $host = $site_url['host'];
88
+
89
+ $_url = \filter_var($url, FILTER_SANITIZE_URL);
90
+
91
+ return $this->doRemoteGet($_url, $host);
92
+ }
93
+
94
+ /**
95
+ * PurgeUrls
96
+ * Purge the cache of urls passed
97
+ *
98
+ * @param array $urls
99
+ * @return void
100
+ */
101
+ public function purgeUrls(array $urls)
102
+ {
103
+ $site_url = $this->getParseSiteUrl();
104
+ $host = $site_url['host'];
105
+
106
+ foreach ($urls as $kurl => $url) {
107
+ $this->doRemoteGet($_url, $host);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * PurgeAll
113
+ * Purge all site
114
+ *
115
+ * @return void
116
+ */
117
+ public function purgeAll()
118
+ {
119
+ $site_url = $this->getParseSiteUrl();
120
+ $host = $site_url['host'];
121
+ return $this->doRemoteGet('/', $host);
122
+ }
123
+
124
+ /**
125
+ * DoRemoteGet
126
+ * Make request to purger
127
+ *
128
+ * @param string $path
129
+ * @param string $host
130
+ * @return void
131
+ */
132
+ public function doRemoteGet(string $path = '/', string $host = '')
133
+ {
134
+ $purgeUrl = $this->preparePurgeRequestUri($path);
135
+
136
+ $response = \wp_remote_get(
137
+ $purgeUrl,
138
+ array(
139
+ 'timeout' => $this->timeOut,
140
+ 'headers' => array(
141
+ 'Host' => $host
142
+ )
143
+ )
144
+ );
145
+
146
+ return $response;
147
+ }
148
+
149
+ /**
150
+ * GetParseSiteUrl
151
+ *
152
+ * @return void
153
+ */
154
+ public function getParseSiteUrl()
155
+ {
156
+ $blog_id = null;
157
+
158
+ if (!is_multisite()) {
159
+ $blog_id = \get_current_blog_id();
160
+ }
161
+
162
+ return \wp_parse_url(\get_site_url($blog_id));
163
+ }
164
+
165
+ /**
166
+ * ParseUrl
167
+ *
168
+ * @param string $url
169
+ * @return path of url
170
+ */
171
+ public function parseUrl(string $url)
172
+ {
173
+ if (!filter_var($url, FILTER_VALIDATE_URL)) {
174
+ return ($url[0] != '/') ? '/' . $url : $url;
175
+ }
176
+
177
+ return \trailingslashit(\wp_parse_url($url)['path']);
178
+ }
179
+
180
+ /**
181
+ * _purge_homepage
182
+ *
183
+ * @return boolean true
184
+ */
185
+ public function getHomepage(): string
186
+ {
187
+
188
+ // WPML installetd?.
189
+ if (\function_exists('icl_get_home_url')) {
190
+ return \trailingslashit(\icl_get_home_url());
191
+ }
192
+
193
+ return \trailingslashit(\home_url());
194
+ }
195
+
196
+ /**
197
+ * Is_enable_setting
198
+ *
199
+ * @param string $setting
200
+ * @return boolean
201
+ */
202
+ public function is_enable_setting(string $setting)
203
+ {
204
+ return (bool) $this->settings[$setting];
205
+ }
206
+
207
+ //--------------
208
+ // HOOKs SECTION
209
+ //--------------
210
+
211
+ /**
212
+ * Ahsc_admin_bar_init
213
+ * Purge the cache
214
+ *
215
+ * @return void
216
+ */
217
+ public function ahsc_admin_bar_init()
218
+ {
219
+ global $wp;
220
+
221
+ // if (!$this->is_enable_setting('ahsc_enable_purge')) {
222
+ // return;
223
+ // }
224
+
225
+ $method = \filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING);
226
+
227
+ if ('POST' === $method) {
228
+ $action = \filter_input(INPUT_POST, 'aruba_hispeed_cache_action', FILTER_SANITIZE_STRING);
229
+ } else {
230
+ $action = \filter_input(INPUT_GET, 'aruba_hispeed_cache_action', FILTER_SANITIZE_STRING);
231
+ }
232
+
233
+ if (empty($action)) {
234
+ return;
235
+ }
236
+
237
+ /**
238
+ * @see https://developer.wordpress.org/reference/functions/wp_die/
239
+ */
240
+ if (! \current_user_can('manage_options')) {
241
+ \wp_die(
242
+ \sprintf(
243
+ '<h3>%s</h3><p>%s</p>',
244
+ \_e('An error has occurred.', 'aruba-hispeed-cache'),
245
+ \_e('Sorry, you do not have the necessary privileges to edit these options.', 'aruba-hispeed-cache')
246
+ ),
247
+ '',
248
+ [
249
+ 'link_url' => \esc_url('https://assistenza.aruba.it/en/home.aspx'),
250
+ 'link_text' => \_e('Contact customer service', 'aruba-hispeed-cache')
251
+ ]
252
+ );
253
+ }
254
+
255
+ if ('done' === $action) {
256
+ \add_action('admin_notices', array( $this->admin, 'display_notices_purge_initied' ));
257
+ \add_action('network_admin_notices', array( $this->admin, 'display_notices_purge_initied' ));
258
+ return;
259
+ }
260
+
261
+ /**
262
+ * @see https://developer.wordpress.org/reference/functions/check_admin_referer/
263
+ */
264
+ \check_admin_referer('aruba_hispeed_cache-purge_all');
265
+
266
+ // current url if permalink is set to simple
267
+ $current_url = \add_query_arg($wp->query_vars, \home_url());
268
+
269
+ // if permalink is custom.
270
+ if (!empty($wp->request)) {
271
+ $current_url = \user_trailingslashit(\home_url($wp->request));
272
+ }
273
+
274
+ if (! \is_admin()) {
275
+ $action = 'purge_current_page';
276
+ $redirect_url = $current_url;
277
+ } else {
278
+ $redirect_url = \add_query_arg(array( 'aruba_hispeed_cache_action' => 'done' ));
279
+ }
280
+
281
+ switch ($action) {
282
+ case 'purge':
283
+ $this->purgeAll();
284
+ break;
285
+ case 'purge_current_page':
286
+
287
+ if (\is_front_page() || \is_home()) {
288
+ $this->purgeAll();
289
+ } else {
290
+ $parse_url = \wp_parse_url($current_url);
291
+ $url_to_purge = (!isset($parse_url['query'])) ? $parse_url['path'] : '/?' . $parse_url['query'];
292
+ $this->purgeUrl($url_to_purge);
293
+ }
294
+
295
+ break;
296
+ }
297
+
298
+ \wp_redirect(\esc_url_raw($redirect_url));
299
+ exit();
300
+ }
301
+
302
+ /**
303
+ * Ahsc_check_ajax_referer
304
+ * Purge the cache on 'save-sidebar-widgets' ajax request
305
+ *
306
+ * @param int|string $action
307
+ * @return void
308
+ */
309
+ public function ahsc_check_ajax_referer($action)
310
+ {
311
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
312
+ return;
313
+ }
314
+
315
+ switch ($action) {
316
+
317
+ case 'save-sidebar-widgets':
318
+ $this->purgeUrl($this->getHomepage());
319
+ break;
320
+
321
+ default:
322
+ break;
323
+
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Ahsc_edit_term
329
+ * Purge the cache of term item or home on term edit.
330
+ *
331
+ * @param int $term_id
332
+ * @param int $tt_id
333
+ * @param string $taxon
334
+ * @return void
335
+ */
336
+ public function ahsc_edit_term(int $term_id, int $tt_id, string $taxon)
337
+ {
338
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
339
+ return;
340
+ }
341
+
342
+ $term_link = \get_term_link($term_id, $taxon);
343
+
344
+ if (!$this->is_enable_setting('ahsc_purge_archive_on_edit')) {
345
+ return;
346
+ }
347
+
348
+ $this->purgeUrl($this->parseUrl($term_link));
349
+
350
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
351
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
352
+ }
353
+ return true;
354
+ }
355
+
356
+ /**
357
+ * purge_on_term_taxonomy_edited
358
+ *
359
+ * @param int $term_id
360
+ * @param int $tt_id
361
+ * @param string $taxon
362
+ * @return void
363
+ */
364
+ public function ahsc_delete_term(int $term, int $tt_id, string $taxonomy, \WP_Term $deleted_term, array $object_ids)
365
+ {
366
+ global $wp_rewrite;
367
+
368
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
369
+ return;
370
+ }
371
+
372
+ if (!$this->is_enable_setting('ahsc_purge_archive_on_edit')) {
373
+ return;
374
+ }
375
+
376
+ $taxonomy = $deleted_term->taxonomy;
377
+ $termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
378
+ $slug = $deleted_term->slug;
379
+ $t = \get_taxonomy($taxonomy);
380
+
381
+ $termlink = \str_replace("%$taxonomy%", $slug, $termlink);
382
+
383
+ if (! empty($t->rewrite['hierarchical'])) {
384
+ $hierarchical_slugs = array();
385
+ $ancestors = \get_ancestors($deleted_term->term_id, $taxonomy, 'taxonomy');
386
+ foreach ((array) $ancestors as $ancestor) {
387
+ $ancestor_term = \get_term($ancestor, $taxonomy);
388
+ $hierarchical_slugs[] = $ancestor_term->slug;
389
+ }
390
+ $hierarchical_slugs = array_reverse($hierarchical_slugs);
391
+ $hierarchical_slugs[] = $slug;
392
+ $termlink = \str_replace("%$taxonomy%", \implode('/', $hierarchical_slugs), $termlink);
393
+ }
394
+
395
+ $termlink = \user_trailingslashit($termlink, 'category');
396
+
397
+ // purge the term cache.
398
+ $this->purgeUrl($termlink);
399
+
400
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
401
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
402
+ }
403
+
404
+ return true;
405
+ }
406
+
407
+ /**
408
+ * Ahsc_transition_post_status
409
+ * Purge the cache of item or site on transition post status
410
+ *
411
+ * @param int|string $new_status
412
+ * @param int|string $old_status
413
+ * @param \WP_Post $post
414
+ * @return void
415
+ */
416
+ public function ahsc_transition_post_status($new_status, $old_status, \WP_Post $post)
417
+ {
418
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
419
+ return;
420
+ }
421
+
422
+ if ($this->is_enable_setting('ahsc_purge_page_on_mod') || $this->is_enable_setting('purge_archive_on_edit')) {
423
+ $status = array( 'publish', 'future' );
424
+
425
+ if (in_array($new_status, $status, true)) {
426
+ $post_url = \get_permalink($post->ID);
427
+ $this->purgeUrl($this->parseUrl($post_url));
428
+
429
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
430
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
431
+ }
432
+ }
433
+ }
434
+
435
+ if ($this->is_enable_setting('ahsc_purge_archive_on_del')) {
436
+ if ('trash' === $new_status) {
437
+ $slug = \str_replace('__trashed', '', $post->post_name);
438
+ $post_url = \home_url($slug);
439
+ $this->purgeUrl($this->parseUrl($post_url));
440
+
441
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_del')) {
442
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ /**
449
+ * Ahsc_transition_comment_status
450
+ * Purge the cache of item or site on canghe status of the comment
451
+ *
452
+ * @param int|string $new_status
453
+ * @param int|string $old_status
454
+ * @param \WP_Comment $comment
455
+ * @return void
456
+ */
457
+ public function ahsc_transition_comment_status($new_status, $old_status, \WP_Comment $comment)
458
+ {
459
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
460
+ return;
461
+ }
462
+
463
+ if ($this->is_enable_setting('ahsc_purge_page_on_new_comment') || $this->is_enable_setting('ahsc_purge_page_on_deleted_comment')) {
464
+ $_post_id = $comment->comment_post_ID;
465
+
466
+ $post_url = \get_permalink($_post_id);
467
+
468
+ switch ($new_status) {
469
+ case 'approved':
470
+ if ($this->is_enable_setting('ahsc_purge_page_on_new_comment')) {
471
+ $this->purgeUrl($this->parseUrl($post_url));
472
+ }
473
+ break;
474
+
475
+ case 'spam':
476
+ case 'unapproved':
477
+ case 'trash':
478
+ if ('approved' === $old_status && $this->is_enable_setting('ahsc_purge_page_on_deleted_comment')) {
479
+ $this->purgeUrl($this->parseUrl($post_url));
480
+ }
481
+ break;
482
+ }
483
+ }
484
+ }
485
+
486
+ /**
487
+ * Ahsc_wp_insert_comment
488
+ * Purge the cache of item on insert the comment
489
+ *
490
+ * @param integer $id
491
+ * @param \WP_Comment $comment
492
+ * @return void
493
+ */
494
+ public function ahsc_wp_insert_comment(int $id, \WP_Comment $comment)
495
+ {
496
+ if (!$this->is_enable_setting('ahsc_enable_purge')) {
497
+ return;
498
+ }
499
+
500
+ if (!$this->is_enable_setting('ahsc_purge_page_on_new_comment')) {
501
+ return;
502
+ }
503
+
504
+ $_post_id = $comment->comment_post_ID;
505
+ $post_url = \get_permalink($_post_id);
506
+
507
+ $this->purgeUrl($this->parseUrl($post_url));
508
+
509
+ if ($this->is_enable_setting('ahsc_purge_homepage_on_edit')) {
510
+ $this->purgeUrl($this->parseUrl($this->getHomepage()));
511
+ }
512
+ }
513
+ }
514
+ }
includes/ArubaHiSpeedCachei18n.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ declare(strict_types=1);
10
+
11
+ namespace ArubaHiSpeedCache\includes;
12
+
13
+ use load_plugin_textdomain;
14
+
15
+ /**
16
+ * ArubaHiSpeedCachei18n
17
+ */
18
+ class ArubaHiSpeedCachei18n
19
+ {
20
+ /**
21
+ * Domain
22
+ *
23
+ * @var string plugin name
24
+ */
25
+ private $domain;
26
+
27
+ /**
28
+ * DirRelPath
29
+ *
30
+ * @var [type]
31
+ */
32
+ private $dirRelPath;
33
+
34
+ public function __construct(string $domain = '', string $plugin_rel_path = '')
35
+ {
36
+ $this->domain = $domain;
37
+ $this->dirRelPath = dirname($plugin_rel_path);
38
+ }
39
+
40
+ /**
41
+ * Load_plugin_textdomain
42
+ *
43
+ * @return void
44
+ */
45
+ public function load_plugin_textdomain()
46
+ {
47
+ \load_plugin_textdomain(
48
+ $this->domain,
49
+ false,
50
+ $this->dirRelPath . '/languages'
51
+ );
52
+ }
53
+ }
includes/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden.
4
+ *
5
+ * @package ArubaHiSpeedCache
6
+ */
index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden.
4
+ *
5
+ * @package ArubaHiSpeedCache
6
+ */
languages/aruba-hispeed-cache-es_ES.mo ADDED
Binary file
languages/aruba-hispeed-cache-es_ES.po ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2022 Aruba.it
2
+ # This file is distributed under the same license as the Aruba HiSpeed Cache plugin.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Aruba HiSpeed Cache 0.0.1\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/aruba-hispeed-"
7
+ "cache\n"
8
+ "POT-Creation-Date: 2022-03-02T16:31:41+01:00\n"
9
+ "PO-Revision-Date: 2022-03-02 16:47+0100\n"
10
+ "Last-Translator: \n"
11
+ "Language-Team: \n"
12
+ "Language: es\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "X-Generator: Poedit 3.0.1\n"
18
+ "X-Domain: aruba-hispeed-cache\n"
19
+
20
+ #. Plugin Name of the plugin
21
+ #: \includes\ArubaHiSpeedCacheAdmin.php:129
22
+ #: \includes\ArubaHiSpeedCacheAdmin.php:130
23
+ #: \includes\ArubaHiSpeedCacheAdmin.php:138
24
+ #: \includes\ArubaHiSpeedCacheAdmin.php:139
25
+ msgid "Aruba HiSpeed Cache"
26
+ msgstr "Aruba HiSpeed Cache"
27
+
28
+ #. Plugin URI of the plugin
29
+ msgid ""
30
+ "https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx"
31
+ msgstr ""
32
+ "https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx"
33
+
34
+ #. Description of the plugin
35
+ msgid "Purges the cache whenever a post is edited or published."
36
+ msgstr "Borrar la caché cada vez que se publique o modifique un artículo"
37
+
38
+ #. Author of the plugin
39
+ msgid "Aruba.it"
40
+ msgstr "Aruba.it"
41
+
42
+ #. Author URI of the plugin
43
+ msgid "https://www.aruba.it/"
44
+ msgstr "https://www.aruba.it/"
45
+
46
+ #: \admin\partials\admin-display.php:9
47
+ msgid "Aruba HiSpeed Cache Settings "
48
+ msgstr "Configuración Aruba HiSpeed Cache"
49
+
50
+ #: \admin\partials\admin-general-options.php:68
51
+ msgid "Save changes"
52
+ msgstr "Guardar cambios"
53
+
54
+ #: \admin\partials\admin-general-options.php:73
55
+ msgid "Purge entire cache"
56
+ msgstr "Borrar caché"
57
+
58
+ #: \admin\partials\admin-notice-purge-completed.php:4
59
+ msgid "Purge completed"
60
+ msgstr "Caché borrada correctamente "
61
+
62
+ #: \admin\partials\admin-notice-settings-saved.php:4
63
+ msgid "Settings saved."
64
+ msgstr "Ajustes guardados"
65
+
66
+ #: \admin\partials\admin-notice-version.php:9
67
+ msgid "Sorry, Aruba HiSpeed Cache requires WordPress %s or higher."
68
+ msgstr ""
69
+ "Lo sentimos mucho, Aruba HiSpeed Cache requiere WordPress %s o una versión "
70
+ "superior."
71
+
72
+ #: \includes\ArubaHiSpeedCacheAdmin.php:115
73
+ msgid "You are about to purge the entire cache. Do you want to continue?"
74
+ msgstr ""
75
+ "Estás a punto de borrar completamente la caché. ¿Seguro que quieres "
76
+ "continuar?"
77
+
78
+ #: \includes\ArubaHiSpeedCacheAdmin.php:170
79
+ msgid "Purge the page cache"
80
+ msgstr "Borrar caché de la página"
81
+
82
+ #: \includes\ArubaHiSpeedCacheAdmin.php:174
83
+ msgid "Purge Cache"
84
+ msgstr "Borrar caché"
85
+
86
+ #: \includes\ArubaHiSpeedCacheAdmin.php:226
87
+ msgid "Settings"
88
+ msgstr "Configuración"
89
+
90
+ #: \includes\ArubaHiSpeedCacheAdmin.php:341
91
+ #: \includes\ArubaHiSpeedCacheAdmin.php:342
92
+ msgid "Purging options"
93
+ msgstr "Opciones de limpieza de caché"
94
+
95
+ #: \includes\ArubaHiSpeedCacheAdmin.php:349
96
+ msgid "Enable automatic purge"
97
+ msgstr "Activar la limpieza automática de caché"
98
+
99
+ #: \includes\ArubaHiSpeedCacheAdmin.php:366
100
+ msgid "Automatically purge entire cache when:"
101
+ msgstr "Borrar automáticamente toda la caché cuando:"
102
+
103
+ #: \includes\ArubaHiSpeedCacheAdmin.php:371
104
+ #: \includes\ArubaHiSpeedCacheAdmin.php:372
105
+ msgid "Home page:"
106
+ msgstr "Página de inicio:"
107
+
108
+ #: \includes\ArubaHiSpeedCacheAdmin.php:379
109
+ #: \includes\ArubaHiSpeedCacheAdmin.php:431
110
+ msgid ""
111
+ "a <strong>post</strong> (or page/custom post) is <strong>modified</strong> "
112
+ "or <strong>added</strong>."
113
+ msgstr ""
114
+ "se <strong>modifica</strong> o <strong>agrega</strong> un <strong>artículo</"
115
+ "strong> (o página/custom post)"
116
+
117
+ #: \includes\ArubaHiSpeedCacheAdmin.php:386
118
+ #: \includes\ArubaHiSpeedCacheAdmin.php:438
119
+ msgid ""
120
+ "a <strong>published post</strong> (or page/custom post) is "
121
+ "<strong>cancelled</strong>."
122
+ msgstr ""
123
+ "se <strong>elimina</strong> un <strong>artículo publicado</strong> (o "
124
+ "página/custom post)"
125
+
126
+ #: \includes\ArubaHiSpeedCacheAdmin.php:393
127
+ #: \includes\ArubaHiSpeedCacheAdmin.php:394
128
+ msgid "Post/page/custom post type:"
129
+ msgstr "Artículo/página/contenido personalizado (cpt):"
130
+
131
+ #: \includes\ArubaHiSpeedCacheAdmin.php:401
132
+ msgid "a <strong>post</strong> is <strong>published</strong>."
133
+ msgstr "se <strong>publica</strong> un <strong>artículo</strong>."
134
+
135
+ #: \includes\ArubaHiSpeedCacheAdmin.php:408
136
+ #: \includes\ArubaHiSpeedCacheAdmin.php:453
137
+ msgid "a <strong>comment</strong> is <strong>approved/published</strong>."
138
+ msgstr ""
139
+ "un <strong>comentario</strong> es <strong>aprobado/publicado</strong>."
140
+
141
+ #: \includes\ArubaHiSpeedCacheAdmin.php:415
142
+ #: \includes\ArubaHiSpeedCacheAdmin.php:460
143
+ msgid "a <strong>comment</strong> is <strong>unapproved/deleted</strong>."
144
+ msgstr ""
145
+ "un <strong>comentario</strong> es <strong>rechazado/eliminado</strong>."
146
+
147
+ #: \includes\ArubaHiSpeedCacheAdmin.php:422
148
+ #: \includes\ArubaHiSpeedCacheAdmin.php:424
149
+ msgid "Archives:"
150
+ msgstr "Archivo:"
151
+
152
+ #: \includes\ArubaHiSpeedCacheAdmin.php:423
153
+ msgid "(date, category, tag, author, custom taxonomies)"
154
+ msgstr "(fecha, categoría, tags, autor, taxonomías personalizadas)"
155
+
156
+ #: \includes\ArubaHiSpeedCacheAdmin.php:445
157
+ #: \includes\ArubaHiSpeedCacheAdmin.php:446
158
+ msgid "Comments:"
159
+ msgstr "Comentarios:"
160
+
161
+ #: \includes\ArubaHiSpeedCacheConfigs.php:128
162
+ msgid "Sorry, you need to be an administrator to use Aruba HiSpeed Cache."
163
+ msgstr ""
164
+ "Lo sentimos mucho, tienes que ser administrador para usar Aruba HiSpeed "
165
+ "Cache."
166
+
167
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:244
168
+ msgid "An error has occurred."
169
+ msgstr "Se ha producido un error."
170
+
171
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:245
172
+ msgid "Sorry, you do not have the necessary privileges to edit these options."
173
+ msgstr ""
174
+ "Lo sentimos mucho pero no dispones de los permisos necesarios para "
175
+ "modificar estas opciones. "
176
+
177
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:250
178
+ msgid "Contact customer service"
179
+ msgstr "Contacta con nuestro servicio clientes"
languages/aruba-hispeed-cache-it_IT.mo ADDED
Binary file
languages/aruba-hispeed-cache-it_IT.po ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2022 Aruba.it
2
+ # This file is distributed under the same license as the Aruba HiSpeed Cache plugin.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Aruba HiSpeed Cache 0.0.1\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/aruba-hispeed-"
7
+ "cache\n"
8
+ "POT-Creation-Date: 2022-03-02T16:31:41+01:00\n"
9
+ "PO-Revision-Date: 2022-03-08 12:19+0100\n"
10
+ "Last-Translator: Aruba Developer <hispeedcache.developer@aruba.it>\n"
11
+ "Language-Team: Aruba Developer <hispeedcache.developer@aruba.it>\n"
12
+ "Language: it_IT\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "X-Generator: Poedit 2.4.2\n"
18
+ "X-Poedit-KeywordsList: __;_e;_n;_x;_ex;_nx;esc_attr__;esc_attr_e;esc_attr_x;"
19
+ "esc_html__;esc_html_e;esc_html_x;_n_noop;_nx_noop;translate_nooped_plural\n"
20
+ "X-Domain: aruba-hispeed-cache\n"
21
+ "X-Poedit-Basepath: ..\n"
22
+ "X-Poedit-SearchPath-0: .\n"
23
+
24
+ #. Plugin Name of the plugin
25
+ #: \includes\ArubaHiSpeedCacheAdmin.php:129
26
+ #: \includes\ArubaHiSpeedCacheAdmin.php:130
27
+ #: \includes\ArubaHiSpeedCacheAdmin.php:138
28
+ #: \includes\ArubaHiSpeedCacheAdmin.php:139
29
+ msgid "Aruba HiSpeed Cache"
30
+ msgstr "Aruba HiSpeed Cache"
31
+
32
+ #. Plugin URI of the plugin
33
+ msgid ""
34
+ "https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx"
35
+ msgstr ""
36
+ "https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx"
37
+
38
+ #. Description of the plugin
39
+ msgid "Purges the cache whenever a post is edited or published."
40
+ msgstr ""
41
+ "Cancella la cache ogni volta che un articolo è modificato o pubblicato."
42
+
43
+ #. Author of the plugin
44
+ msgid "Aruba.it"
45
+ msgstr "Aruba.it"
46
+
47
+ #. Author URI of the plugin
48
+ msgid "https://www.aruba.it/"
49
+ msgstr "https://www.aruba.it/"
50
+
51
+ #: \admin\partials\admin-display.php:9
52
+ msgid "Aruba HiSpeed Cache Settings "
53
+ msgstr "Impostazioni Aruba HiSpeed Cache "
54
+
55
+ #: \admin\partials\admin-general-options.php:68
56
+ msgid "Save changes"
57
+ msgstr "Salva modifiche"
58
+
59
+ #: \admin\partials\admin-general-options.php:73
60
+ msgid "Purge entire cache"
61
+ msgstr "Cancella cache"
62
+
63
+ #: \admin\partials\admin-notice-purge-completed.php:4
64
+ msgid "Purge completed"
65
+ msgstr "Cache cancellata correttamente"
66
+
67
+ #: \admin\partials\admin-notice-settings-saved.php:4
68
+ msgid "Settings saved."
69
+ msgstr "Impostazioni salvate."
70
+
71
+ #: \admin\partials\admin-notice-version.php:9
72
+ msgid "Sorry, Aruba HiSpeed Cache requires WordPress %s or higher."
73
+ msgstr ""
74
+ "Ci dispiace, ma Aruba HiSpeed Cache richiede WordPress %s o una versione "
75
+ "superiore."
76
+
77
+ #: \includes\ArubaHiSpeedCacheAdmin.php:115
78
+ msgid "You are about to purge the entire cache. Do you want to continue?"
79
+ msgstr "Si sta per cancellare completamente la cache. Vuoi procedere?"
80
+
81
+ #: \includes\ArubaHiSpeedCacheAdmin.php:170
82
+ msgid "Purge the page cache"
83
+ msgstr "Cancella la cache della pagina"
84
+
85
+ #: \includes\ArubaHiSpeedCacheAdmin.php:174
86
+ msgid "Purge Cache"
87
+ msgstr "Cancella cache"
88
+
89
+ #: \includes\ArubaHiSpeedCacheAdmin.php:226
90
+ msgid "Settings"
91
+ msgstr "Impostazioni"
92
+
93
+ #: \includes\ArubaHiSpeedCacheAdmin.php:341
94
+ #: \includes\ArubaHiSpeedCacheAdmin.php:342
95
+ msgid "Purging options"
96
+ msgstr "Opzioni di pulizia della cache"
97
+
98
+ #: \includes\ArubaHiSpeedCacheAdmin.php:349
99
+ msgid "Enable automatic purge"
100
+ msgstr "Attiva la pulizia automatica della cache"
101
+
102
+ #: \includes\ArubaHiSpeedCacheAdmin.php:366
103
+ msgid "Automatically purge entire cache when:"
104
+ msgstr "Cancella automaticamente tutta la cache quando:"
105
+
106
+ #: \includes\ArubaHiSpeedCacheAdmin.php:371
107
+ #: \includes\ArubaHiSpeedCacheAdmin.php:372
108
+ msgid "Home page:"
109
+ msgstr "Home page:"
110
+
111
+ #: \includes\ArubaHiSpeedCacheAdmin.php:379
112
+ #: \includes\ArubaHiSpeedCacheAdmin.php:431
113
+ msgid ""
114
+ "a <strong>post</strong> (or page/custom post) is <strong>modified</strong> "
115
+ "or <strong>added</strong>."
116
+ msgstr ""
117
+ "un <strong>articolo</strong> (o pagina/contenuto personalizzato) è "
118
+ "<strong>modificato</strong> o <strong>aggiunto</strong>."
119
+
120
+ #: \includes\ArubaHiSpeedCacheAdmin.php:386
121
+ #: \includes\ArubaHiSpeedCacheAdmin.php:438
122
+ msgid ""
123
+ "a <strong>published post</strong> (or page/custom post) is "
124
+ "<strong>cancelled</strong>."
125
+ msgstr ""
126
+ "un <strong>articolo pubblicato</strong> (o pagina/contenuto personalizzato) "
127
+ "è <strong>cancellato</strong>."
128
+
129
+ #: \includes\ArubaHiSpeedCacheAdmin.php:393
130
+ #: \includes\ArubaHiSpeedCacheAdmin.php:394
131
+ msgid "Post/page/custom post type:"
132
+ msgstr "Articolo/pagina/contenuto personalizzato:"
133
+
134
+ #: \includes\ArubaHiSpeedCacheAdmin.php:401
135
+ msgid "a <strong>post</strong> is <strong>published</strong>."
136
+ msgstr "un <strong>articolo</strong> è <strong>pubblicato</strong>."
137
+
138
+ #: \includes\ArubaHiSpeedCacheAdmin.php:408
139
+ #: \includes\ArubaHiSpeedCacheAdmin.php:453
140
+ msgid "a <strong>comment</strong> is <strong>approved/published</strong>."
141
+ msgstr "un <strong>commento</strong> è <strong>approvato/pubblicato</strong>."
142
+
143
+ #: \includes\ArubaHiSpeedCacheAdmin.php:415
144
+ #: \includes\ArubaHiSpeedCacheAdmin.php:460
145
+ msgid "a <strong>comment</strong> is <strong>unapproved/deleted</strong>."
146
+ msgstr ""
147
+ "un <strong>commento</strong> è <strong>non approvato/cancellato</strong>."
148
+
149
+ #: \includes\ArubaHiSpeedCacheAdmin.php:422
150
+ #: \includes\ArubaHiSpeedCacheAdmin.php:424
151
+ msgid "Archives:"
152
+ msgstr "Archivio:"
153
+
154
+ #: \includes\ArubaHiSpeedCacheAdmin.php:423
155
+ msgid "(date, category, tag, author, custom taxonomies)"
156
+ msgstr "(data, categoria, tag, autore, tassonomia custom)"
157
+
158
+ #: \includes\ArubaHiSpeedCacheAdmin.php:445
159
+ #: \includes\ArubaHiSpeedCacheAdmin.php:446
160
+ msgid "Comments:"
161
+ msgstr "Commenti:"
162
+
163
+ #: \includes\ArubaHiSpeedCacheConfigs.php:128
164
+ msgid "Sorry, you need to be an administrator to use Aruba HiSpeed Cache."
165
+ msgstr ""
166
+ "Ci dispiace, ma devi essere un amministratore per usare Aruba HiSpeed Cache."
167
+
168
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:244
169
+ msgid "An error has occurred."
170
+ msgstr "Si è verificato un errore."
171
+
172
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:245
173
+ msgid "Sorry, you do not have the necessary privileges to edit these options."
174
+ msgstr ""
175
+ "Ci dispiace, ma non disponi dei permessi necessari per modificare queste "
176
+ "opzioni."
177
+
178
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:250
179
+ msgid "Contact customer service"
180
+ msgstr "Contatta il nostro servizio clienti"
181
+
182
+ #~ msgid "Purged Everything Done!"
183
+ #~ msgstr "Cache cancellata correttamente!"
languages/aruba-hispeed-cache.pot ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2022 Aruba.it
2
+ # This file is distributed under the same license as the Aruba HiSpeed Cache plugin.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Aruba HiSpeed Cache 0.0.1\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/aruba-hispeed-cache\n"
7
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
+ "Language-Team: LANGUAGE <LL@li.org>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2022-03-02T16:31:41+01:00\n"
13
+ "PO-Revision-Date: 2022-03-02T16:31:41+01:00\n"
14
+ "X-Generator: WP-CLI 2.0.1\n"
15
+ "X-Domain: aruba-hispeed-cache\n"
16
+
17
+ #. Plugin Name of the plugin
18
+ #: \includes\ArubaHiSpeedCacheAdmin.php:129
19
+ #: \includes\ArubaHiSpeedCacheAdmin.php:130
20
+ #: \includes\ArubaHiSpeedCacheAdmin.php:138
21
+ #: \includes\ArubaHiSpeedCacheAdmin.php:139
22
+ msgid "Aruba HiSpeed Cache"
23
+ msgstr ""
24
+
25
+ #. Plugin URI of the plugin
26
+ msgid "https://www.aruba.it/magazine/hosting/siti-piu-veloci-con-hispeed-cache.aspx"
27
+ msgstr ""
28
+
29
+ #. Description of the plugin
30
+ msgid "Purges the cache whenever a post is edited or published."
31
+ msgstr ""
32
+
33
+ #. Author of the plugin
34
+ msgid "Aruba.it"
35
+ msgstr ""
36
+
37
+ #. Author URI of the plugin
38
+ msgid "https://www.aruba.it/"
39
+ msgstr ""
40
+
41
+ #: \admin\partials\admin-display.php:9
42
+ msgid "Aruba HiSpeed Cache Settings "
43
+ msgstr ""
44
+
45
+ #: \admin\partials\admin-general-options.php:68
46
+ msgid "Save changes"
47
+ msgstr ""
48
+
49
+ #: \admin\partials\admin-general-options.php:73
50
+ msgid "Purge entire cache"
51
+ msgstr ""
52
+
53
+ #: \admin\partials\admin-notice-purge-completed.php:4
54
+ msgid "Purge completed"
55
+ msgstr ""
56
+
57
+ #: \admin\partials\admin-notice-settings-saved.php:4
58
+ msgid "Settings saved."
59
+ msgstr ""
60
+
61
+ #: \admin\partials\admin-notice-version.php:9
62
+ msgid "Sorry, Aruba HiSpeed Cache requires WordPress %s or higher."
63
+ msgstr ""
64
+
65
+ #: \includes\ArubaHiSpeedCacheAdmin.php:115
66
+ msgid "You are about to purge the entire cache. Do you want to continue?"
67
+ msgstr ""
68
+
69
+ #: \includes\ArubaHiSpeedCacheAdmin.php:170
70
+ msgid "Purge the page cache"
71
+ msgstr ""
72
+
73
+ #: \includes\ArubaHiSpeedCacheAdmin.php:174
74
+ msgid "Purge Cache"
75
+ msgstr ""
76
+
77
+ #: \includes\ArubaHiSpeedCacheAdmin.php:226
78
+ msgid "Settings"
79
+ msgstr ""
80
+
81
+ #: \includes\ArubaHiSpeedCacheAdmin.php:341
82
+ #: \includes\ArubaHiSpeedCacheAdmin.php:342
83
+ msgid "Purging options"
84
+ msgstr ""
85
+
86
+ #: \includes\ArubaHiSpeedCacheAdmin.php:349
87
+ msgid "Enable automatic purge"
88
+ msgstr ""
89
+
90
+ #: \includes\ArubaHiSpeedCacheAdmin.php:366
91
+ msgid "Automatically purge entire cache when:"
92
+ msgstr ""
93
+
94
+ #: \includes\ArubaHiSpeedCacheAdmin.php:371
95
+ #: \includes\ArubaHiSpeedCacheAdmin.php:372
96
+ msgid "Home page:"
97
+ msgstr ""
98
+
99
+ #: \includes\ArubaHiSpeedCacheAdmin.php:379
100
+ #: \includes\ArubaHiSpeedCacheAdmin.php:431
101
+ msgid "a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>."
102
+ msgstr ""
103
+
104
+ #: \includes\ArubaHiSpeedCacheAdmin.php:386
105
+ #: \includes\ArubaHiSpeedCacheAdmin.php:438
106
+ msgid "a <strong>published post</strong> (or page/custom post) is <strong>cancelled</strong>."
107
+ msgstr ""
108
+
109
+ #: \includes\ArubaHiSpeedCacheAdmin.php:393
110
+ #: \includes\ArubaHiSpeedCacheAdmin.php:394
111
+ msgid "Post/page/custom post type:"
112
+ msgstr ""
113
+
114
+ #: \includes\ArubaHiSpeedCacheAdmin.php:401
115
+ msgid "a <strong>post</strong> is <strong>published</strong>."
116
+ msgstr ""
117
+
118
+ #: \includes\ArubaHiSpeedCacheAdmin.php:408
119
+ #: \includes\ArubaHiSpeedCacheAdmin.php:453
120
+ msgid "a <strong>comment</strong> is <strong>approved/published</strong>."
121
+ msgstr ""
122
+
123
+ #: \includes\ArubaHiSpeedCacheAdmin.php:415
124
+ #: \includes\ArubaHiSpeedCacheAdmin.php:460
125
+ msgid "a <strong>comment</strong> is <strong>unapproved/deleted</strong>."
126
+ msgstr ""
127
+
128
+ #: \includes\ArubaHiSpeedCacheAdmin.php:422
129
+ #: \includes\ArubaHiSpeedCacheAdmin.php:424
130
+ msgid "Archives:"
131
+ msgstr ""
132
+
133
+ #: \includes\ArubaHiSpeedCacheAdmin.php:423
134
+ msgid "(date, category, tag, author, custom taxonomies)"
135
+ msgstr ""
136
+
137
+ #: \includes\ArubaHiSpeedCacheAdmin.php:445
138
+ #: \includes\ArubaHiSpeedCacheAdmin.php:446
139
+ msgid "Comments:"
140
+ msgstr ""
141
+
142
+ #: \includes\ArubaHiSpeedCacheConfigs.php:128
143
+ msgid "Sorry, you need to be an administrator to use Aruba HiSpeed Cache."
144
+ msgstr ""
145
+
146
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:244
147
+ msgid "An error has occurred."
148
+ msgstr ""
149
+
150
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:245
151
+ msgid "Sorry, you do not have the necessary privileges to edit these options."
152
+ msgstr ""
153
+
154
+ #: \includes\ArubaHiSpeedCacheWpPurger.php:250
155
+ msgid "Contact customer service"
156
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Aruba HiSpeed Cache ===
2
+
3
+ Contributors: arubait, arubadev, arubasupport, agelmini, camaran
4
+ Tags: hispeed-cache, aruba, cache, caching, performance, pagespeed, optimize, wp-cache, speed, purge
5
+ Requires at least: 5.7
6
+ Tested up to: 6.0
7
+ Requires PHP: 7.4
8
+ Stable tag: 1.0.0
9
+ License: GPLv2 or later
10
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Aruba HiSpeed Cache interfaces directly with an Aruba hosting platform's HiSpeed Cache service and automates its management.
13
+
14
+ == Description ==
15
+
16
+ **Aruba HiSpeed Cache** is a plugin that interfaces directly with the **HiSpeed Cache** service for an [Aruba](https://www.aruba.it/en/) [hosting platform](https://hosting.aruba.it/en/) and automates its management in the WordPress dashboard, without having to access the website's control panel.
17
+
18
+ **The plugin can only be used if your WordPress website is hosted on an [Aruba](https://www.aruba.it/en/) [hosting platform](https://hosting.aruba.it/en/).**
19
+
20
+ The HiSpeed Cache service significantly reduces the TTFB (first Byte transfer time) and webpage loading times.
21
+
22
+ When the service is active, the plugin lets you clear the cache automatically (and/or manually) every time a page or post is edited, without having to access the control panel for the website by clicking on the link provided.
23
+
24
+ HiSpeed Cache keeps dynamic content in the servers' memory after the first time it loads, making it available for subsequent requests much faster, significantly speeding up website browsing. The plugin simply clears the cache every time a custom page, article or content item is edited.
25
+
26
+ For more details and to find out whether the HiSpeed Cache service is active on your website [please refer to our guide](https://guide.hosting.aruba.it/hosting/wordpress-e-altri-cms/wordpress-plugin-aruba-hispeed-cache.aspx?viewmode=0#eng).
27
+
28
+ == Installation ==
29
+
30
+ = From your WordPress dashboard =
31
+ 1. Visit ‘Plugins -> Add New’
32
+ 2. Search for ‘Aruba HiSpeed Cache’
33
+ 3. Activate Aruba HiSpeed Cache from your Plugins page.
34
+ 4. Click ‘Settings -> Aruba HiSpeed Cache’
35
+
36
+ = From WordPress.org =
37
+ 1. Download Aruba HiSpeed Cache.
38
+ 2. Create a directory named 'aruba-hispeed-cache' in your '/wp-content/plugins/' directory, using your preferred method (ftp, sftp, scp, etc.).
39
+ 3. Activate Aruba HiSpeed Cache from your Plugins page.
40
+ 4. Click Options from your Plugins page
41
+
42
+ == Frequently Asked Questions ==
43
+
44
+ = What is HiSpeed Cache? =
45
+
46
+ HiSpeed Cache is a dynamic caching system that significantly improves webpage loading speeds. The active cache reduces the time to first byte (TTFB). The service also lets you clear the cache automatically or manually, whenever a page or any content is edited.
47
+
48
+ = What is the purpose of the plugin? =
49
+
50
+ When the service is active, using the plugin means you can clear the website's cache at any time directly from the WordPress dashboard, without having to access the hosting control panel. You can set the cache to clear automatically, or you can use the manual option.
51
+
52
+ = My website is not hosted on an Aruba hosting platform. Can I still use the plugin? =
53
+
54
+ You can install the plugin, but it was designed to interface with the caching system for an Aruba hosting platform. Purchase an Aruba hosting service then migrate your website to use the plugin.
55
+
56
+ == Screenshots ==
57
+
58
+ 1. General Settings enabled
59
+ 2. General Settings disabled
60
+
61
+ == Changelog ==
62
+
63
+ = 1.0.0 =
64
+ * First stable version released.
65
+
66
+ == Upgrade Notice ==
67
+
68
+ = 1.0.0 =
69
+ * First stable version released.
uninstall.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manages the uninstallation process of the Aruba HiSpeed Cache Plugin for more
4
+ * information, see https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/
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
+ */
12
+
13
+ declare(strict_types=1);
14
+
15
+ namespace ArubaHiSpeedCache;
16
+
17
+ use \delete_site_option;
18
+ use \defined;
19
+
20
+ // if uninstall.php is not called by WordPress, die
21
+ if (! \defined('WP_UNINSTALL_PLUGIN')) {
22
+ exit;
23
+ }
24
+
25
+ \delete_site_option('aruba_hispeed_cache_options');