Skip to content

Commit 321cb3a

Browse files
authored
Merge pull request #11 from psaux-it/v2.0.8
v2.0.8
2 parents 374d5d3 + 9c14466 commit 321cb3a

33 files changed

+154
-87
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Styles for FastCGI Cache Purge and Preload for Nginx
33
* Description: This CSS file contains styles for the FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

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/fastcgi-cache-purge-and-preload-nginx-admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Plugin Name: FastCGI Cache Purge and Preload for Nginx
44
* Plugin URI: https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload
55
* Description: Manage FastCGI Cache Purge and Preload for Nginx operations directly from your WordPress admin dashboard.
6-
* Version: 2.0.7
7-
* Author: Hasan ÇALIŞIR
6+
* Version: 2.0.8
7+
* Author: Hasan CALISIR
88
* Author URI: https://www.psauxit.com/
99
* Author Email: hasan.calisir@psauxit.com
1010
* License: GPL-2.0+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* JavaScript for FastCGI Cache Purge and Preload for Nginx
33
* Description: This JavaScript file contains functions to manage FastCGI Cache Purge and Preload for Nginx plugin and interact with WordPress admin dashboard.
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

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

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/js/nppp-disable-functionality.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* JavaScript for FastCGI Cache Purge and Preload for Nginx
33
* Description: This file contains disable functionality for FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

admin/js/preload-button-disable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* JavaScript for FastCGI Cache Purge and Preload for Nginx
33
* Description: This JavaScript file contains function to disable Preload action if wget command not found on the host for FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Plugin Name: FastCGI Cache Purge and Preload for Nginx
44
* Plugin URI: https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload
55
* Description: Manage FastCGI Cache Purge and Preload for Nginx operations directly from your WordPress admin dashboard.
6-
* Version: 2.0.7
7-
* Author: Hasan ÇALIŞIR
6+
* Version: 2.0.8
7+
* Author: Hasan CALISIR
88
* Author URI: https://www.psauxit.com/
99
* Author Email: hasan.calisir@psauxit.com
1010
* License: GPL-2.0+

frontend/css/fastcgi-cache-purge-and-preload-nginx-front.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Frontend styles for FastCGI Cache Purge and Preload for Nginx
33
* Description: This CSS file contains frontend styles for the FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

frontend/js/fastcgi-cache-purge-and-preload-nginx-front.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Frontend JavaScript for FastCGI Cache Purge and Preload for Nginx
33
* Description: This JavaScript file contains functions that shows on-page purge & preload actions messages for FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

frontend/js/nppp-disable-functionality-front.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Frontend JavaScript for FastCGI Cache Purge and Preload for Nginx
33
* Description: This JavaScript file contains functions that disabling frontpage admin bar actions for FastCGI Cache Purge and Preload for Nginx
4-
* Version: 2.0.7
5-
* Author: Hasan ÇALIŞIR
4+
* Version: 2.0.8
5+
* Author: Hasan CALISIR
66
* Author Email: hasan.calisir@psauxit.com
77
* Author URI: https://www.psauxit.com
88
* License: GPL-2.0+

includes/admin-bar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* WP Admin Bar code for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains Admin Bar code for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/advanced.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Advanced table for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains advanced table functions for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/configuration-parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Nginx config parser functions for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains Nginx config parser functions for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/enqueue-assets.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Enqueue custom CSS and JavaScript files for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains enqueue assets functions for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+
@@ -27,7 +27,7 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_assets() {
2727
wp_enqueue_style('nppp_tempus-dominus-css', plugins_url('../admin/css/tempus-dominus.min.css', __FILE__), array(), '6.9.4');
2828

2929
// Enqueue CSS files for Nginx FastCGI Cache Purge and Preload Plugin
30-
wp_enqueue_style('nppp_admin-css', plugins_url('../admin/css/fastcgi-cache-purge-and-preload-nginx.min.css', __FILE__), array(), '2.0.7');
30+
wp_enqueue_style('nppp_admin-css', plugins_url('../admin/css/fastcgi-cache-purge-and-preload-nginx.min.css', __FILE__), array(), '2.0.8');
3131

3232
// Enqueue the default-passive-events polyfill
3333
wp_enqueue_script('nppp_default-event-js', plugins_url('../admin/js/default-passive-events.min.js', __FILE__), array(), '2.0.0', false);
@@ -57,7 +57,7 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_assets() {
5757
wp_enqueue_script('nppp_tempus-dominus-js', plugins_url('../admin/js/tempus-dominus.min.js', __FILE__), array('nppp_popper-js'), '6.9.4', true);
5858

5959
// Enqueue JavaScript files for Nginx FastCGI Cache Purge and Preload Plugin
60-
wp_enqueue_script('nppp_admin-js', plugins_url('../admin/js/fastcgi-cache-purge-and-preload-nginx.min.js', __FILE__), array('jquery'), '2.0.7', true);
60+
wp_enqueue_script('nppp_admin-js', plugins_url('../admin/js/fastcgi-cache-purge-and-preload-nginx.min.js', __FILE__), array('jquery'), '2.0.8', true);
6161

6262
// Retrieve plugin options.
6363
$options = get_option('nginx_cache_settings');
@@ -244,7 +244,7 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_requisite_assets() {
244244
$output = shell_exec('command -v wget');
245245
if (empty($output)) {
246246
// Wget is not available
247-
wp_enqueue_script('preload-button-disable', plugins_url('../admin/js/preload-button-disable.js', __FILE__), array('jquery'), '2.0.7', true);
247+
wp_enqueue_script('preload-button-disable', plugins_url('../admin/js/preload-button-disable.js', __FILE__), array('jquery'), '2.0.8', true);
248248
} else {
249249
// Wget is available, dequeue the preload-button-disable.js if it's already enqueued
250250
wp_dequeue_script('preload-button-disable');
@@ -253,7 +253,7 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_requisite_assets() {
253253
} else {
254254
// This plugin only works on Linux with nginx
255255
// Disable plugin functionality to prevent unexpected behaviors.
256-
wp_enqueue_script('nppp-disable-functionality', plugins_url('../admin/js/nppp-disable-functionality.js', __FILE__), array('jquery'), '2.0.7', true);
256+
wp_enqueue_script('nppp-disable-functionality', plugins_url('../admin/js/nppp-disable-functionality.js', __FILE__), array('jquery'), '2.0.8', true);
257257
}
258258
}
259259

@@ -264,17 +264,17 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_front_assets() {
264264
if (wp_verify_nonce($nonce, 'nppp_redirect_nonce')) {
265265
if (!is_admin()) {
266266
// Enqueue CSS files for Nginx FastCGI Cache Purge and Preload Plugin
267-
wp_enqueue_style('nppp_admin-front-css', plugins_url('../frontend/css/fastcgi-cache-purge-and-preload-nginx-front.css', __FILE__), array(), '2.0.7');
267+
wp_enqueue_style('nppp_admin-front-css', plugins_url('../frontend/css/fastcgi-cache-purge-and-preload-nginx-front.css', __FILE__), array(), '2.0.8');
268268
// Enqueue JavaScript files for Nginx FastCGI Cache Purge and Preload Plugin frontend
269-
wp_enqueue_script('nppp_admin-front-js', plugins_url('../frontend/js/fastcgi-cache-purge-and-preload-nginx-front.js', __FILE__), array('jquery'), '2.0.7', true);
269+
wp_enqueue_script('nppp_admin-front-js', plugins_url('../frontend/js/fastcgi-cache-purge-and-preload-nginx-front.js', __FILE__), array('jquery'), '2.0.8', true);
270270
}
271271
}
272272
}
273273

274274
// Check plugin requirements and limit the functionality accordingly on front-end
275275
$nppp_met = nppp_plugin_requirements_met();
276276
if (!$nppp_met) {
277-
wp_enqueue_script('nppp-disable-functionality-front', plugins_url('../frontend/js/nppp-disable-functionality-front.js', __FILE__), array('jquery'), '2.0.7', true);
277+
wp_enqueue_script('nppp-disable-functionality-front', plugins_url('../frontend/js/nppp-disable-functionality-front.js', __FILE__), array('jquery'), '2.0.8', true);
278278
} else {
279279
wp_dequeue_script('nppp-disable-functionality-front');
280280
}
@@ -285,7 +285,7 @@ function nppp_enqueue_nginx_fastcgi_cache_purge_preload_front_assets() {
285285
// are visible while on the plugin settings page.
286286
function nppp_manage_admin_notices() {
287287
// Register a dummy stylesheet
288-
wp_register_style('nppp-manage-notices', false, array(), '2.0.7');
288+
wp_register_style('nppp-manage-notices', false, array(), '2.0.8');
289289

290290
// Enqueue the dummy stylesheet
291291
wp_enqueue_style('nppp-manage-notices');

includes/help.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* FAQ for FastCGI Cache Purge and Preload for Nginx
44
* Description: This help file contains informations about FastCGI Cache Purge and Preload for Nginx plugin usage.
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/log.php

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Logging & WP admin notices function for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contain logging & wp admin notices function for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+
@@ -115,10 +115,48 @@ function nppp_display_admin_notice($type, $message, $log_message = true, $displa
115115
}
116116

117117
// Perform the permission check for admin actions
118-
if (is_admin()) {
119-
if (! current_user_can('manage_options')) {
120-
echo '<div class="notice notice-error"><p>You do not have sufficient permissions to access this page.</p></div>';
121-
return;
118+
if (is_admin() && !current_user_can('manage_options')) {
119+
echo '<div class="notice notice-error"><p>You do not have sufficient permissions to access this page.</p></div>';
120+
return;
121+
}
122+
123+
// Define the array of WP screen IDs
124+
$screen_ids = array(
125+
'dashboard',
126+
'post',
127+
'edit-post',
128+
'page',
129+
'edit-page',
130+
'upload',
131+
'edit-comments',
132+
'themes',
133+
'themes-network',
134+
'widgets',
135+
'menus',
136+
'customize',
137+
'plugins',
138+
'plugin-install',
139+
'users',
140+
'tools',
141+
'general',
142+
'writing',
143+
'reading',
144+
'discussion',
145+
'media',
146+
'permalink',
147+
'update',
148+
'edit-category',
149+
'edit-post_tag',
150+
'import',
151+
'export'
152+
);
153+
154+
// Prevent NPP admin notices interfere with core WP screens
155+
if (function_exists('get_current_screen')) {
156+
$screen = get_current_screen();
157+
// Check if the current screen ID is in the array
158+
if ($screen && in_array($screen->id, $screen_ids)) {
159+
return false;
122160
}
123161
}
124162

includes/plugin-tracking.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Description: This file handles tracking the plugin activation and deactivation status
66
* and sends this information to the main API to track plugin statistics.
77
*
8-
* Version: 2.0.7
9-
* Author: Hasan ÇALIŞIR
8+
* Version: 2.0.8
9+
* Author: Hasan CALISIR
1010
* Author URI: https://www.psauxit.com
1111
* License: GPL-2.0+
1212
*

includes/pre-checks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Pre-checks for FastCGI Cache Purge and Preload for Nginx
44
* Description: This pre-check file contains several critical checks for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/preload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Preload action functions for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains preload action functions for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+

includes/purge.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* Purge action functions for FastCGI Cache Purge and Preload for Nginx
44
* Description: This file contains Purge action functions for FastCGI Cache Purge and Preload for Nginx
5-
* Version: 2.0.7
6-
* Author: Hasan ÇALIŞIR
5+
* Version: 2.0.8
6+
* Author: Hasan CALISIR
77
* Author Email: hasan.calisir@psauxit.com
88
* Author URI: https://www.psauxit.com
99
* License: GPL-2.0+
@@ -445,17 +445,38 @@ function nppp_purge($nginx_cache_path, $PIDFILE, $tmp_path, $nppp_is_rest_api =
445445

446446
// Check if the preload process is alive
447447
if ($pid > 0 && posix_kill($pid, 0)) {
448-
// If process is alive, kill it
449-
450-
// Use posix_kill if available
451-
if (defined('SIGTERMM')) {
452-
posix_kill($pid, SIGTERM);
453-
} else {
454-
// Fallback: Use shell_exec to kill the process
455-
$kill_path = trim(shell_exec('command -v kill'));
456-
if (!empty($kill_path)) {
457-
shell_exec("$kill_path -9 $pid");
448+
// Try to kill the process with SIGTERM
449+
if (@posix_kill($pid, SIGTERM) === false) {
450+
// Log if SIGTERM is failed
451+
nppp_display_admin_notice('info', "INFO PROCESS: Failed to send SIGTERM to Preload process PID: $pid", true, false);
452+
sleep(1);
453+
454+
// Check again if the process is still alive after SIGTERM
455+
if (posix_kill($pid, 0)) {
456+
// Fallback: Use shell_exec to send SIGKILL
457+
$kill_path = trim(shell_exec('command -v kill'));
458+
if (!empty($kill_path)) {
459+
shell_exec(escapeshellcmd("$kill_path -9 $pid"));
460+
usleep(400000);
461+
462+
// Check again if the process is still alive after SIGKILL
463+
if (!posix_kill($pid, 0)) {
464+
// Log success after SIGKILL
465+
nppp_display_admin_notice('success', "SUCCESS PROCESS: Fallback - SIGKILL sent to Preload process PID: $pid", true, false);
466+
} else {
467+
// Log failure if fallback didn't work
468+
nppp_display_admin_notice('error', "ERROR PROCESS: Unable to stop the ongoing Preload process. Please wait for the Preload process to complete and try Purge All again.", true, false);
469+
return;
470+
}
471+
} else {
472+
// Log failure if the kill command is not found
473+
nppp_display_admin_notice('error', "ERROR PROCESS: Unable to stop the ongoing Preload process. Please wait for the Preload process to complete and try Purge All again.", true, false);
474+
return;
475+
}
458476
}
477+
} else {
478+
// Log if SIGTERM is successfully sent
479+
nppp_display_admin_notice('success', "SUCCESS PROCESS: Successfully sent SIGTERM to Preload process with PID: $pid", true, false);
459480
}
460481

461482
// If on-going preload action halted via purge

0 commit comments

Comments
 (0)