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 +34 -29 4.0.29trunk View file →
@@ -224,8 +224,9 @@
224 224 "/embed",
225 225 "/view-order/",
226 226 "/redirect/",
227 227 "/elementskit-content/",
228 + "/checkout/",
228 229 ];
229 230
230 231 $exclude_items = apply_filters('berqwp_exclude_slug_match', $exclude_items);
231 232
@@ -1479,8 +1480,9 @@
1479 1480
1480 1481 $berqconfigs = berqConfigs::getInstance();
1481 1482 $configs = $berqconfigs->get_configs();
1482 1483 $post_params['cache_lifespan'] = $configs['cache_lifespan'];
1484 + $post_params['sandbox'] = get_option('berqwp_enable_sandbox');
1483 1485
1484 1486 if ($query->have_posts()) {
1485 1487 $sitemap_urls = [];
1486 1488
@@ -1887,11 +1889,27 @@
1887 1889 <FilesMatch "index\.html\.gz$">
1888 1890 Order allow,deny
1889 1891 Allow from all
1890 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>
1891 1903 HTACCESS;
1892 1904
1893 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 + }
1894 1912 }
1895 1913
1896 1914 function bwp_write_htaccess_rules($ignore_sandbox = false)
1897 1915 {
@@ -1903,8 +1921,10 @@
1903 1921 return;
1904 1922 }
1905 1923
1906 1924 $htaccess = get_home_path() . '.htaccess';
1925 + $cache_tag_host = parse_url(home_url(), PHP_URL_HOST);
1926 +
1907 1927 $rules = [
1908 1928 '<IfModule mod_rewrite.c>',
1909 1929 ' RewriteEngine On',
1910 1930 ' RewriteCond %{REQUEST_METHOD} !POST',
@@ -1909,8 +1929,9 @@
1909 1929 ' RewriteEngine On',
1910 1930 ' RewriteCond %{REQUEST_METHOD} !POST',
1911 1931 ' RewriteCond %{QUERY_STRING} ^$',
1912 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]',
1913 1934 ' RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/berqwp/html/%{HTTP_HOST}%{REQUEST_URI}/index.html.gz -f',
1914 1935 ' RewriteRule .* /wp-content/cache/berqwp/html/%{HTTP_HOST}%{REQUEST_URI}/index.html.gz [L]',
1915 1936 '</IfModule>',
1916 1937 '<IfModule mod_mime.c>',
@@ -1916,16 +1937,20 @@
1916 1937 '<IfModule mod_mime.c>',
1917 1938 ' <FilesMatch "index\.html\.gz$">',
1918 1939 ' ForceType text/html',
1919 1940 ' AddEncoding gzip .gz',
1941 + ' AddDefaultCharset utf-8',
1920 1942 ' </FilesMatch>',
1921 1943 '</IfModule>',
1922 1944 '<IfModule mod_headers.c>',
1923 1945 ' <FilesMatch "index\.html\.gz$">',
1946 + ' Header set X-BerqWP-Cache "HIT"',
1924 1947 ' Header set X-Served "server"',
1925 1948 ' Header set Content-Encoding "gzip"',
1926 1949 ' Header set Vary "Accept-Encoding, Cookie"',
1927 - ' Header set Cache-Control "public, max-age=0, s-maxage=3600, must-revalidate"',
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 . '"',
1928 1953 ' Header set X-Content-Type-Options "nosniff"',
1929 1954 ' </FilesMatch>',
1930 1955 '</IfModule>',
1931 1956 '<IfModule mod_expires.c>',
@@ -2250,9 +2275,8 @@
2250 2275
2251 2276 function berqwp_validate_url_array($urls)
2252 2277 {
2253 2278 $home_host = parse_url(home_url(), PHP_URL_HOST);
2254 - $home_scheme = parse_url(home_url(), PHP_URL_SCHEME);
2255 2279
2256 2280 $urls = array_filter($urls, function ($url) use ($home_host) {
2257 2281 $url_host = parse_url($url, PHP_URL_HOST);
2258 2282
@@ -2263,35 +2287,9 @@
2263 2287
2264 2288 return $url_host === $home_host;
2265 2289 });
2266 2290
2267 - $urls = array_map(function ($url) use ($home_scheme) {
2268 - // Skip invalid URLs
2269 - if (!is_string($url) || $url === '') {
2270 - return $url;
2271 - }
2272 -
2273 - $parts = parse_url($url);
2274 -
2275 - // Relative URL → leave as-is
2276 - if (empty($parts['scheme'])) {
2277 - return $url;
2278 - }
2279 -
2280 - // Rebuild URL with home scheme
2281 - $parts['scheme'] = $home_scheme;
2282 -
2283 - $new_url = $parts['scheme'] . '://';
2284 - $new_url .= $parts['host'] ?? '';
2285 - $new_url .= isset($parts['port']) ? ':' . $parts['port'] : '';
2286 - $new_url .= $parts['path'] ?? '';
2287 - $new_url .= isset($parts['query']) ? '?' . $parts['query'] : '';
2288 - $new_url .= isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
2289 -
2290 - return $new_url;
2291 - }, $urls);
2292 -
2293 - return $urls;
2291 + return array_values($urls);
2294 2292 }
2295 2293
2296 2294 function berqwp_render_toggle($name, $checked) {
2297 2295 ?>
@@ -2352,4 +2350,11 @@
2352 2350 $license_key = berqwp_get_license_key();
2353 2351
2354 2352 return !empty($configs['site_id']) && !empty($configs['secret']) && !empty($configs['optimization_method']) && $configs['optimization_method'] == 'cloud' && !empty($license_key);
2355 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 +}