PluginProbe
atec Cache APCu / 2.3.8
atec Cache APCu v2.3.8
2.3.77 2.1.51 2.1.52 2.1.53 2.1.55 2.1.56 2.1.57 2.1.58 2.1.59 2.1.60 2.1.61 2.1.62 2.1.63 2.1.65 2.1.66 2.1.67 2.1.68 2.1.72 2.1.79 2.1.8 2.1.80 2.1.81 2.1.82 2.1.83 2.1.84 All 105 releases
atec-cache-apcu / atec-cache-apcu.php

atec-cache-apcu.php in atec Cache APCu 2.3.8, at atec-cache-apcu.php

121 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: atec Cache APCu
4 * Plugin URI: https://atecplugins.com/
5 * Description: Super fast APCu-Object-Cache and the only APCu based page-cache plugin available.
6 * Version: 2.3.8
7 * Requires at least:4.9
8 * Tested up to: 6.8
9 * Tested up to PHP: 8.4.2
10 * Requires PHP: 7.4
11 * Requires CP: 1.7
12 * Premium URI: https://atecplugins.com
13 * Author: Chris Ahrweiler �
14 atecplugins.com
15 * Author URI: https://atec-systems.com/
16 * License: GPL2
17 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
18 * Text Domain: atec-cache-apcu
19 */
20 namespace ATEC;
21
22 defined('ABSPATH') || exit;
23 if (!defined('ATEC_LOADER')) { require __DIR__ . '/includes/ATEC/LOADER.php'; }
24
25 use ATEC\INIT;
26 use ATEC\WPC;
27 use ATEC\WPCA;
28
29 INIT::set_version('wpca', '2.3.8');
30
31 if (INIT::is_real_admin())
32 {
33 INIT::register_activation_deactivation_hook(__FILE__, 1, 1, 'wpca');
34 add_action('admin_menu', fn() => INIT::menu(__DIR__, 'wpca', 'Cache APCu'));
35
36 add_action('admin_init', function ()
37 {
38 if (!INIT::current_user_can('admin')) return;
39
40 if (INIT::is_plugins_page()) INIT::add_plugin_settings(__FILE__);
41 INIT::maybe_register_settings(__DIR__, 'wpca', true, '&flushWPCA');
42
43 if (WPCA::apcu_enabled())
44 {
45 $o_admin = WPCA::settings('o_cache') && WPCA::settings('o_admin');
46 $p_admin = WPCA::settings('p_cache') && WPCA::settings('p_admin');
47
48 if ($o_admin || $p_admin)
49 {
50 add_action('admin_bar_menu', function($wp_admin_bar) use($o_admin, $p_admin)
51 {
52 if ($o_admin) INIT::admin_bar($wp_admin_bar, 'wpca', 'flush&type=WP', 'Cache', 'oc', 'OC#Flush object cache.', true);
53 if ($p_admin) INIT::admin_bar($wp_admin_bar, 'wpca', 'flush', 'Page_Cache', 'pc', 'PC#Flush page cache.', true);
54 }, 999);
55 }
56 }
57 });
58
59 (function() {
60
61 if (WPCA::apcu_enabled())
62 {
63 $p_cache = WPCA::settings('p_cache');
64 if ($p_cache)
65 {
66 require __DIR__.'/includes/atec-wpca-pcache-tools.php';
67
68 foreach (['after_switch_theme', 'wp_ajax_edit_theme_plugin_file', 'wp_update_nav_menu', 'wp_delete_nav_menu'] as $hook)
69 add_action($hook, function() { \ATEC_WPCA\Tools::delete_page_cache_all(); });
70
71 foreach (['create_category', 'delete_category'] as $hook)
72 add_action($hook, [\ATEC_WPCA\Tools::class, 'on_category_change'], 10, 1);
73
74 add_action('edited_category', [\ATEC_WPCA\Tools::class, 'on_category_edit'], 10, 2);
75
76 foreach (['created_term', 'delete_term'] as $hook)
77 add_action($hook, [\ATEC_WPCA\Tools::class, 'on_tag_change'], 10, 3);
78
79 add_action('edited_terms', [\ATEC_WPCA\Tools::class, 'on_tag_edit'], 10, 3);
80 }
81
82 if ($p_cache || WPCA::settings('o_cache'))
83 {
84 foreach (['activated_plugin', 'deactivated_plugin', 'upgrader_pre_install'] as $hook)
85 {
86 add_action($hook, function() use($p_cache)
87 {
88 WPC::flush_wp_cache_options();
89 if ($p_cache) \ATEC_WPCA\Tools::delete_page_cache_all();
90 });
91 }
92 }
93
94 }
95
96 })();
97
98 if (defined('ATEC_OC_ACTIVE_APCU') && defined('ATEC_OC_VERSION') && ATEC_OC_VERSION!== '2.0.3')
99 {
100 require(__DIR__.'/includes/atec-wpca-install-object-cache.php');
101 \ATEC_WPCA\Install_OCache::init(true);
102 }
103 }
104 else // not is_real_admin
105 {
106 if (INIT::is_interactive())
107 {
108 if (!defined('ATEC_PC_ACTIVE_APCU') && WPCA::settings('p_cache'))
109 {
110 require(__DIR__.'/includes/atec-wpca-pcache.php');
111 add_action('init', ['\ATEC_WPCA\\PCache', 'init'], -1);
112 }
113 }
114 }
115
116 if (!INIT::is_cli() && !INIT::is_cron())
117 { if (WPCA::apcu_enabled() && WPCA::settings('p_cache')) require(__DIR__.'/includes/atec-wpca-pcache-comments.php'); }
118
119 if (INIT::is_interactive())
120 { if (defined('ATEC_OC_ACTIVE_APCU') && WPCA::settings('o_stats')) register_shutdown_function([WPCA::class, 'o_cache_stats']); }
121 ?>