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/helper-functions.php +77 -38 4.0.19trunk View file →
@@ -82,9 +82,8 @@
82 82 }
83 83
84 84 function berqwp_activate_single_site() {
85 85 if (empty(berqwp_get_license_key())) {
86 - set_transient('bqwp_hide_feedback_notice', true, 60 * 60);
87 86 set_transient('berqwp_redirect', true, 1);
88 87 }
89 88 update_option('berqwp_sync_addons', true);
90 89 do_action('berqwp_activate_plugin');
@@ -225,8 +224,9 @@
225 224 "/embed",
226 225 "/view-order/",
227 226 "/redirect/",
228 227 "/elementskit-content/",
228 + "/checkout/",
229 229 ];
230 230
231 231 $exclude_items = apply_filters('berqwp_exclude_slug_match', $exclude_items);
232 232
@@ -1480,8 +1480,9 @@
1480 1480
1481 1481 $berqconfigs = berqConfigs::getInstance();
1482 1482 $configs = $berqconfigs->get_configs();
1483 1483 $post_params['cache_lifespan'] = $configs['cache_lifespan'];
1484 + $post_params['sandbox'] = get_option('berqwp_enable_sandbox');
1484 1485
1485 1486 if ($query->have_posts()) {
1486 1487 $sitemap_urls = [];
1487 1488
@@ -1639,21 +1640,21 @@
1639 1640
1640 1641 if (!empty($_GET['tab_id'])) {
1641 1642 if (sanitize_text_field($_GET['tab_id']) == $tab_id) {
1642 1643 // echo ' style="display:block" ';
1643 - echo ' style="visibility:visible;opacity:1;height:auto;" ';
1644 + echo ' style="visibility:visible;opacity:1;height:auto;display:block;" ';
1644 1645 } else {
1645 1646 // echo ' style="display:none" ';
1646 - echo ' style="visibility:hidden;opacity:0;height:0;overflow:hidden;" ';
1647 + echo ' style="visibility:hidden;opacity:0;height:0;overflow:hidden;display:none;" ';
1647 1648 }
1648 1649 } else {
1649 1650
1650 1651 if ($tab_id == $default_tab) {
1651 1652 // echo ' style="display:block" ';
1652 - echo ' style="visibility:visible;opacity:1;height:auto;" ';
1653 + echo ' style="visibility:visible;opacity:1;height:auto;display:block;" ';
1653 1654 } else {
1654 1655 // echo ' style="display:none" ';
1655 - echo ' style="visibility:hidden;opacity:0;height:0;overflow:hidden;" ';
1656 + echo ' style="visibility:hidden;opacity:0;height:0;overflow:hidden;display:none;" ';
1656 1657 }
1657 1658 }
1658 1659 }
1659 1660
@@ -1691,15 +1692,15 @@
1691 1692 d="M6.43896 0H17.561C21.1172 0 24 2.88287 24 6.43903V17.561C24 21.1171 21.1172 24 17.561 24H6.43896C2.88281 24 0 21.1171 0 17.561V6.43903C0 2.88287 2.88281 0 6.43896 0ZM15.7888 4.09753L8.59961 12.7534H12.3517L7.02441 20.4878L16.3903 11.0222L12.7814 10.3799L15.7888 4.09753Z"
1692 1693 fill="#1f72ff" />
1693 1694 </svg></div>
1694 1695 <div class="content">
1695 - <div class="status-tag"><?php esc_html_e($status, 'searchpro'); ?></div>
1696 + <div class="status-tag"><?php echo esc_html($status); ?></div>
1696 1697 <?php if (!empty($title)) { ?>
1697 - <h5><?php echo wp_kses_post(__($title, 'searchpro')); ?></h5>
1698 + <h5><?php echo wp_kses_post($title); ?></h5>
1698 1699 <?php } ?>
1699 1700
1700 1701 <?php if (!empty($message)) { ?>
1701 - <?php echo wp_kses_post(__($message, 'searchpro')); ?>
1702 + <?php echo wp_kses_post($message); ?>
1702 1703 <?php } ?>
1703 1704
1704 1705 <?php if (!empty($btn) && is_array($btn)) { ?>
1705 1706 <div class="bwp-notice-btn">
@@ -1723,9 +1724,9 @@
1723 1724 ?>
1724 1725 <a target="<?php echo esc_attr($bwp_btn['target']) ?? ''; ?>"
1725 1726 href="<?php echo esc_attr($bwp_btn['href']) ?? ''; ?>"
1726 1727 class="bwp-btn <?php echo esc_attr($bwp_btn['classes']) ?? ''; ?>">
1727 - <?php echo esc_html__($bwp_btn['text'], 'searchpro') ?? ''; ?>
1728 + <?php echo esc_html($bwp_btn['text']); ?>
1728 1729 </a>
1729 1730 <?php
1730 1731 }
1731 1732 ?>
@@ -1810,9 +1811,9 @@
1810 1811 if (isset($_GET['berqwp_logs'])) {
1811 1812
1812 1813 // Check if the current user is logged in and has admin privileges
1813 1814 if (!is_user_logged_in() || !current_user_can('administrator')) {
1814 - wp_die(__('You are not allowed to access this page.', 'berqwp'));
1815 + wp_die(__('You are not allowed to access this page.', 'searchpro'));
1815 1816 }
1816 1817
1817 1818 // Define the path to the BerqWP logs file
1818 1819 $log_file_path = optifer_cache . '/logs/berqwp.log'; // Adjust path if needed
@@ -1888,11 +1889,27 @@
1888 1889 <FilesMatch "index\.html\.gz$">
1889 1890 Order allow,deny
1890 1891 Allow from all
1891 1892 </FilesMatch>
1893 +
1894 +# Block PHP execution and dot-files to prevent webshell deployment
1895 +<FilesMatch "\.php\d*$|\.phtml$|\.phar$">
1896 + Order allow,deny
1897 + Deny from all
1898 +</FilesMatch>
1899 +<FilesMatch "^\.">
1900 + Order allow,deny
1901 + Deny from all
1902 +</FilesMatch>
1892 1903 HTACCESS;
1893 1904
1894 1905 file_put_contents($cache_dir . '.htaccess', $rules);
1906 +
1907 + // Suppress directory listing
1908 + $index_stub = $cache_dir . 'index.php';
1909 + if (!file_exists($index_stub)) {
1910 + file_put_contents($index_stub, '<?php // Silence is golden');
1911 + }
1895 1912 }
1896 1913
1897 1914 function bwp_write_htaccess_rules($ignore_sandbox = false)
1898 1915 {
@@ -1904,8 +1921,10 @@
1904 1921 return;
1905 1922 }
1906 1923
1907 1924 $htaccess = get_home_path() . '.htaccess';
1925 + $cache_tag_host = parse_url(home_url(), PHP_URL_HOST);
1926 +
1908 1927 $rules = [
1909 1928 '<IfModule mod_rewrite.c>',
1910 1929 ' RewriteEngine On',
1911 1930 ' RewriteCond %{REQUEST_METHOD} !POST',
@@ -1910,8 +1929,9 @@
1910 1929 ' RewriteEngine On',
1911 1930 ' RewriteCond %{REQUEST_METHOD} !POST',
1912 1931 ' RewriteCond %{QUERY_STRING} ^$',
1913 1932 ' RewriteCond %{HTTP_COOKIE} !(wp\-postpass|wordpress_logged_in|comment_author|woocommerce_cart_hash|edd_items_in_cart) [NC]',
1933 + ' RewriteCond %{HTTP_USER_AGENT} !(Googlebot|Google-InspectionTool|Bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Sogou|Exabot|facebookexternalhit|Twitterbot|LinkedInBot|WhatsApp|TelegramBot|Applebot|AhrefsBot|SemrushBot|MJ12bot|DotBot|PetalBot|BLEXBot|archive\.org_bot|UptimeRobot|Pingdom|ChatGPT-User|GPTBot|ClaudeBot|Bytespider) [NC]',
1914 1934 ' RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/berqwp/html/%{HTTP_HOST}%{REQUEST_URI}/index.html.gz -f',
1915 1935 ' RewriteRule .* /wp-content/cache/berqwp/html/%{HTTP_HOST}%{REQUEST_URI}/index.html.gz [L]',
1916 1936 '</IfModule>',
1917 1937 '<IfModule mod_mime.c>',
@@ -1917,15 +1937,54 @@
1917 1937 '<IfModule mod_mime.c>',
1918 1938 ' <FilesMatch "index\.html\.gz$">',
1919 1939 ' ForceType text/html',
1920 1940 ' AddEncoding gzip .gz',
1941 + ' AddDefaultCharset utf-8',
1921 1942 ' </FilesMatch>',
1922 1943 '</IfModule>',
1923 1944 '<IfModule mod_headers.c>',
1924 1945 ' <FilesMatch "index\.html\.gz$">',
1946 + ' Header set X-BerqWP-Cache "HIT"',
1925 1947 ' Header set X-Served "server"',
1948 + ' Header set Content-Encoding "gzip"',
1949 + ' Header set Vary "Accept-Encoding, Cookie"',
1950 + ' Header set CDN-Cache-Control "max-age=2592000"',
1951 + ' Header set Cache-Control "public, max-age=600, s-maxage=2592000, stale-while-revalidate=86400"',
1952 + ' Header set Cache-Tag "' . $cache_tag_host . '"',
1953 + ' Header set X-Content-Type-Options "nosniff"',
1926 1954 ' </FilesMatch>',
1927 1955 '</IfModule>',
1956 + '<IfModule mod_expires.c>',
1957 + ' ExpiresActive On',
1958 + ' ExpiresByType text/css "access plus 1 year"',
1959 + ' ExpiresByType application/javascript "access plus 1 year"',
1960 + ' ExpiresByType text/javascript "access plus 1 year"',
1961 + ' ExpiresByType image/jpeg "access plus 1 year"',
1962 + ' ExpiresByType image/png "access plus 1 year"',
1963 + ' ExpiresByType image/gif "access plus 1 year"',
1964 + ' ExpiresByType image/webp "access plus 1 year"',
1965 + ' ExpiresByType image/avif "access plus 1 year"',
1966 + ' ExpiresByType image/svg+xml "access plus 1 year"',
1967 + ' ExpiresByType image/x-icon "access plus 1 year"',
1968 + ' ExpiresByType font/woff "access plus 1 year"',
1969 + ' ExpiresByType font/woff2 "access plus 1 year"',
1970 + ' ExpiresByType application/font-woff "access plus 1 year"',
1971 + ' ExpiresByType application/font-woff2 "access plus 1 year"',
1972 + ' ExpiresByType application/x-font-ttf "access plus 1 year"',
1973 + ' ExpiresByType application/x-font-opentype "access plus 1 year"',
1974 + '</IfModule>',
1975 + '<IfModule mod_headers.c>',
1976 + ' <FilesMatch "\.(css|js)$">',
1977 + ' Header set Cache-Control "public, max-age=31536000, immutable"',
1978 + ' </FilesMatch>',
1979 + ' <FilesMatch "\.(jpg|jpeg|png|gif|webp|avif|svg|ico)$">',
1980 + ' Header set Cache-Control "public, max-age=31536000, immutable"',
1981 + ' </FilesMatch>',
1982 + ' <FilesMatch "\.(woff|woff2|ttf|otf|eot)$">',
1983 + ' Header set Cache-Control "public, max-age=31536000, immutable"',
1984 + ' Header set Access-Control-Allow-Origin "*"',
1985 + ' </FilesMatch>',
1986 + '</IfModule>',
1928 1987 ];
1929 1988
1930 1989 // Must appear before the WordPress block so Apache processes it first
1931 1990 $marker = 'BerqWP Cache';
@@ -2216,9 +2275,8 @@
2216 2275
2217 2276 function berqwp_validate_url_array($urls)
2218 2277 {
2219 2278 $home_host = parse_url(home_url(), PHP_URL_HOST);
2220 - $home_scheme = parse_url(home_url(), PHP_URL_SCHEME);
2221 2279
2222 2280 $urls = array_filter($urls, function ($url) use ($home_host) {
2223 2281 $url_host = parse_url($url, PHP_URL_HOST);
2224 2282
@@ -2229,35 +2287,9 @@
2229 2287
2230 2288 return $url_host === $home_host;
2231 2289 });
2232 2290
2233 - $urls = array_map(function ($url) use ($home_scheme) {
2234 - // Skip invalid URLs
2235 - if (!is_string($url) || $url === '') {
2236 - return $url;
2237 - }
2238 -
2239 - $parts = parse_url($url);
2240 -
2241 - // Relative URL → leave as-is
2242 - if (empty($parts['scheme'])) {
2243 - return $url;
2244 - }
2245 -
2246 - // Rebuild URL with home scheme
2247 - $parts['scheme'] = $home_scheme;
2248 -
2249 - $new_url = $parts['scheme'] . '://';
2250 - $new_url .= $parts['host'] ?? '';
2251 - $new_url .= isset($parts['port']) ? ':' . $parts['port'] : '';
2252 - $new_url .= $parts['path'] ?? '';
2253 - $new_url .= isset($parts['query']) ? '?' . $parts['query'] : '';
2254 - $new_url .= isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
2255 -
2256 - return $new_url;
2257 - }, $urls);
2258 -
2259 - return $urls;
2291 + return array_values($urls);
2260 2292 }
2261 2293
2262 2294 function berqwp_render_toggle($name, $checked) {
2263 2295 ?>
@@ -2318,4 +2350,11 @@
2318 2350 $license_key = berqwp_get_license_key();
2319 2351
2320 2352 return !empty($configs['site_id']) && !empty($configs['secret']) && !empty($configs['optimization_method']) && $configs['optimization_method'] == 'cloud' && !empty($license_key);
2321 2353 }
2354 +
2355 +function berqwp_generate_site_id() {
2356 + $blog_id = get_current_blog_id();
2357 + $network_id = function_exists('get_current_network_id') ? get_current_network_id() : 1;
2358 + $siteurl = get_option('siteurl');
2359 + return md5("berqwp|$network_id|$blog_id|$siteurl");
2360 +}