PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.26
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.26
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 / inc / dropin-functions.php

dropin-functions.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.26, at inc/dropin-functions.php

107 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function bwp_is_ajax() {
4 return
5 (function_exists("wp_doing_ajax") && wp_doing_ajax()) ||
6 (defined('DOING_AJAX') && DOING_AJAX) ||
7 (!empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") ||
8 (!empty($_SERVER["REQUEST_URI"]) && basename($_SERVER["REQUEST_URI"]) == "admin-ajax.php") ||
9 !empty($_GET["wc-ajax"]);
10 }
11
12 function bwp_is_user_logged_in() {
13 foreach ($_COOKIE as $key => $value) {
14 if (strpos($key, 'wordpress_logged_in') === 0) {
15 return true;
16 }
17 }
18 return false;
19 }
20
21 function dropin_remove_ignore_params($slug)
22 {
23 $tracking_params = ignoreParams::$query_params;
24
25 // Parse the provided slug
26 $url_parts = parse_url($slug);
27
28 // Get the current URL parameters
29 $url_params = array();
30 if (isset($url_parts['query'])) {
31 parse_str($url_parts['query'], $url_params);
32 }
33
34 // Remove specified tracking parameters from the URL
35 foreach ($tracking_params as $param) {
36 $param = trim($param);
37 if (isset($url_params[$param])) {
38 unset($url_params[$param]);
39 }
40 }
41
42 // Build the new query string
43 $new_query_string = http_build_query($url_params);
44
45 // Reconstruct the URL with the new query string
46 $updated_url = $url_parts['scheme'] . "://" . $url_parts['host'] . $url_parts['path'];
47 if (!empty($new_query_string)) {
48 $updated_url .= '?' . $new_query_string;
49 }
50
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 }
107