PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / trunk
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript vtrunk
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
← All changes | inc/dropin-functions.php +62 -8 1.9.3trunk View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 function bwp_is_ajax() {
4 - return
4 + return
5 5 (function_exists("wp_doing_ajax") && wp_doing_ajax()) ||
6 6 (defined('DOING_AJAX') && DOING_AJAX) ||
7 7 (!empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") ||
8 8 (!empty($_SERVER["REQUEST_URI"]) && basename($_SERVER["REQUEST_URI"]) == "admin-ajax.php") ||
@@ -10,9 +10,9 @@
10 10 }
11 11
12 12 function bwp_is_user_logged_in() {
13 13 foreach ($_COOKIE as $key => $value) {
14 - if (strpos($key, 'wordpress_logged_in_') === 0) {
14 + if (strpos($key, 'wordpress_logged_in') === 0) {
15 15 return true;
16 16 }
17 17 }
18 18 return false;
@@ -23,15 +23,15 @@
23 23 $tracking_params = ignoreParams::$query_params;
24 24
25 25 // Parse the provided slug
26 26 $url_parts = parse_url($slug);
27 -
27 +
28 28 // Get the current URL parameters
29 29 $url_params = array();
30 30 if (isset($url_parts['query'])) {
31 31 parse_str($url_parts['query'], $url_params);
32 32 }
33 -
33 +
34 34 // Remove specified tracking parameters from the URL
35 35 foreach ($tracking_params as $param) {
36 36 $param = trim($param);
37 37 if (isset($url_params[$param])) {
@@ -42,11 +42,65 @@
42 42 // Build the new query string
43 43 $new_query_string = http_build_query($url_params);
44 44
45 45 // Reconstruct the URL with the new query string
46 - $new_slug = $url_parts['path'];
46 + $updated_url = $url_parts['scheme'] . "://" . $url_parts['host'] . $url_parts['path'];
47 47 if (!empty($new_query_string)) {
48 - $new_slug .= '?' . $new_query_string;
48 + $updated_url .= '?' . $new_query_string;
49 49 }
50 50
51 - return $new_slug;
52 -}
51 + return $updated_url;
52 +}
53 +
54 +function bwp_dropin_isGzipEncoded() {
55 + // Check if the Content-Encoding header is set to gzip
56 + if (isset($_SERVER['HTTP_CONTENT_ENCODING']) && strtolower($_SERVER['HTTP_CONTENT_ENCODING']) === 'gzip') {
57 + return true;
58 + }
59 +
60 + foreach (headers_list() as $header) {
61 + if (stripos($header, 'Content-Encoding: gzip') !== false) {
62 + return true;
63 + }
64 + }
65 +
66 + return false;
67 +}
68 +
69 +function berqwp_dropin_is_page_url_excluded($page_url) {
70 + if (empty($page_url)) {
71 + return false;
72 + }
73 +
74 + $berqconfigs = berqConfigs::getInstance();
75 + $configs = $berqconfigs->get_configs();
76 + $pages_to_exclude = $configs['exclude_urls'];
77 +
78 + if (strpos($page_url, '?') !== false) {
79 + $page_url = explode('?', $page_url)[0];
80 + }
81 +
82 + if (in_array($page_url, $pages_to_exclude)) {
83 + return true;
84 + }
85 +
86 + if (!empty($pages_to_exclude)) {
87 + foreach ($pages_to_exclude as $single_page_url) {
88 +
89 + if (empty($single_page_url)) {
90 + continue;
91 + }
92 +
93 + if (substr($single_page_url, -1) !== '*') {
94 + continue;
95 + }
96 +
97 + $single_page_url = str_replace('*', '', $single_page_url);
98 +
99 + if (strpos($page_url, $single_page_url) !== false) {
100 + return true;
101 + }
102 + }
103 + }
104 +
105 + return false;
106 +}