PluginProbe
APCu Manager / trunk
APCu Manager vtrunk
4.6.0 4.6.1 4.5.4 4.5.2 4.5.3 4.5.1 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.4.1 2.5.0 2.6.0 3.0.0 3.0.1 3.1.0 All 49 releases
apcu-manager / apcu-manager.php

apcu-manager.php in APCu Manager trunk, at apcu-manager.php

156 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main plugin file.
4 *
5 * @package Bootstrap
6 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
7 * @since 1.0.0
8 *
9 * @wordpress-plugin
10 * Plugin Name: APCu Manager
11 * Plugin URI: https://perfops.one/apcu-manager
12 * Description: APCu statistics and management right in the WordPress admin dashboard.
13 * Version: 4.6.1
14 * Requires at least: 6.4
15 * Requires PHP: 8.2
16 * Author: Pierre Lannoy / PerfOps One
17 * Author URI: https://perfops.one
18 * License: GPLv3
19 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
20 * Network: true
21 * Text Domain: apcu-manager
22 * Domain Path: /languages
23 */
24
25 // If this file is called directly, abort.
26 if ( ! defined( 'WPINC' ) ) {
27 die;
28 }
29
30 require_once __DIR__ . '/init.php';
31 require_once __DIR__ . '/functions.php';
32 require_once __DIR__ . '/includes/system/class-option.php';
33 require_once __DIR__ . '/includes/system/class-environment.php';
34 require_once __DIR__ . '/autoload.php';
35 require_once __DIR__ . '/includes/libraries/class-libraries.php';
36 require_once __DIR__ . '/includes/libraries/autoload.php';
37 require_once __DIR__ . '/includes/features/class-wpcli.php';
38
39 /**
40 * Copy the file responsible to early initialization in drop-ins dir.
41 *
42 * @since 3.0.0
43 */
44 function apcm_check_earlyloading() {
45 if ( (bool) get_site_option( 'apcm_earlyloading', false ) ) {
46 if ( defined( 'APCM_BOOTSTRAPPED' ) && APCM_BOOTSTRAPPED ) {
47 return;
48 }
49 if ( ! defined( 'APCM_BOOTSTRAPPED' ) ) {
50 $target = WP_CONTENT_DIR . '/object-cache.php';
51 $source = __DIR__ . '/assets/object-cache.php';
52 if ( file_exists( $target ) && (bool) get_site_option( 'apcm_forceearlyloading', true ) ) {
53 // phpcs:ignore
54 @unlink( $target );
55 define( 'APCM_BOOTSTRAP_ALREADY_EXISTS_REMOVED', true );
56 }
57 if ( ! file_exists( $target ) ) {
58 if ( file_exists( $source ) ) {
59 // phpcs:ignore
60 @copy( $source, $target );
61 // phpcs:ignore
62 @chmod( $target, 0644 );
63 }
64 if ( ! file_exists( $target ) ) {
65 define( 'APCM_BOOTSTRAP_COPY_ERROR', true );
66 }
67 } else {
68 define( 'APCM_BOOTSTRAP_ALREADY_EXISTS_ERROR', true );
69 }
70 }
71 } else {
72 if ( defined( 'APCM_BOOTSTRAPPED' ) ) {
73 $file = WP_CONTENT_DIR . '/object-cache.php';
74 if ( file_exists( $file ) ) {
75 // phpcs:ignore
76 @unlink( $file );
77 define( 'APCM_BOOTSTRAP_COPY_REMOVED', true );
78 }
79 }
80 }
81 }
82
83 /**
84 * Removes the file responsible to early initialization in drop-ins dir.
85 *
86 * @since 3.1.0
87 */
88 function apcm_reset_earlyloading() {
89 if ( defined( 'APCM_BOOTSTRAPPED' ) ) {
90 $target = WP_CONTENT_DIR . '/object-cache.php';
91 if ( file_exists( $target ) ) {
92 // phpcs:ignore
93 @unlink( $target );
94 }
95 }
96 }
97
98 /**
99 * The code that runs during plugin activation.
100 *
101 * @since 1.0.0
102 */
103 function apcm_activate() {
104 APCuManager\Plugin\Activator::activate();
105 }
106
107 /**
108 * The code that runs during plugin deactivation.
109 *
110 * @since 1.0.0
111 */
112 function apcm_deactivate() {
113 APCuManager\Plugin\Deactivator::deactivate();
114 }
115
116 /**
117 * The code that runs during plugin uninstallation.
118 *
119 * @since 1.0.0
120 */
121 function apcm_uninstall() {
122 APCuManager\Plugin\Uninstaller::uninstall();
123 }
124
125 /**
126 * Begins execution of the plugin.
127 *
128 * @since 1.0.0
129 */
130 function apcm_run() {
131 apcm_check_earlyloading();
132 \DecaLog\Engine::initPlugin( APCM_SLUG, APCM_PRODUCT_NAME, APCM_VERSION, \APCuManager\Plugin\Core::get_base64_logo() );
133 if ( wp_using_ext_object_cache() ) {
134 global $wp_object_cache;
135 if ( method_exists( $wp_object_cache, 'get_manager_id' ) && 'apcm' === $wp_object_cache::get_manager_id() ) {
136 if ( method_exists( $wp_object_cache, 'set_events_logger' ) ) {
137 $wp_object_cache::set_events_logger( \DecaLog\Engine::eventsLogger( APCM_SLUG ) );
138 }
139 if ( method_exists( $wp_object_cache, 'set_traces_logger' ) ) {
140 $wp_object_cache::set_traces_logger( \DecaLog\Engine::tracesLogger( APCM_SLUG ) );
141 }
142 if ( method_exists( $wp_object_cache, 'set_metrics_logger' ) ) {
143 $wp_object_cache::set_metrics_logger( \DecaLog\Engine::metricsLogger( APCM_SLUG ) );
144 }
145 }
146 }
147 \APCuManager\System\Cache::init();
148 $plugin = new APCuManager\Plugin\Core();
149 $plugin->run();
150 }
151
152 register_activation_hook( __FILE__, 'apcm_activate' );
153 register_deactivation_hook( __FILE__, 'apcm_deactivate' );
154 register_uninstall_hook( __FILE__, 'apcm_uninstall' );
155 apcm_run();
156