-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject-cache.php
More file actions
55 lines (51 loc) · 1.62 KB
/
object-cache.php
File metadata and controls
55 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
* Plugin Name: WordPress Cache
* Description: A Simple Object Cache
* Version: 0.1
* Requires PHP: 8.2
* Author: Matt Maiorano
* Author URI: https://mattmaiorano.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: maiorano
*/
add_action('init', function(){
global $wp_object_cache;
if(!is_admin()) {
$wp_object_cache->stats();
}
});
/* register_activation_hook( __FILE__, function() {
$sys = loadFileSystem();
if($sys !== false ) {
$dropinPath = WP_CONTENT_DIR . '/object-cache.php';
if($sys->exists($dropinPath)) {
$sys->move($dropinPath, $dropinPath . '.bak');
}
$sys->copy( __DIR__ . '/dropin/object-cache.php', $dropinPath, true, FS_CHMOD_FILE );
wp_cache_flush();
}
} );
register_deactivation_hook( __FILE__, function() {
$sys = loadFileSystem();
if($sys !== false ) {
$dropinPath = WP_CONTENT_DIR . '/object-cache.php';
if($sys->exists($dropinPath)) {
$sys->delete($dropinPath, false, 'f');
}
if($sys->exists($dropinPath . '.bak')) {
$sys->move($dropinPath . '.bak', $dropinPath);
}
wp_cache_flush();
}
} );
function loadFileSystem() {
$url = wp_nonce_url(plugin_dir_url(__FILE__), 'wp-symfony-cache-move');
$creds = request_filesystem_credentials( $url, '', false, WP_CONTENT_DIR, null );
if($creds !== false && WP_Filesystem($creds) ) {
global $wp_filesystem;
return $wp_filesystem;
}
return false;
} */