PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.30
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.30
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / berqwp.php

berqwp.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.30, at berqwp.php

160 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: BerqWP
4 * Plugin URI: https://berqwp.com/
5 * Description: Automatically boost your WordPress website speed. Includes full-page caching, image optimization, CSS/JS delivery, and Core Web Vitals improvements.
6 * Version: 4.0.30
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 * Network: true
14 * License: GPL-2.0-or-later
15 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
16 */
17
18 if (!defined('ABSPATH')) exit;
19
20 if (!defined('BERQWP_VERSION')) {
21 define('BERQWP_VERSION', '4.0.30');
22 }
23
24 if (!defined('optifer_PATH')) {
25 define('optifer_PATH', plugin_dir_path(__FILE__));
26 }
27
28 if (!defined('optifer_URL')) {
29 define('optifer_URL', plugin_dir_url(__FILE__));
30 }
31
32 if (!defined('optifer_cache')) {
33 define('optifer_cache', WP_CONTENT_DIR . '/cache/berqwp/');
34 }
35
36 if (!defined('BERQ_SERVER')) {
37 define('BERQ_SERVER', 'https://berqwp.com/');
38 }
39
40 if (!defined('BERQ_SECRET')) {
41 define('BERQ_SECRET', '64bc22f838e982.66069471');
42 }
43
44 // define('BERQWP_DISABLE_CACHE_WARMUP', true);
45
46 if (!file_exists(optifer_cache)) {
47 mkdir(optifer_cache, 0755, true);
48 }
49
50 if (isset($_GET['disable_berqwp'])) {
51 return;
52 }
53
54 global $bwp_current_page;
55 $bwp_current_page = null;
56
57 // Initialize BerqWP SDK
58 require_once optifer_PATH . '/BerqWP/vendor-prefixed/vendor/scoper-autoload.php';
59 // require_once optifer_PATH . '/BerqWP/src/Vendor/SimpleHtmlDom/simple_html_dom.php';
60
61 require_once optifer_PATH . '/inc/crawler/berqDetectCrawler.php';
62 require_once optifer_PATH . '/inc/class-berqconfigs.php';
63 // require_once optifer_PATH . '/vendor/autoload.php';
64 // require_once optifer_PATH . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
65 require_once optifer_PATH . '/inc/class-berqlogs.php';
66 require_once optifer_PATH . '/inc/helper-functions.php';
67 require_once optifer_PATH . '/inc/common-functions.php';
68 require_once optifer_PATH . '/inc/dropin-functions.php';
69 require_once optifer_PATH . '/inc/photon/class-berqUsedCSS.php';
70 require_once optifer_PATH . '/inc/photon/class-berqPageOptimizer.php';
71 require_once optifer_PATH . '/inc/class-berqintegrations.php';
72 require_once optifer_PATH . '/inc/class-berqwp.php';
73 require_once optifer_PATH . '/inc/class-berqnotifications.php';
74
75 // cache
76 require_once optifer_PATH . '/inc/cache/class-berqcache.php';
77 require_once optifer_PATH . '/inc/cache/class-berqwarmup.php';
78 require_once optifer_PATH . '/inc/cache/class-berqCloudflareAPIHandler.php';
79 require_once optifer_PATH . '/inc/cache/class-berqreverseproxy.php';
80 require_once optifer_PATH . '/inc/cache/class-ignoreparams.php';
81
82 // queue
83 require_once optifer_PATH . '/inc/queue/class-berqUpload.php';
84 require_once optifer_PATH . '/inc/queue/class-berqHeartbeat.php';
85
86 // admin
87 require_once optifer_PATH . '/admin/class-berqPageRules.php';
88 require_once optifer_PATH . '/admin/admin-bar.php';
89
90 if (get_option('berqwp_enable_sandbox') == 0) {
91 bwp_serve_advanced_cache();
92 }
93 // register_shutdown_function('bwp_cache_current_page');
94
95 // Redirect to BerqWP admin page after activation
96 register_activation_hook(__FILE__, 'berqwp_activation');
97 register_deactivation_hook(__FILE__, 'berqwp_deactivate_plugin');
98
99 function berqwp_activation($network_wide = false)
100 {
101 if (function_exists('is_multisite') && is_multisite() && $network_wide) {
102 // Network-wide activation: activate for each site
103 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
104 foreach ($sites as $site_id) {
105 switch_to_blog($site_id);
106 berqwp_activate_single_site();
107 restore_current_blog();
108 }
109 } else {
110 berqwp_activate_single_site();
111 }
112
113 // Install the advanced-cache.php drop-in (shared across network)
114 berqwp_install_dropin();
115 }
116
117 function berqwp_install_dropin()
118 {
119 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
120 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
121 } else {
122 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
123 }
124
125 if (!file_exists($dropin_file) || (file_exists($dropin_file) && is_writable($dropin_file))) {
126 $dropin_content = file_get_contents(optifer_PATH . 'advanced-cache.php');
127 file_put_contents($dropin_file, $dropin_content);
128 berqwp_enable_advanced_cache(true);
129 }
130 }
131
132 function berqwp_deactivate_plugin($network_wide = false) {
133
134 // Remove the shared drop-in
135 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
136 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
137 } else {
138 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
139 }
140
141 if (file_exists($dropin_file)) {
142 unlink($dropin_file);
143 }
144
145 berqwp_enable_advanced_cache(false);
146
147 if (function_exists('is_multisite') && is_multisite() && $network_wide) {
148 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
149 foreach ($sites as $site_id) {
150 switch_to_blog($site_id);
151 do_action('berqwp_deactivate_plugin');
152 restore_current_blog();
153 }
154 } else {
155 do_action('berqwp_deactivate_plugin');
156 }
157 }
158
159 bwp_lock_cache_directory();
160