PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.16
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.16
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.1.16, at berqwp.php

162 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.1.16
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.1.16');
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 . '/inc/class-berqdatabase.php';
64 // require_once optifer_PATH . '/vendor/autoload.php';
65 // require_once optifer_PATH . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
66 require_once optifer_PATH . '/inc/class-berqlogs.php';
67 require_once optifer_PATH . '/inc/helper-functions.php';
68 require_once optifer_PATH . '/inc/common-functions.php';
69 require_once optifer_PATH . '/inc/dropin-functions.php';
70 require_once optifer_PATH . '/inc/photon/class-berqUsedCSS.php';
71 require_once optifer_PATH . '/inc/photon/class-berqPageOptimizer.php';
72 require_once optifer_PATH . '/inc/class-berqintegrations.php';
73 require_once optifer_PATH . '/inc/class-berqwp.php';
74 require_once optifer_PATH . '/inc/class-berqnotifications.php';
75
76 // cache
77 require_once optifer_PATH . '/inc/cache/class-berqcache.php';
78 require_once optifer_PATH . '/inc/cache/class-berqwarmup.php';
79 require_once optifer_PATH . '/inc/cache/class-berqCloudflareAPIHandler.php';
80 require_once optifer_PATH . '/inc/cache/class-berqreverseproxy.php';
81 require_once optifer_PATH . '/inc/cache/class-ignoreparams.php';
82
83 // queue
84 require_once optifer_PATH . '/inc/queue/class-berqUpload.php';
85 require_once optifer_PATH . '/inc/queue/class-berqHeartbeat.php';
86
87 // admin
88 require_once optifer_PATH . '/admin/class-berqPageRules.php';
89 require_once optifer_PATH . '/admin/admin-bar.php';
90
91 if (get_option('berqwp_enable_sandbox') == 0) {
92 bwp_serve_advanced_cache();
93 }
94 // register_shutdown_function('bwp_cache_current_page');
95
96 // Redirect to BerqWP admin page after activation
97 register_activation_hook(__FILE__, 'berqwp_activation');
98 register_deactivation_hook(__FILE__, 'berqwp_deactivate_plugin');
99
100 function berqwp_activation($network_wide = false)
101 {
102 if (function_exists('is_multisite') && is_multisite() && $network_wide) {
103 // Network-wide activation: activate for each site
104 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
105 foreach ($sites as $site_id) {
106 switch_to_blog($site_id);
107 berqwp_activate_single_site();
108 restore_current_blog();
109 }
110 } else {
111 berqwp_activate_single_site();
112 }
113
114 // Install the advanced-cache.php drop-in (shared across network)
115 berqwp_install_dropin();
116 }
117
118 function berqwp_install_dropin()
119 {
120 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
121 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
122 } else {
123 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
124 }
125
126 if (!file_exists($dropin_file) || (file_exists($dropin_file) && is_writable($dropin_file))) {
127 $dropin_content = file_get_contents(optifer_PATH . 'advanced-cache.php');
128 file_put_contents($dropin_file, $dropin_content);
129 berqwp_enable_advanced_cache(true);
130 }
131 }
132
133 function berqwp_deactivate_plugin($network_wide = false) {
134
135 // Remove the shared drop-in
136 if (defined('BERQWP_ADVANCED_CACHE_PATH')) {
137 $dropin_file = BERQWP_ADVANCED_CACHE_PATH;
138 } else {
139 $dropin_file = WP_CONTENT_DIR . '/advanced-cache.php';
140 }
141
142 if (file_exists($dropin_file)) {
143 unlink($dropin_file);
144 }
145
146 berqwp_enable_advanced_cache(false);
147
148 if (function_exists('is_multisite') && is_multisite() && $network_wide) {
149 $sites = get_sites(['fields' => 'ids', 'number' => 0]);
150 foreach ($sites as $site_id) {
151 switch_to_blog($site_id);
152 do_action('berqwp_deactivate_plugin');
153 restore_current_blog();
154 }
155 } else {
156 do_action('berqwp_deactivate_plugin');
157 }
158 }
159
160 bwp_lock_cache_directory();
161 bwp_serve_advanced_cache();
162