PluginProbe ʕ •ᴥ•ʔ
Aruba HiSpeed Cache / 3.0.15
Aruba HiSpeed Cache v3.0.15
3.0.15 3.0.14 3.0.13 1.2.4 1.2.5 1.2.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.19 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3
aruba-hispeed-cache / aruba-hispeed-cache.php
aruba-hispeed-cache Last commit date
admin 5 days ago assets 5 months ago languages 5 months ago src 5 days ago aruba-hispeed-cache.php 5 days ago index.php 2 years ago readme.txt 5 days ago uninstall.php 5 days ago
aruba-hispeed-cache.php
757 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 /**
4 * Aruba HiSpeed Cache
5 * php version 7.4
6 *
7 * @category Wordpress-plugin
8 *
9 * @author Aruba Developer <hispeedcache.developer@aruba.it>
10 * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
11 *
12 * @see Null
13 * @since 1.0.0
14 *
15 * @wordpress-plugin
16 * Plugin Name: Aruba HiSpeed Cache
17 * Version: 3.0.15
18 * Plugin URI: https://hosting.aruba.it/wordpress.aspx
19 *
20 * @phpcs:ignore Generic.Files.LineLength.TooLong
21 * Description: Aruba HiSpeed Cache interfaces directly with the Aruba HiSpeed Cache service of the Aruba hosting platform and automates its management.
22 * Author: Aruba
23 * Author URI: https://www.aruba.it/
24 * Text Domain: aruba-hispeed-cache
25 * Domain Path: /languages
26 * License: GPL v3 or later
27 * Tested up to: 7.1
28 * Requires PHP: 7.4
29 * Requires at least: 6.2
30 * This program is free software: you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation, either version 2 of the License, or
33 * (at your option) any later version.
34 *
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License
41 * along with this program. If not, see <http://www.gnu.org/licenses/>.
42 *
43 * @package ArubaHispeedCache
44 */
45
46 //declare compliance with consent level API
47 $plugin = plugin_basename( __FILE__ );
48 add_filter( "wp_consent_api_registered_{$plugin}", '__return_true' );
49
50 function AHSC_get_version() {
51 require_once ABSPATH . 'wp-admin/includes/plugin.php';
52 // Prevent early translation call by setting $translate to false.
53 $plugin_data = get_plugin_data( __FILE__, false, /* $translate */ false );
54 return $plugin_data['Version'];
55 }
56
57 /** constant configuration*/
58 include_once "src/AHSC_Config.php";
59 /** Debug Manager*/
60
61 if(AHSC_CORE['debug']) {
62 if ( file_exists( __DIR__ . DIRECTORY_SEPARATOR . "Debug/Enable.php" ) ) {
63 include_once "Debug/Enable.php";
64 }
65 }
66 /** control plugin version*/
67 include_once "src/AHSC_Version.php";
68 /** Static cache htaccess*/
69 include_once "src/AHSC_Static.php";
70 /** image lazy load*/
71 include_once "src/AHSC_Lazyload.php";
72 /** DNS prefetch and Preconnect*/
73 include_once "src/AHSC_Preconnect.php";
74 /** disable XMLRpc service*/
75 include_once "src/AHSC_XmlRPC.php";
76 /** HTML Optimizer*/
77 include_once "src/AHSC_HtmlOptimizer.php";
78 /** WP-Config transformer*/
79 include_once "src/assets/AHSC_WPCT.php";
80 /** plugin general functions*/
81 include_once "src/AHSC_Functions.php";
82 /** apc*/
83 include_once "src/AHSC_Apc.php";
84 /** DB OPTIMIZATION*/
85 include_once "src/AHSC_Dboptimization.php";
86
87 /** plugin controllo per check services*/
88 include_once "src/AHSC_Check.php";
89 /** class for function purger*/
90 include_once "src/Purger/AbstractPurger.php";
91 include_once "src/Purger/WpPurger.php";
92 /** ADMIN inclusion */
93 include_once "admin/AHSC_Admin_Menu.php";
94 include_once "admin/AHSC_Admin_Bar.php";
95 /** Warmer Manager*/
96 include_once "src/AHSC_Warmer.php";
97 /** event for clearcache*/
98 include_once "src/Events/AHSC_Comments.php";
99 include_once "src/Events/AHSC_Deferer.php";
100 include_once "src/Events/AHSC_Plugins.php";
101 include_once "src/Events/AHSC_PostType.php";
102 include_once "src/Events/AHSC_Terms.php";
103 include_once "src/Events/AHSC_Themes.php";
104
105
106
107 /** check WordPress and php version */
108 AHSC_check_requirement();
109
110 /**
111 * Adding methods to "activate" hooks
112 */
113 register_activation_hook(__FILE__, 'AHSC_activation' );
114
115 /**
116 * Adding methods to "deactivate" hooks
117 */
118 register_deactivation_hook(__FILE__,'AHSC_deactivation');
119
120 \add_action( 'activated_plugin', 'ahsc_check_hispeed_cache_services' , 20, 1 );
121 /**
122 * Adding methods for link in plugins page
123 */
124 if ( \is_multisite() ) {
125 add_filter( 'network_admin_plugin_action_links_'.AHSC_CONSTANT['ARUBA_HISPEED_CACHE_BASENAME'], 'AHSC_plugin_action_links' );
126 } else {
127 add_filter( 'plugin_action_links_' .AHSC_CONSTANT['ARUBA_HISPEED_CACHE_BASENAME'],'AHSC_plugin_action_links' );
128 }
129
130 add_filter( 'site_status_page_cache_supported_cache_headers', 'ahsc_add_supported_cache_headers', 100, 1 );
131
132
133 /**
134 * Add new header to the existing list of cache headers supported by core.
135 * @param array $cache_headers The list of supported cache headers.
136 * @return array
137 */
138 function ahsc_add_supported_cache_headers( $cache_headers ) {
139 // Add new header to the existing list.
140 $cache_headers['x-aruba-cache'] = static function ( $header_value ) {
141 return false !== strpos( strtolower( $header_value ), 'hit' );
142 };
143 return $cache_headers;
144 }
145
146
147 /** Load Multi languages*/
148 add_action( 'init','AHSC_load_plugin_textdomain',200 );
149 //add_action( 'admin_bar_init','AHSC_load_plugin_textdomain' );
150 //add_action( 'wp_before_admin_bar_render','AHSC_load_plugin_textdomain' );
151
152 function AHSC_load_plugin_textdomain() {
153 /* \load_plugin_textdomain(
154 'aruba-hispeed-cache',
155 false,
156 dirname( plugin_basename( __FILE__ ) ) . '/languages'
157 );
158 */
159 define( "AHSC_AJAX", array(
160 'security_error' => array(
161 'code' => 404,
162 'message' => __( 'An error occurred. Please try again later or contact support.', 'aruba-hispeed-cache' ),
163 'type' => 'error',
164 ),
165 'success' => array(
166 'code' => 200,
167 'message' => __( 'Cache purged.', 'aruba-hispeed-cache' ),
168 'type' => 'success',
169 ),
170 'warning' => array(
171 'code' => 202,
172 'message' => __( 'An error occurred. Please try again later or contact support.', 'aruba-hispeed-cache' ),
173 'type' => 'warning',
174 ),
175 ) );
176
177 define( "AHSC_TRANSIENT_AJAX", array(
178 'security_error' => array(
179 'code' => 404,
180 'message' => __( 'An error occurred. Please try again later or contact support.', 'aruba-hispeed-cache' ),
181 'type' => 'error',
182 ),
183 'success' => array(
184 'code' => 200,
185 'message' => __( 'Expired transient purged.', 'aruba-hispeed-cache' ),
186 'type' => 'success',
187 ),
188 'warning' => array(
189 'code' => 202,
190 'message' => __( 'An error occurred. Please try again later or contact support.', 'aruba-hispeed-cache' ),
191 'type' => 'warning',
192 ),
193 ) );
194 }
195
196
197 add_action('init','AHSC_script_nit');
198 function AHSC_script_nit() {
199 if ( current_user_can( 'manage_options' ) ) {
200 if ( is_admin_bar_showing() ) {
201 // Moved off wp_after_admin_bar_render onto the enqueue hooks, so the rules can
202 // go through wp_add_inline_style() instead of being printed by hand.
203 add_action( 'wp_enqueue_scripts', 'ahsc_adminbar_inline_style' );
204 add_action( 'wp_enqueue_scripts', 'ahsc_enqueue_toolbar_js' );
205 add_action( 'wp_enqueue_scripts', 'AHSC_localize_toolbar_js' );
206 if(is_admin()){
207 add_action( 'admin_enqueue_scripts', 'ahsc_adminbar_inline_style' );
208 add_action( 'admin_enqueue_scripts', 'ahsc_enqueue_toolbar_js' );
209 add_action( 'admin_enqueue_scripts', 'AHSC_localize_toolbar_js' );
210 }
211 }
212 }
213 }
214
215 function AHSC_gutemberg_scripts() {
216 if( is_admin() ){
217
218 $js_param = array(
219 'ahsc_ajax_url' => \admin_url( 'admin-ajax.php' ),
220 'ahsc_topurge' => 'all',
221 'ahsc_nonce' => \wp_create_nonce( 'ahsc-purge-cache' ),
222 );
223 wp_add_inline_script( 'AHSC-gutenberg-editor-js-purge', 'const AHSC_TOOLBAR = ' . \wp_json_encode( $js_param ), 'before' );
224
225 wp_enqueue_script(
226 'AHSC-gutenberg-editor-js-purge',
227 plugins_url( "admin/assets/js/editor.js", __FILE__ ),
228 array( 'wp-plugins', 'wp-edit-post', 'react' ),
229 filemtime( plugin_dir_path( __FILE__ ) . "admin/assets/js/editor.js" ),
230 array(
231 'in_footer' => true,
232 'strategy' => 'defer',
233 )
234 );
235 }
236 }
237 add_action( 'enqueue_block_assets', 'AHSC_gutemberg_scripts' );
238
239 /**
240 * Css inclusion for adminbar menu icon and loader
241 * @return void
242 */
243 function ahsc_adminbar_inline_style() {
244 $icon = "#wp-admin-bar-ahsc-purge-link .ahsc-ab-icon:before, #wp-admin-bar-ahsc-transient-purge .ahsc-ab-icon:before{
245 content: '\\f17e';
246 top: 4px;
247 }";
248
249 $loader = "#ahsc-loader-toolbar{
250 display: none;
251 background: rgba(255, 255, 255, .7) url('data:image/gif;base64,R0lGODlhSwBLANUAAP////7+/v39/fz8/Pr6+vn5+ff39/b29vX19fT09PPz8/Ly8vHx8fDw8O/v7+7u7u3t7ezs7Ovr6+rq6unp6ejo6Ofn5+bm5uTk5OPj4+Li4uDg4N3d3dra2tjY2NfX19TU1NHR0c/Pz87Ozs3NzcfHx8XFxcTExMHBwbu7u7q6urW1tbS0tLGxsa+vr6ioqKenp6Kiop6enp2dnZycnJSUlJOTk4qKioCAgHd3d21tbWNjYwAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgAAACwAAAAAQwBLAAAG/0CAcEgsGo/FAogVo8VYoAJySq1aj50mbcuNda7g8LXELZdL4rRaCDK7t6C13KrQ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D/FYgi7AwYIIVEPkhqxgwQkZ+FowV4BjwY7yQvUaStGcSHkpbKlemw9gy2kaZ2yI8rCnxGEWvnAkI1kR4TKHMhgD2mfSHDODKgQDeZZzXrB7HfETAGSxnDh1DqEWeiZv20hw2bdy8RYFgrq3bt8codAAx4sOGBnC7XAgxoq/fESDA5m2y4a/hvmwHEz7MWIHiJQoYMwbxuAgHyYwTVwaAmTGHzQAidzZMebPo0X9Bn0Y9IgToAqz9dgDtMPaICbQt2C5AG8AH1mU3H+DbmWhvAAd+SzZ+XMgEun85OG6+pICC65uDAAAh+QQJCgAAACwAAAAASwBLAAAG/0CAcEgsGo9FhOqm2+luKgRySq1ar8JTc8ft6k7YsHgMgHXPZxh5zSam0HBuqk0XS7bxs05S71dfeXEvfoRHOYFwOYWLQ4hxjGEKF5NTHo5wHpBVIC80np4pF0YHl2gHmkgRLp+snihGeJc6qEcRMa24r0QypVwytEaruLgjRJa9mcBDI8PNCkQ1pTXKRJ3NuCBEBziOOKfUAArXwytFB9F5Nd/gFuO4MUce6F01yeBC7e6tUwce/uv38OljNSggmYGf5hgckwIhjQ4Lx+TTVzCiGBQDLVgkg3EcxI1kRtzC9QICyDYgVnRygWLDyZcwY9IBKHNMBhAjcobY8KzmFc4IIXIKFerSJ5UNQ5Pm/GAUCQSlUDk0NRIUqtIGU4dMsAr1Y9YOXKFmFRIWas+pZZWebZo26VqjYNvmHAtgq1yvWaumxUr3aVqpdIUgDcs08BCgVosaJoIBp06ei/lFnky5shgDDiRcoBAhgWUAFCaJnlRhweQDo1NPcrC4gOrXrAOHfq26AF3UtFU/oPsg92u6s32Ptp1VeO2xFYwPHxtBuWi6CZxvDiz9bVNJxvkYdiC8wmTutLVPLtB7NAXPnwEUWJ++vfv38OPLn78xCAA7') no-repeat center;
252 position: fixed;
253 top: 0;
254 left: 0;
255 width: 100%;
256 height: 100%;
257 z-index: 9998;
258 }";
259
260 /*
261 * These rules used to be printed by hand right after the admin bar markup, with an
262 * escaping exemption on both variables. There is no correct escaper for CSS anyway:
263 * esc_html() would turn the quotes in content: '\f17e' and url('data:...') into
264 * entities and break the rules. Registering a src-less handle and attaching the CSS
265 * with wp_add_inline_style() is the pattern core provides for inline-only styles —
266 * WordPress emits the <style> tag itself, so nothing needs escaping here, and the
267 * rules now land in <head> instead of after the admin bar.
268 */
269 wp_register_style( 'ahsc-adminbar', false, array(), AHSC_CONSTANT['ARUBA_HISPEED_CACHE_VERSION'] );
270 wp_enqueue_style( 'ahsc-adminbar' );
271 wp_add_inline_style( 'ahsc-adminbar', $icon . $loader );
272 }
273
274 /**
275 * This method adds and localizes the toolbar.js on both the frontend and backend.
276 *
277 * @return void
278 */
279 function ahsc_enqueue_toolbar_js() {
280
281 wp_enqueue_script(
282 'ahcs-toolbar',
283 AHSC_CONSTANT['ARUBA_HISPEED_CACHE_BASEURL'] . '/assets/js/toolbar.js',
284 array(),
285 time(),
286 array(
287 'in_footer' => true,
288 'strategy' => 'defer',
289 )
290 );
291 }
292
293 add_action( 'wp_ajax_ahcs_clear_cache', 'ahsc_tool_bar_purge' , 100 );
294
295
296 /**
297 * Medoto connected to WP's ajax handler to handle calls to cleaning APIs.
298 *
299 * @return void
300 *
301 * @SuppressWarnings(PHPMD.ElseExpression)
302 */
303 function ahsc_tool_bar_purge() {
304 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset( $_POST['ahsc_nonce'] )){
305
306 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ahsc_nonce'] ) ), 'ahsc-purge-cache' ) ) {
307 wp_die( wp_json_encode( AHSC_AJAX['security_error'] ) );
308 }else{
309
310 $cleaner= new \ArubaSPA\HiSpeedCache\Purger\WpPurger() ;
311 $cleaner->setPurger( AHSC_PURGER );
312
313 if ( isset( $_POST['ahsc_to_purge'] ) ) {
314 /*
315 * The value is either the literal "all" or a percent-encoded URL, so the
316 * sanitizer has to run before urldecode() and must leave the octets alone:
317 * sanitize_text_field() strips every %XX sequence and would shred the URL,
318 * while wp_strip_all_tags() only removes markup. The URL branch below still
319 * goes through esc_url_raw().
320 */
321 $to_purge = urldecode( wp_strip_all_tags( wp_unslash( $_POST['ahsc_to_purge'] ) ) );
322
323 if ( 'all' === $to_purge ) {
324 $cleaner->purgeAll();
325 } else {
326 $cleaner->purgeUrl( \esc_url_raw( $to_purge ) );
327 }
328 // Don't forget to stop execution afterward.
329 wp_die( wp_json_encode( AHSC_AJAX['success']) );
330 }
331 // Don't forget to stop execution afterward.
332 wp_die( wp_json_encode( AHSC_AJAX['warning'] ) );
333 }
334 }else{
335 wp_die( wp_json_encode( AHSC_AJAX['security_error'] ) );
336 }
337 }
338
339 add_action( 'wp_ajax_ahsc_clear_expired_transient', 'ahsc_clear_expired_transient' , 100 );
340 function ahsc_clear_expired_transient(){
341 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset( $_POST['ahsc_nonce'] )) {
342 if ( !\wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['ahsc_nonce'] ) ), 'ahsc-purge-cache' ) ){
343 wp_die( wp_json_encode( AHSC_TRANSIENT_AJAX['security_error'] ) );
344 } else {
345 delete_expired_transients( true );
346 if(class_exists('\ArubaSPA\HiSpeedCache\Debug\Logger')) {
347 // Logger.
348 AHSC_log( 'ALL', 'Clear Expired Transient' );
349 // Logger.
350 }
351 wp_die( wp_json_encode( AHSC_TRANSIENT_AJAX['success']) );
352 }
353 }else{
354 wp_die( wp_json_encode( AHSC_TRANSIENT_AJAX['security_error'] ) );
355 }
356 }
357
358 if(is_multisite()){
359 add_action('network_admin_notices', 'AHSC_check_hispeed_cache_notices');
360 }else{
361 add_action( 'admin_notices', 'AHSC_check_hispeed_cache_notices' );
362 }
363
364 if(ahsc_check_debug_status()){
365 add_action( 'admin_enqueue_scripts', 'ahsc_enqueue_debug_status_js' );
366 add_action( 'admin_notices', 'AHSC_debug_status_notices' );
367 }
368
369 function AHSC_debug_status_notices(){
370 ahsc_admin_notice(
371 '<p id="ahsc_debug_status_message">'.__('<b>Debug mode is active.</b> To improve the responsiveness of your site, we suggest you disable it. This will remove any log files.','aruba-hispeed-cache' ).'</p>'.'<a class="button-secondary" id="ahsc_debug_disable" href="#">'.__('Disable Debugging','aruba-hispeed-cache').'</a>',
372 array(
373 'type' => 'warning',
374 'dismissible' => false,
375 )
376 );
377 }
378
379 function ahsc_enqueue_debug_status_js() {
380 wp_register_script(
381 'ahcs-debug-status',
382 AHSC_CONSTANT['ARUBA_HISPEED_CACHE_BASEURL'] . '/assets/js/debug_status.js',
383 array(),
384 AHSC_get_version(),
385 array(
386 'strategy' => 'defer',
387 'in_footer'=> true
388 )
389 );
390
391 wp_enqueue_script( 'ahcs-debug-status' );
392 wp_localize_script( 'ahcs-debug-status', 'AHSC_DEBUG_OPTIONS_CONFIGS',
393 array(
394 'ahsc_ajax_url' => \admin_url( 'admin-ajax.php' ),
395 'ahsc_nonce' => \wp_create_nonce( 'ahsc-disable-debug' ),
396 'asc_result_message'=>__('debug mode has been disabled','aruba-hispeed-cache')
397 )
398 );
399 }
400 /**
401 * Render della notifica in base alla logica presente in ahsc_get_check_notice.
402 *
403 * @return void
404 */
405 function AHSC_check_hispeed_cache_notices() {
406 $check = ahsc_get_check_notice( ahsc_has_notice() );
407 if ( ! \is_null( $check ) ) {
408 // AHSC_Notice_Render() builds a notice div whose body is already wp_kses_post()ed;
409 // applying it to the wrapper too costs nothing and removes the exemption.
410 echo wp_kses_post( $check );
411 }
412 }
413 add_action("wp_ajax_ahsc_disable_debug", "ahsc_disable_debug");
414
415 function ahsc_disable_debug(){
416 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-disable-debug' ) ) {
417
418 $ahsc_response = array();
419 $wpc_transformer = new HASC_WPCT( ABSPATH . 'wp-config.php' );
420 $ahsc_response['disabled_wp_debug']=$wpc_transformer->remove('constant', 'WP_DEBUG');
421 $ahsc_response['disabled_wp_debug_log']=$wpc_transformer->remove('constant', 'WP_DEBUG_LOG');
422 $ahsc_response['disabled_wp_debug_display']=$wpc_transformer->remove('constant', 'WP_DEBUG_DISPLAY');
423 $ahsc_result = glob( WP_CONTENT_DIR . '/*.log' );
424 if ( count( $ahsc_result ) ) {
425 // log files exist
426 foreach ( $ahsc_result as $ahsc_file ) {
427 // wp_delete_file() returns nothing, so the outcome is read back from the
428 // filesystem. As before, only the last iteration is reported.
429 \wp_delete_file( $ahsc_file );
430 $ahsc_response['removed_wp_debug_log_file'] = ! file_exists( $ahsc_file );
431 }
432 }
433 echo wp_json_encode( $ahsc_response );
434 die();
435 }
436 }
437
438
439
440 add_action("wp_ajax_ahsc_enable_purge", "ahsc_ajax_enable_purge");
441 //add_action("wp_ajax_nopriv_ahsc_enable_purge", "ahsc_ajax_enable_purge");
442 function ahsc_ajax_enable_purge(){
443 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' ) ) {
444 $result=array();
445
446 $c_opt=get_option(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME']);
447 $c_opt['ahsc_enable_purge']= isset($_REQUEST['status']) && $_REQUEST['status']==="true";
448 if ($c_opt['ahsc_enable_purge'] === false) {
449 $c_opt['ahsc_purge_homepage_on_edit'] = false;
450 $c_opt['ahsc_purge_page_on_new_comment'] = false;
451 $c_opt['ahsc_purge_archive_on_edit'] = false;
452 }
453 $_res = update_option(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt);
454 $result['result'] = $_res;
455 echo wp_json_encode($result);
456 die();
457 }
458 }
459
460 add_action("wp_ajax_ahsc_purge_homepage_on_edit", "ahsc_ajax_purge_homepage_on_edit");
461 //add_action("wp_ajax_nopriv_ahsc_purge_homepage_on_edit", "ahsc_ajax_purge_homepage_on_edit");
462 function ahsc_ajax_purge_homepage_on_edit(){
463 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' ) ) {
464
465 $result = array();
466
467 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
468 $c_opt['ahsc_purge_homepage_on_edit'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
469 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
470 $result['result'] = $_res;
471 echo wp_json_encode( $result );
472 die();
473 }
474 }
475
476
477 add_action("wp_ajax_ahsc_purge_page_on_new_comment", "ahsc_ajax_purge_page_on_new_comment");
478 //add_action("wp_ajax_nopriv_ahsc_purge_page_on_new_comment", "ahsc_ajax_purge_page_on_new_comment");
479 function ahsc_ajax_purge_page_on_new_comment(){
480 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
481
482 $result = array();
483
484 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
485 $c_opt['ahsc_purge_page_on_new_comment'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
486 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
487 $result['result'] = $_res;
488 echo wp_json_encode( $result );
489 die();
490 }
491 }
492 //ahsc_purge_archive_on_edit
493 add_action("wp_ajax_ahsc_purge_archive_on_edit", "ahsc_ajax_purge_archive_on_edit");
494 //add_action("wp_ajax_nopriv_ahsc_purge_archive_on_edit", "ahsc_ajax_purge_archive_on_edit");
495 function ahsc_ajax_purge_archive_on_edit(){
496 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
497
498 $result = array();
499
500 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
501 $c_opt['ahsc_purge_archive_on_edit'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
502 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
503 $result['result'] = $_res;
504 echo wp_json_encode( $result );
505 die();
506 }
507 }
508
509 //ahsc_cache_warmer
510 add_action("wp_ajax_ahsc_cache_warmer", "ahsc_ajax_cache_warmer");
511 //add_action("wp_ajax_nopriv_ahsc_cache_warmer", "ahsc_ajax_cache_warmer");
512 function ahsc_ajax_cache_warmer(){
513 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
514
515 $result = array();
516
517 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
518 $c_opt['ahsc_cache_warmer'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
519 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
520 $result['result'] = $_res;
521 echo wp_json_encode( $result );
522 die();
523 }
524 }
525
526 //ahsc_static_cache
527 add_action("wp_ajax_ahsc_static_cache", "ahsc_ajax_static_cache");
528 //add_action("wp_ajax_nopriv_ahsc_static_cache", "ahsc_ajax_static_cache");
529 function ahsc_ajax_static_cache(){
530 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
531
532 $result = array();
533
534 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
535 $c_opt['ahsc_static_cache'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
536 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
537 $result['result'] = $_res;
538 echo wp_json_encode( $result );
539 die();
540 }
541 }
542 //ahsc_lazy_load
543 add_action("wp_ajax_ahsc_lazy_load", "ahsc_ajax_lazy_load");
544 //add_action("wp_ajax_nopriv_ahsc_lazy_load", "ahsc_ajax_lazy_load");
545 function ahsc_ajax_lazy_load(){
546 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
547
548 $result=array();
549 $c_opt=get_option(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME']);
550 $c_opt['ahsc_lazy_load']=isset($_REQUEST['status']) && $_REQUEST['status']==="true";
551 $_res=update_option(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt);
552 $result['result']= $_res;
553 echo wp_json_encode($result);
554 die();
555 }
556 }
557 //ahsc_html_optimizer
558 add_action("wp_ajax_ahsc_html_optimizer", "ahsc_ajax_html_optimizer");
559 //add_action("wp_ajax_nopriv_ahsc_html_optimizer", "ahsc_ajax_html_optimizer");
560 function ahsc_ajax_html_optimizer(){
561 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
562
563 $result = array();
564 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
565 $c_opt['ahsc_html_optimizer'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
566 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
567 $result['result'] = $_res;
568 echo wp_json_encode( $result );
569 die();
570 }
571 }
572 //ahsc_dns_preconnect
573 add_action("wp_ajax_ahsc_dns_preconnect", "ahsc_ajax_dns_preconnect");
574 //add_action("wp_ajax_nopriv_ahsc_dns_preconnect", "ahsc_ajax_dns_preconnect");
575 function ahsc_ajax_dns_preconnect(){
576 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
577
578 $result = array();
579 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
580 $c_opt['ahsc_dns_preconnect'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
581 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
582 $result['result'] = $_res;
583 echo wp_json_encode( $result );
584 die();
585 }
586 }
587 //ahsc_dns_preconnect_domain_list
588 add_action("wp_ajax_ahsc_dns_preconnect_domain_list", "ahsc_ajax_dns_preconnect_domain_list");
589 //add_action("wp_ajax_nopriv_ahsc_dns_preconnect_domain_list", "ahsc_ajax_dns_preconnect_domain_list");
590 function ahsc_ajax_dns_preconnect_domain_list(){
591 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
592
593 $result = array();
594 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
595 $trans_domain_list = array();
596 if(isset($_REQUEST['list'] )){
597 // wp_kses_post() rather than sanitize_text_field(): the <div> wrappers must
598 // survive, because the regex below is what turns them into separators.
599 $trans_domain_list_string = preg_replace( "/<div>(.*?)<\/div>/", "$1;", trim( wp_kses_post( wp_unslash( $_REQUEST['list'] ) ) ) );
600 $trans_domain_list_string = wp_strip_all_tags( $trans_domain_list_string );
601 $trans_domain_list = array_filter( explode( ";", trim( $trans_domain_list_string ) ), fn( $value ) => ! is_null( $value ) && $value !== '' );
602 }
603 foreach ( $trans_domain_list as $index => $string ) {
604 $_check = wp_parse_url( $string );
605
606 if ( $string !== "" ) {
607 if (isset($_SERVER['SERVER_NAME']) && strpos( $string, sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME'])) ) !== false ) {
608 unset( $trans_domain_list[ $index ] );
609 }
610 if ( ! isset( $_check['path'] ) ) {
611 $string .= '/';
612 $_check = wp_parse_url( $string );
613 }
614 if ( ! isset( $_check['scheme'] ) ) {
615 $string = "https://" . $string;
616 } elseif ( $_check['scheme'] === "http" ) {
617 $string = preg_replace( "/^http:/i", "https:", $string );
618 //str_ireplace(array('http://'),'https://',$string);
619 }
620 $trans_domain_list[ $index ] = rtrim( trim( esc_url( $string, array( 'https' ) ) ), "/" );
621 }
622 }
623 $c_opt['ahsc_dns_preconnect_domains'] = $trans_domain_list;
624 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
625 $result['result'] = $_res;
626 echo wp_json_encode( $result );
627 die();
628 }
629 }
630 //ahsc_enable_cron
631 add_action("wp_ajax_ahsc_enable_cron", "ahsc_ajax_enable_cron");
632 //add_action("wp_ajax_nopriv_ahsc_enable_cron", "ahsc_ajax_enable_cron");
633 function ahsc_ajax_enable_cron(){
634 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
635
636 $result = array();
637 $wpc_transformer = new HASC_WPCT( ABSPATH . 'wp-config.php' );
638 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
639 $c_opt['ahsc_enable_cron'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
640 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
641 $result['result'] = $_res;
642
643 if ( $c_opt['ahsc_enable_cron'] ) {
644 //var_dump("non disabilito cron ");
645 $wpc_transformer->remove( 'constant', 'DISABLE_WP_CRON' );
646 } else {
647 //var_dump("disabilito cron ");
648 $wpc_transformer->update( 'constant', 'DISABLE_WP_CRON', 'true', array( 'raw' => true,
649 'normalize' => true
650 ) );
651 $wpc_transformer->remove( 'constant', 'WP_CRON_LOCK_TIMEOUT' );
652 }
653 echo wp_json_encode( $result );
654 die();
655 }
656 }
657 //ahsc_cron_status
658 add_action("wp_ajax_ahsc_cron_status", "ahsc_ajax_cron_status");
659 //add_action("wp_ajax_nopriv_ahsc_cron_status", "ahsc_ajax_cron_status");
660 function ahsc_ajax_cron_status() {
661 if ( is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
662
663 $result = array();
664 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
665 $c_opt['ahsc_cron_status'] = isset($_REQUEST['status']) && $_REQUEST['status'] === "true";
666 $c_opt['ahsc_cron_time'] = $c_opt['ahsc_cron_time'] ?? AHSC_OPTIONS_LIST_DEFAULT['ahsc_cron_time']['default'];
667 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
668 $result['result'] = $_res;
669 echo wp_json_encode( $result );
670 die();
671 }
672 }
673 //ahsc_cron_time
674 add_action("wp_ajax_ahsc_cron_time", "ahsc_ajax_cron_time");
675 //add_action("wp_ajax_nopriv_ahsc_cron_time", "ahsc_ajax_cron_time");
676 function ahsc_ajax_cron_time(){
677 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
678
679 $result = array();
680 $wpc_transformer = new HASC_WPCT( ABSPATH . 'wp-config.php' );
681 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
682 $c_opt['ahsc_cron_time'] = (isset($_REQUEST['time']))?sanitize_text_field(wp_unslash($_REQUEST['time'])):false;
683 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
684 $result['result'] = $_res;
685 //var_dump("setto time ");
686 $wpc_transformer->update( 'constant', 'WP_CRON_LOCK_TIMEOUT', "'" . absint( $c_opt['ahsc_cron_time'] ) . "'", array( 'raw' => true,
687 'normalize' => true
688 ) );
689 echo wp_json_encode( $result );
690 die();
691 }
692 }
693 //ahsc_xmlrpc_status
694 add_action("wp_ajax_ahsc_xmlrpc_status", "ahsc_ajax_xmlrpc_status");
695 //add_action("wp_ajax_nopriv_ahsc_xmlrpc_status", "ahsc_ajax_xmlrpc_status");
696 function ahsc_ajax_xmlrpc_status(){
697 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
698
699 $result = array();
700 $c_opt = get_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'] );
701 $c_opt['ahsc_xmlrpc_status'] = (isset($_REQUEST['status']))?sanitize_text_field(wp_unslash($_REQUEST['status'])):false;
702 $_res = update_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
703 $result['result'] = $_res;
704 echo wp_json_encode( $result );
705 die();
706 }
707 }
708
709 //ahsc_reset_options();
710 add_action("wp_ajax_ahsc_reset_options", "ahsc_ajax_reset_options");
711 //add_action("wp_ajax_nopriv_ahsc_reset_options", "ahsc_ajax_reset_options");
712 function ahsc_ajax_reset_options(){
713 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
714
715 $result = array();
716 $msg = ahsc_reset_options();
717 $result['message'] = $msg;
718 $result['type'] = 'success';
719 $result['action'] = wp_kses( __( 'Reload', 'aruba-hispeed-cache' ), array( 'strong' => array() ) );
720 echo wp_json_encode( $result );
721 die();
722 }
723 }
724
725 //ahsc_debug_status
726 /*add_action("wp_ajax_ahsc_debug_status", "ahsc_ajax_debug_status");
727 add_action("wp_ajax_nopriv_ahsc_debug_status", "ahsc_ajax_debug_status");
728 function ahsc_ajax_debug_status(){
729 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
730 $result = array();
731 $wpc_transformer = new HASC_WPCT( ABSPATH . 'wp-config.php' );
732 if ( $wpc_transformer->exists( 'constant', 'WP_DEBUG' ) ) {
733 $result['result'] = $wpc_transformer->remove( 'constant', 'WP_DEBUG' );
734 } else {
735 $result['result'] = $wpc_transformer->update( 'constant', 'WP_DEBUG', 'true', array( 'raw' => true,
736 'normalize' => true
737 ) );
738 }
739 echo wp_json_encode( $result );
740 die();
741 }
742 }*/
743
744 //ahsc_debug_status
745 add_action("wp_ajax_ahsc_dboptimization", "ahsc_ajax_dboptimization_active");
746 //add_action("wp_ajax_nopriv_ahsc_dboptimization", "ahsc_ajax_dboptimization_active");
747 function ahsc_ajax_dboptimization_active(){
748 if(is_user_logged_in() && current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
749
750 $result = array();
751 $result['message'] = '';
752 $result['type'] = 'success';
753 $result['result'] = AHSC_DBOPT_manage( (isset($_REQUEST['dbstatus'])?sanitize_textarea_field(wp_unslash($_REQUEST['dbstatus'])):null ) );
754 echo wp_json_encode( $result );
755 die();
756 }
757 }