| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Powered Cache |
| 4 |
* Plugin URI: https://poweredcache.com |
| 5 |
* Description: Powered Cache is the most powerful caching and performance suite for WordPress, designed to easily improve your PageSpeed and Web Vitals Score. |
| 6 |
* Version: 3.7.3 |
| 7 |
* Requires at least: 5.7 |
| 8 |
* Requires PHP: 7.4 |
| 9 |
* Author: Powered Cache |
| 10 |
* Author URI: https://poweredcache.com |
| 11 |
* License: GPL v2 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: powered-cache |
| 14 |
* Domain Path: /languages |
| 15 |
* |
| 16 |
* @package PoweredCache |
| 17 |
*/ |
| 18 |
|
| 19 |
namespace PoweredCache; |
| 20 |
|
| 21 |
use PoweredCache\Extensions\Extensions; |
| 22 |
|
| 23 |
if ( ! defined( 'ABSPATH' ) ) { |
| 24 |
exit; // Exit if accessed directly. |
| 25 |
} |
| 26 |
|
| 27 |
// Useful global constants. |
| 28 |
define( 'POWERED_CACHE_VERSION', '3.7.3' ); |
| 29 |
define( 'POWERED_CACHE_DB_VERSION', '3.4' ); |
| 30 |
define( 'POWERED_CACHE_PLUGIN_FILE', __FILE__ ); |
| 31 |
define( 'POWERED_CACHE_URL', plugin_dir_url( __FILE__ ) ); |
| 32 |
define( 'POWERED_CACHE_PATH', plugin_dir_path( __FILE__ ) ); |
| 33 |
define( 'POWERED_CACHE_INC', POWERED_CACHE_PATH . 'includes/' ); |
| 34 |
define( 'POWERED_CACHE_DROPIN_DIR', POWERED_CACHE_INC . 'dropins/' ); |
| 35 |
define( 'POWERED_CACHE_COMPAT_DIR', POWERED_CACHE_INC . 'compat/' ); |
| 36 |
define( 'POWERED_CACHE_PACKAGE_DIR', POWERED_CACHE_INC . 'package/' ); |
| 37 |
|
| 38 |
if ( ! defined( 'POWERED_CACHE_CACHE_DIR' ) ) { |
| 39 |
define( 'POWERED_CACHE_CACHE_DIR', WP_CONTENT_DIR . '/cache/' ); |
| 40 |
} |
| 41 |
|
| 42 |
if ( ! defined( 'POWERED_CACHE_FO_CACHE_DIR' ) ) { |
| 43 |
define( 'POWERED_CACHE_FO_CACHE_DIR', POWERED_CACHE_CACHE_DIR . 'min/' ); |
| 44 |
} |
| 45 |
|
| 46 |
// Require Composer autoloader if it exists. |
| 47 |
if ( file_exists( POWERED_CACHE_PATH . 'vendor/autoload.php' ) ) { |
| 48 |
require_once POWERED_CACHE_PATH . 'vendor/autoload.php'; |
| 49 |
} |
| 50 |
|
| 51 |
// load packages |
| 52 |
require_once POWERED_CACHE_PACKAGE_DIR . 'deliciousbrains/wp-background-processing/classes/wp-async-request.php'; |
| 53 |
require_once POWERED_CACHE_PACKAGE_DIR . 'deliciousbrains/wp-background-processing/classes/wp-background-process.php'; |
| 54 |
|
| 55 |
/** |
| 56 |
* PSR-4-ish autoloading |
| 57 |
* |
| 58 |
* @since 2.0 |
| 59 |
*/ |
| 60 |
spl_autoload_register( |
| 61 |
function ( $class ) { |
| 62 |
// project-specific namespace prefix. |
| 63 |
$prefix = 'PoweredCache\\'; |
| 64 |
|
| 65 |
// base directory for the namespace prefix. |
| 66 |
$base_dir = __DIR__ . '/includes/classes/'; |
| 67 |
|
| 68 |
// does the class use the namespace prefix? |
| 69 |
$len = strlen( $prefix ); |
| 70 |
|
| 71 |
if ( strncmp( $prefix, $class, $len ) !== 0 ) { |
| 72 |
return; |
| 73 |
} |
| 74 |
|
| 75 |
$relative_class = substr( $class, $len ); |
| 76 |
|
| 77 |
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php'; |
| 78 |
|
| 79 |
// if the file exists, require it. |
| 80 |
if ( file_exists( $file ) ) { |
| 81 |
require $file; |
| 82 |
} |
| 83 |
} |
| 84 |
); |
| 85 |
|
| 86 |
// Include files. |
| 87 |
require_once POWERED_CACHE_INC . 'constants.php'; |
| 88 |
require_once POWERED_CACHE_INC . 'utils.php'; |
| 89 |
require_once POWERED_CACHE_INC . 'core.php'; |
| 90 |
require_once POWERED_CACHE_INC . 'admin/dashboard.php'; |
| 91 |
require_once POWERED_CACHE_INC . 'admin/notices.php'; |
| 92 |
require_once POWERED_CACHE_COMPAT_DIR . 'loader.php'; |
| 93 |
|
| 94 |
$network_activated = Utils\is_network_wide( POWERED_CACHE_PLUGIN_FILE ); |
| 95 |
if ( ! defined( 'POWERED_CACHE_IS_NETWORK' ) ) { |
| 96 |
define( 'POWERED_CACHE_IS_NETWORK', $network_activated ); |
| 97 |
} |
| 98 |
|
| 99 |
if ( Utils\is_dev_mode_active() ) { |
| 100 |
DevMode::setup(); |
| 101 |
|
| 102 |
$frontend_request = ! ( |
| 103 |
( function_exists( 'is_admin' ) && is_admin() ) |
| 104 |
|| ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| 105 |
|| ( defined( 'DOING_CRON' ) && DOING_CRON ) |
| 106 |
|| ( defined( 'WP_CLI' ) && WP_CLI ) |
| 107 |
); |
| 108 |
|
| 109 |
// don't run the plugin for frontend requests in dev mode |
| 110 |
if ( $frontend_request ) { |
| 111 |
return; |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
if ( Utils\bypass_request() ) { |
| 116 |
return; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
// Bootstrap. |
| 121 |
Core\setup(); |
| 122 |
Admin\Dashboard\setup(); |
| 123 |
Admin\Notices\setup(); |
| 124 |
Install::factory(); |
| 125 |
AdvancedCache::factory(); |
| 126 |
ObjectCache::factory(); |
| 127 |
CDN::factory(); |
| 128 |
Cron::factory(); |
| 129 |
Preloader::factory(); |
| 130 |
FileOptimizer::factory(); |
| 131 |
LazyLoad::factory(); |
| 132 |
Preloader::factory(); |
| 133 |
MetaBox::factory(); |
| 134 |
Extensions::factory(); |
| 135 |
|
| 136 |
// Activation/Deactivation. |
| 137 |
register_activation_hook( __FILE__, '\PoweredCache\Core\activate' ); |
| 138 |
register_deactivation_hook( __FILE__, '\PoweredCache\Core\deactivate' ); |
| 139 |
|