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

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