| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: BerqWP |
| 4 |
* Plugin URI: https://berqwp.com |
| 5 |
* Description: Automatically pass Core Web Vitals for WordPress and boost your speed score to 90+ for both mobile and desktop without any technical skills. |
| 6 |
* Version: 1.9.4 |
| 7 |
* Requires at least: 5.3 |
| 8 |
* Requires PHP: 7.4 |
| 9 |
* Author: BerqWP |
| 10 |
* Author URI: https://berqwp.com |
| 11 |
* Text Domain: searchpro |
| 12 |
* Domain Path: /languages |
| 13 |
*/ |
| 14 |
|
| 15 |
if (!defined('ABSPATH')) exit; |
| 16 |
|
| 17 |
if (class_exists('berqWP')) { |
| 18 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 19 |
$free_plugin_path = 'berqwp-lite/berqwp-lite.php'; |
| 20 |
if (is_plugin_active($free_plugin_path)) { |
| 21 |
deactivate_plugins($free_plugin_path); |
| 22 |
} |
| 23 |
$free_plugin_path = 'berqwp/berqwp.php'; |
| 24 |
if (is_plugin_active($free_plugin_path)) { |
| 25 |
deactivate_plugins($free_plugin_path); |
| 26 |
} |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
if (!defined('BERQWP_VERSION')) { |
| 31 |
define('BERQWP_VERSION', '1.9.4'); |
| 32 |
} |
| 33 |
|
| 34 |
if (!defined('optifer_PATH')) { |
| 35 |
define('optifer_PATH', plugin_dir_path(__FILE__)); |
| 36 |
} |
| 37 |
|
| 38 |
if (!defined('optifer_URL')) { |
| 39 |
define('optifer_URL', plugin_dir_url(__FILE__)); |
| 40 |
} |
| 41 |
|
| 42 |
if (!defined('optifer_cache')) { |
| 43 |
define('optifer_cache', WP_CONTENT_DIR . '/cache/berqwp/'); |
| 44 |
} |
| 45 |
|
| 46 |
if (!defined('BERQ_SERVER')) { |
| 47 |
define('BERQ_SERVER', 'https://berqwp.com/'); |
| 48 |
} |
| 49 |
|
| 50 |
if (!defined('BERQ_SECRET')) { |
| 51 |
define('BERQ_SECRET', '64bc22f838e982.66069471'); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
if (!defined('BERQWP_MAX_WARMUP_REQUESTS')) { |
| 56 |
define('BERQWP_MAX_WARMUP_REQUESTS', 1); // The maximum number of requests in our rate limit window. |
| 57 |
} |
| 58 |
|
| 59 |
if (!defined('BERQWP_WARMUP_RATE_LIMIT_WINDOW')) { |
| 60 |
define('BERQWP_WARMUP_RATE_LIMIT_WINDOW', 125); // Time window for rate limit in seconds, i.e., 5 minutes. |
| 61 |
} |
| 62 |
|
| 63 |
if (!file_exists(optifer_cache)) { |
| 64 |
mkdir(optifer_cache, 0755, true); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
// if (isset($_GET['generating_critical_css']) |
| 69 |
// || isset($_GET['nocache']) |
| 70 |
// || isset($_GET['creating_cache'])) { |
| 71 |
|
| 72 |
// add_filter( 'berqwp_bypass_cache', function () { return true; } ); |
| 73 |
|
| 74 |
// if (berqReverseProxyCache::is_reverse_proxy_cache_enabled()) { |
| 75 |
// berqReverseProxyCache::bypass(); |
| 76 |
// } |
| 77 |
|
| 78 |
// if (!class_exists('HMWP_Models_Compatibility_Abstract')) { |
| 79 |
// return; |
| 80 |
// } |
| 81 |
// } |
| 82 |
|
| 83 |
|
| 84 |
// if (get_option('berqwp_enable_sandbox') == 1 && !isset($_GET['berqwp']) && !is_admin() && !isset($_POST)) { |
| 85 |
// return; |
| 86 |
// } |
| 87 |
|
| 88 |
require_once optifer_PATH . '/inc/class-berqreverseproxy.php'; |
| 89 |
require_once optifer_PATH . '/inc/class-ignoreparams.php'; |
| 90 |
require_once optifer_PATH . '/inc/class-MemoryLeakDetector.php'; |
| 91 |
require_once optifer_PATH . '/vendor/autoload.php'; |
| 92 |
require_once optifer_PATH . '/vendor/woocommerce/action-scheduler/action-scheduler.php'; |
| 93 |
require_once optifer_PATH . '/inc/class-berqlogs.php'; |
| 94 |
require_once optifer_PATH . '/inc/helper-functions.php'; |
| 95 |
require_once optifer_PATH . '/inc/classs-http.php'; |
| 96 |
require_once optifer_PATH . '/inc/photon/class-berqPageOptimizer.php'; |
| 97 |
require_once optifer_PATH . '/inc/photon/class-berqBufferOptimize.php'; |
| 98 |
require_once optifer_PATH . '/inc/photon/class-styleOptimizer.php'; |
| 99 |
require_once optifer_PATH . '/inc/photon/class-scriptOptimizer.php'; |
| 100 |
require_once optifer_PATH . '/inc/photon/class-berqImages.php'; |
| 101 |
require_once optifer_PATH . '/inc/photon/class-berqCDN.php'; |
| 102 |
require_once optifer_PATH . '/inc/photon/class-berqCriticalCSS.php'; |
| 103 |
require_once optifer_PATH . '/inc/photon/integration/index.php'; |
| 104 |
require_once optifer_PATH . '/inc/class-berqcache.php'; |
| 105 |
require_once optifer_PATH . '/inc/class-berqwp.php'; |
| 106 |
require_once optifer_PATH . '/inc/class-berqimages.php'; |
| 107 |
require_once optifer_PATH . '/inc/class-berqintegrations.php'; |
| 108 |
require_once optifer_PATH . '/inc/class-berqnotifications.php'; |
| 109 |
|
| 110 |
|
| 111 |
// Redirect to BerqWP admin page after activation |
| 112 |
register_activation_hook(__FILE__, 'berqwp_activation'); |
| 113 |
register_deactivation_hook(__FILE__, 'berqwp_deactivate_plugin'); |
| 114 |
|
| 115 |
function berqwp_activation() |
| 116 |
{ |
| 117 |
// Specify the drop-in file path |
| 118 |
$dropin_file = ABSPATH . 'wp-content/advanced-cache.php'; |
| 119 |
|
| 120 |
// Dynamically create the drop-in file |
| 121 |
$dropin_content = file_get_contents(optifer_PATH . 'advanced-cache.php'); |
| 122 |
|
| 123 |
// Write the drop-in content to the file, replacing any existing file |
| 124 |
file_put_contents($dropin_file, $dropin_content); |
| 125 |
|
| 126 |
// Enable object cache in wp-config.php |
| 127 |
berqwp_enable_object_cache(true); |
| 128 |
|
| 129 |
if (function_exists('wp_cache_flush')) { |
| 130 |
wp_cache_flush(); // Clear the entire object cache. |
| 131 |
} |
| 132 |
|
| 133 |
set_transient( 'bqwp_hide_feedback_notice', true, 60*60 ); // Hide for one hour |
| 134 |
set_transient('berqwp_redirect', true, 1); |
| 135 |
} |
| 136 |
|
| 137 |
function berqwp_deactivate_plugin() { |
| 138 |
// Specify the drop-in file path |
| 139 |
$dropin_file = ABSPATH . 'wp-content/advanced-cache.php'; |
| 140 |
|
| 141 |
// Check if the drop-in file exists and delete it |
| 142 |
if (file_exists($dropin_file)) { |
| 143 |
unlink($dropin_file); |
| 144 |
} |
| 145 |
|
| 146 |
// Disable object cache in wp-config.php |
| 147 |
berqwp_enable_object_cache(false); |
| 148 |
} |