generated from Pierre-Lannoy/wp-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 6
/
apcu-manager.php
155 lines (146 loc) · 4.28 KB
/
apcu-manager.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* Main plugin file.
*
* @package Bootstrap
* @author Pierre Lannoy <https://pierre.lannoy.fr/>.
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: APCu Manager
* Plugin URI: https://perfops.one/apcu-manager
* Description: APCu statistics and management right in the WordPress admin dashboard.
* Version: 4.1.0
* Requires at least: 6.2
* Requires PHP: 8.1
* Author: Pierre Lannoy / PerfOps One
* Author URI: https://perfops.one
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Network: true
* Text Domain: apcu-manager
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/includes/system/class-option.php';
require_once __DIR__ . '/includes/system/class-environment.php';
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/includes/libraries/class-libraries.php';
require_once __DIR__ . '/includes/libraries/autoload.php';
require_once __DIR__ . '/includes/features/class-wpcli.php';
/**
* Copy the file responsible to early initialization in drop-ins dir.
*
* @since 3.0.0
*/
function apcm_check_earlyloading() {
if ( (bool) get_site_option( 'apcm_earlyloading', false ) ) {
if ( defined( 'APCM_BOOTSTRAPPED' ) && APCM_BOOTSTRAPPED ) {
return;
}
if ( ! defined( 'APCM_BOOTSTRAPPED' ) ) {
$target = WP_CONTENT_DIR . '/object-cache.php';
$source = __DIR__ . '/assets/object-cache.php';
if ( file_exists( $target ) && (bool) get_site_option( 'apcm_forceearlyloading', true ) ) {
// phpcs:ignore
@unlink( $target );
define( 'APCM_BOOTSTRAP_ALREADY_EXISTS_REMOVED', true );
}
if ( ! file_exists( $target ) ) {
if ( file_exists( $source ) ) {
// phpcs:ignore
@copy( $source, $target );
// phpcs:ignore
@chmod( $target, 0644 );
}
if ( ! file_exists( $target ) ) {
define( 'APCM_BOOTSTRAP_COPY_ERROR', true );
}
} else {
define( 'APCM_BOOTSTRAP_ALREADY_EXISTS_ERROR', true );
}
}
} else {
if ( defined( 'APCM_BOOTSTRAPPED' ) ) {
$file = WP_CONTENT_DIR . '/object-cache.php';
if ( file_exists( $file ) ) {
// phpcs:ignore
@unlink( $file );
define( 'APCM_BOOTSTRAP_COPY_REMOVED', true );
}
}
}
}
/**
* Removes the file responsible to early initialization in drop-ins dir.
*
* @since 3.1.0
*/
function apcm_reset_earlyloading() {
if ( defined( 'APCM_BOOTSTRAPPED' ) ) {
$target = WP_CONTENT_DIR . '/object-cache.php';
if ( file_exists( $target ) ) {
// phpcs:ignore
@unlink( $target );
}
}
}
/**
* The code that runs during plugin activation.
*
* @since 1.0.0
*/
function apcm_activate() {
APCuManager\Plugin\Activator::activate();
}
/**
* The code that runs during plugin deactivation.
*
* @since 1.0.0
*/
function apcm_deactivate() {
APCuManager\Plugin\Deactivator::deactivate();
}
/**
* The code that runs during plugin uninstallation.
*
* @since 1.0.0
*/
function apcm_uninstall() {
APCuManager\Plugin\Uninstaller::uninstall();
}
/**
* Begins execution of the plugin.
*
* @since 1.0.0
*/
function apcm_run() {
apcm_check_earlyloading();
\DecaLog\Engine::initPlugin( APCM_SLUG, APCM_PRODUCT_NAME, APCM_VERSION, \APCuManager\Plugin\Core::get_base64_logo() );
if ( wp_using_ext_object_cache() ) {
global $wp_object_cache;
if ( method_exists( $wp_object_cache, 'get_manager_id' ) && 'apcm' === $wp_object_cache::get_manager_id() ) {
if ( method_exists( $wp_object_cache, 'set_events_logger' ) ) {
$wp_object_cache::set_events_logger( \DecaLog\Engine::eventsLogger( APCM_SLUG ) );
}
if ( method_exists( $wp_object_cache, 'set_traces_logger' ) ) {
$wp_object_cache::set_traces_logger( \DecaLog\Engine::tracesLogger( APCM_SLUG ) );
}
if ( method_exists( $wp_object_cache, 'set_metrics_logger' ) ) {
$wp_object_cache::set_metrics_logger( \DecaLog\Engine::metricsLogger( APCM_SLUG ) );
}
}
}
\APCuManager\System\Cache::init();
$plugin = new APCuManager\Plugin\Core();
$plugin->run();
}
register_activation_hook( __FILE__, 'apcm_activate' );
register_deactivation_hook( __FILE__, 'apcm_deactivate' );
register_uninstall_hook( __FILE__, 'apcm_uninstall' );
apcm_run();