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 / src / AHSC_Apc.php
aruba-hispeed-cache / src Last commit date
APC 3 days ago Events 3 days ago Purger 3 days ago assets 3 days ago AHSC_Apc.php 3 days ago AHSC_Check.php 3 days ago AHSC_Config.php 3 days ago AHSC_Dboptimization.php 3 days ago AHSC_Functions.php 3 days ago AHSC_HtmlOptimizer.php 5 months ago AHSC_Lazyload.php 3 days ago AHSC_Preconnect.php 5 months ago AHSC_Static.php 4 months ago AHSC_Version.php 5 months ago AHSC_Warmer.php 3 days ago AHSC_XmlRPC.php 5 months ago index.php 5 months ago
AHSC_Apc.php
103 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 add_action("wp_ajax_ahsc_check_apc_file", "ahsc_check_apc_file");
6 //add_action("wp_ajax_nopriv_ahsc_check_apc_file", "ahsc_check_apc_file");
7
8 function ahsc_check_apc_file() {
9 $target = WP_CONTENT_DIR . '/object-cache.php';
10 $result=array();
11
12 if (file_exists( $target )) {
13 $result['message']=AHSC_Notice_Render('ahsc-service-error', 'error',\wp_kses(
14 __( '<strong>Another plugin use object cache.</strong> Deactivate the plugin or functionality and retry.', 'aruba-hispeed-cache' ),
15 array(
16 'strong' => array(),
17 )
18 ), true );
19 $result['result']= false;
20 }else {
21 $result['result']= true;
22 }
23
24 echo wp_json_encode($result);
25 die();
26 }
27
28 add_action("wp_ajax_ahsc_create_apc_file", "ahsc_create_apc_file");
29 //add_action("wp_ajax_nopriv_ahsc_create_apc_file", "ahsc_create_apc_file");
30 function ahsc_create_apc_file(){
31 if(current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
32 $result = array();
33 $target = WP_CONTENT_DIR . '/object-cache.php';
34 $source = __DIR__ . '/APC/object-cache.php';
35
36 /*
37 * Was copy() followed by a separate chmod( $target, 0644 ). WP_Filesystem::copy()
38 * does both in one call — the fourth argument is the mode — and works on hosts
39 * where PHP cannot write directly and WordPress falls back to FTP or SSH. Where
40 * copy() used to succeed, get_filesystem_method() selects the "direct" transport,
41 * which is a plain copy() plus chmod, so nothing changes. The third argument is
42 * true because PHP's copy() overwrites by default and WP_Filesystem's does not.
43 */
44 require_once ABSPATH . 'wp-admin/includes/file.php';
45 global $wp_filesystem;
46
47 $is_copied = false;
48
49 if ( WP_Filesystem() && $wp_filesystem instanceof WP_Filesystem_Base ) {
50 $is_copied = $wp_filesystem->copy( $source, $target, true, FS_CHMOD_FILE );
51 } else {
52 AHSC_log( 'Could not initialise WP_Filesystem, the object-cache.php drop-in was not installed.', 'apcu', 'warning' );
53 }
54
55 if ( ! $is_copied ) {
56 AHSC_log( sprintf( 'Could not install the object-cache.php drop-in into %s.', WP_CONTENT_DIR ), 'apcu', 'warning' );
57 }
58
59 /*
60 * Was hard-coded to true regardless of the outcome: a failed copy still answered
61 * "ok", the interface ticked the checkbox and the follow-up call switched the
62 * ahsc_apc option on for a drop-in that had never been written.
63 */
64 $result['result'] = (bool) $is_copied;
65 echo wp_json_encode( $result );
66 }
67 die();
68 }
69 add_action("wp_ajax_ahsc_update_apc_Settings", "ahsc_update_apc_Settings");
70 //add_action("wp_ajax_nopriv_ahsc_update_apc_Settings", "ahsc_update_apc_Settings");
71 function ahsc_update_apc_Settings() {
72 if(current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
73 $result = array();
74 $c_opt = AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS'];
75 $c_opt['ahsc_apc'] = true;
76 update_site_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
77 $result['result'] = true;
78 echo wp_json_encode( $result );
79 }
80 die();
81 }
82
83
84 add_action("wp_ajax_ahsc_delete_apc_file", "ahsc_delete_apc_file");
85 //add_action("wp_ajax_nopriv_ahsc_delete_apc_file", "ahsc_delete_apc_file");
86 function ahsc_delete_apc_file(){
87 if(current_user_can( 'manage_options' ) && isset($_POST['ahsc_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash( $_POST['ahsc_nonce'])), 'ahsc-purge-cache' )) {
88 $result = array();
89 $file = WP_CONTENT_DIR . '/object-cache.php';
90 $c_opt = AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS'];
91 if ( file_exists( $file ) ) {
92 \wp_delete_file( $file );
93 $result['result'] = true;
94
95 }
96 //$c_opt=get_site_option(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME']);
97 $c_opt['ahsc_apc'] = false;
98 update_site_option( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS_NAME'], $c_opt );
99
100 echo wp_json_encode( $result );
101 }
102 die();
103 }