Skip to content

Commit b399f1c

Browse files
authored
Merge v2.1.4 into main
2 parents 145021c + bad85db commit b399f1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+9140
-1854
lines changed

admin/css/dataTables.min.css

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/css/fastcgi-cache-purge-and-preload-nginx.css

Lines changed: 856 additions & 16 deletions
Large diffs are not rendered by default.

admin/css/fastcgi-cache-purge-and-preload-nginx.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/css/nppp-dashboard-widget.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Styles for FastCGI Cache Purge and Preload for Nginx
33
* Description: This file contains WP dashboard widget styles for the FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.1.3
4+
* Version: 2.1.4
55
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com

admin/fastcgi-cache-purge-and-preload-nginx-admin.php

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/*
33
* Load NPP
4-
* Version: 2.1.3
4+
* Version: 2.1.4
55
* Author: Hasan CALISIR
66
* Author URI: https://www.psauxit.com/
77
* License: GPL-2.0+
@@ -19,12 +19,99 @@
1919

2020
// Define a constant for the desktop user agent
2121
if (!defined('NPPP_USER_AGENT')) {
22-
define('NPPP_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36');
22+
define('NPPP_USER_AGENT', 'NPP/2.1.4 (NginxCacheWarm; device=desktop; Desktop)');
2323
}
2424

2525
// Define a constant for the mobile user agent
2626
if (!defined('NPPP_USER_AGENT_MOBILE')) {
27-
define('NPPP_USER_AGENT_MOBILE', 'Mozilla/5.0 (Linux; Android 15; SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.81 Mobile Safari/537.36');
27+
define('NPPP_USER_AGENT_MOBILE', 'NPP/2.1.4 (NginxCacheWarm; device=mobile; Mobile)');
28+
}
29+
30+
// Define a header constant for mimic real browser request
31+
if (!defined('NPPP_HEADER_ACCEPT')) {
32+
define('NPPP_HEADER_ACCEPT', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,' . '*' . '/' . '*;q=0.8');
33+
}
34+
35+
// Prepare PATH and SAFEXEC related env
36+
function nppp_prepare_request_env(bool $force = false): void {
37+
static $done = false;
38+
39+
// allow re-run when forced
40+
if ($done && !$force) {
41+
return;
42+
}
43+
44+
if (!function_exists('getenv') || !function_exists('putenv')) {
45+
$done = true;
46+
return;
47+
}
48+
49+
// register the shutdown restore ONCE
50+
if (empty($GLOBALS['NPPP__RESTORE_REGISTERED'])) {
51+
register_shutdown_function(static function () {
52+
// PATH
53+
if (array_key_exists('NPPP__ORIG_PATH', $GLOBALS)) {
54+
$orig = $GLOBALS['NPPP__ORIG_PATH'];
55+
if ($orig === null) putenv('PATH'); else putenv("PATH={$orig}");
56+
}
57+
58+
// Always unset safexec related envs
59+
putenv('SAFEXEC_QUIET');
60+
putenv('SAFEXEC_PCTNORM');
61+
putenv('SAFEXEC_PCTNORM_CASE');
62+
putenv('SAFEXEC_DETACH');
63+
});
64+
$GLOBALS['NPPP__RESTORE_REGISTERED'] = true;
65+
}
66+
67+
// PATH
68+
$need = ['/usr/local/sbin','/usr/local/bin','/usr/sbin','/usr/bin','/sbin','/bin'];
69+
$orig_path = getenv('PATH');
70+
$parts = $orig_path ? array_filter(explode(':', (string)$orig_path), fn($p) => $p !== '' && $p !== '.') : [];
71+
$merged = array_values(array_unique(array_merge($need, $parts)));
72+
$new_path = implode(':', $merged);
73+
74+
// Save only once so $force runs don't clobber the true original
75+
if (!array_key_exists('NPPP__ORIG_PATH', $GLOBALS)) {
76+
$GLOBALS['NPPP__ORIG_PATH'] = ($orig_path === false) ? null : $orig_path;
77+
}
78+
79+
if ($new_path !== $orig_path) {
80+
putenv("PATH={$new_path}");
81+
}
82+
83+
// Always quiet safexec
84+
putenv('SAFEXEC_QUIET=1');
85+
86+
// safexec mode (off|upper|lower|preserve)
87+
$opts = get_option('nginx_cache_settings', []);
88+
$mode = isset($opts['nginx_cache_pctnorm_mode']) ? strtolower((string)$opts['nginx_cache_pctnorm_mode']) : 'off';
89+
if (!in_array($mode, ['off','upper','lower','preserve'], true)) $mode = 'off';
90+
91+
switch ($mode) {
92+
case 'upper':
93+
putenv('SAFEXEC_PCTNORM=1');
94+
putenv('SAFEXEC_PCTNORM_CASE=upper');
95+
break;
96+
case 'lower':
97+
putenv('SAFEXEC_PCTNORM=1');
98+
putenv('SAFEXEC_PCTNORM_CASE=lower');
99+
break;
100+
case 'preserve':
101+
putenv('SAFEXEC_PCTNORM=1');
102+
putenv('SAFEXEC_PCTNORM_CASE=off');
103+
break;
104+
case 'off':
105+
default:
106+
putenv('SAFEXEC_PCTNORM=0');
107+
putenv('SAFEXEC_PCTNORM_CASE');
108+
break;
109+
}
110+
111+
// Detach behavior for this request
112+
putenv('SAFEXEC_DETACH=auto');
113+
114+
$done = true;
28115
}
29116

30117
// Include plugin files
@@ -35,6 +122,7 @@
35122
require_once dirname(__DIR__) . '/includes/log.php';
36123
require_once dirname(__DIR__) . '/includes/svg.php';
37124
require_once dirname(__DIR__) . '/includes/settings.php';
125+
require_once dirname(__DIR__) . '/includes/related.php';
38126
require_once dirname(__DIR__) . '/includes/purge.php';
39127
require_once dirname(__DIR__) . '/includes/preload.php';
40128
require_once dirname(__DIR__) . '/includes/help.php';
@@ -47,6 +135,8 @@
47135
require_once dirname(__DIR__) . '/includes/plugin-tracking.php';
48136
require_once dirname(__DIR__) . '/includes/update.php';
49137
require_once dirname(__DIR__) . '/includes/dashboard-widget.php';
138+
require_once dirname(__DIR__) . '/includes/compat-elementor.php';
139+
require_once dirname(__DIR__) . '/includes/compat-gutenberg.php';
50140

51141
// Get the status of Auto Purge option
52142
$options = get_option('nginx_cache_settings');
@@ -66,7 +156,6 @@
66156
);
67157

68158
// Add actions and filters
69-
add_action('init', 'nppp_load_i18n');
70159
add_action('load-settings_page_nginx_cache_settings', 'nppp_enqueue_nginx_fastcgi_cache_purge_preload_assets');
71160
add_action('load-settings_page_nginx_cache_settings', 'nppp_check_for_plugin_update');
72161
add_action('admin_enqueue_scripts', 'nppp_enqueue_nginx_fastcgi_cache_purge_preload_requisite_assets');
@@ -116,6 +205,9 @@
116205
add_action('npp_plugin_tracking_event', 'nppp_plugin_tracking', 10, 1);
117206
add_action('wp_dashboard_setup', 'nppp_add_dashboard_widget');
118207
add_action('wp_ajax_nppp_update_enable_proxy_option', 'nppp_update_enable_proxy_option');
208+
add_action('wp_ajax_nppp_update_related_fields', 'nppp_update_related_fields');
209+
add_action('wp_ajax_nppp_locate_cache_file', 'nppp_locate_cache_file_ajax');
210+
add_action('wp_ajax_nppp_update_pctnorm_mode', 'nppp_update_pctnorm_mode');
119211
$nppp_auto_purge
120212
? array_map(function($purge_action) { add_action($purge_action, 'nppp_purge_callback'); }, $page_cache_purge_actions)
121213
: array_map(function($purge_action) { remove_action($purge_action, 'nppp_purge_callback'); }, $page_cache_purge_actions);

admin/js/dataTables.min.js

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)