Changeset 3395024
- Timestamp:
- 11/13/2025 12:25:16 PM (5 months ago)
- Location:
- tnc-toolbox
- Files:
-
- 18 added
- 4 edited
-
tags/2.0.5 (added)
-
tags/2.0.5/assets (added)
-
tags/2.0.5/assets/index.php (added)
-
tags/2.0.5/assets/styles-config.css (added)
-
tags/2.0.5/assets/tnc-icon-light.png (added)
-
tags/2.0.5/core (added)
-
tags/2.0.5/core/core.php (added)
-
tags/2.0.5/core/index.php (added)
-
tags/2.0.5/core/settings.php (added)
-
tags/2.0.5/index.php (added)
-
tags/2.0.5/license.txt (added)
-
tags/2.0.5/locale (added)
-
tags/2.0.5/locale/index.php (added)
-
tags/2.0.5/readme.txt (added)
-
tags/2.0.5/tnc-toolbox.php (added)
-
tags/2.0.5/vendor (added)
-
tags/2.0.5/vendor/cpanel-uapi.php (added)
-
tags/2.0.5/vendor/index.php (added)
-
trunk/core/core.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tnc-toolbox.php (modified) (3 diffs)
-
trunk/vendor/cpanel-uapi.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tnc-toolbox/trunk/core/core.php
r3391021 r3395024 62 62 add_action('admin_post_nginx_cache_purge', array($this, 'nginx_cache_purge')); 63 63 add_action('post_updated', array($this, 'purge_cache_on_update'), 10, 3); 64 add_action('_core_updated_successfully', array($this, 'nginx_cache_purge'));64 add_action('_core_updated_successfully', function() { TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache', [], true); }); 65 65 66 66 // Notices (Admin GUI) … … 69 69 // ACF Save (#24) 70 70 if (has_action('acf/options_page/save') === true) { 71 add_action('acf/options_page/save', TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache'), 10, 3);71 add_action('acf/options_page/save', function() { TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache', [], true); }, 10, 3); 72 72 } 73 73 } … … 77 77 */ 78 78 public function add_capability_dependent_hooks() { 79 if (current_user_can(' update_core')) {79 if (current_user_can('manage_options')) { 80 80 add_action('admin_bar_menu', array($this, 'add_cache_off_button'), 100); 81 81 add_action('admin_post_nginx_cache_off', array($this, 'nginx_cache_off')); … … 209 209 public function nginx_cache_purge() { 210 210 check_admin_referer('nginx_cache_purge'); 211 if (!current_user_can('manage_options')) { 212 wp_die(__('You are not allowed to do that.')); 213 } 211 214 $response = TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache'); 212 215 $this->set_notice( … … 224 227 public function nginx_cache_off() { 225 228 check_admin_referer('nginx_cache_off'); 229 if (!current_user_can('manage_options')) { 230 wp_die(__('You are not allowed to do that.')); 231 } 226 232 $response = TNC_cPanel_UAPI::make_api_request('NginxCaching/disable_cache'); 227 233 $this->set_notice( … … 239 245 public function nginx_cache_on() { 240 246 check_admin_referer('nginx_cache_on'); 247 if (!current_user_can('manage_options')) { 248 wp_die(__('You are not allowed to do that.')); 249 } 241 250 $response = TNC_cPanel_UAPI::make_api_request('NginxCaching/enable_cache'); 242 251 $this->set_notice( … … 259 268 ($post_before->post_status === 'publish' && $post_after->post_status !== 'trash')) { 260 269 // Use the UAPI directly rather than function, to support automated (#31) 261 TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache' );270 TNC_cPanel_UAPI::make_api_request('NginxCaching/clear_cache', [], true); 262 271 } 263 272 } -
tnc-toolbox/trunk/readme.txt
r3394702 r3395024 6 6 Tags: NGINX, Cache Purge, Web Performance, Automatic Purge, Freeware 7 7 Tested up to: 6.8 8 Stable tag: 2.0. 48 Stable tag: 2.0.5 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 113 113 == Changelog == 114 114 115 = 2.0.5: Nov 13, 2025 = 116 * Security: Restrict actions to Cron/Hook & via Perms 117 115 118 = 2.0.4: Nov 11, 2025 = 116 119 * Remove minimum requirements: Ensure v2 adoption growth -
tnc-toolbox/trunk/tnc-toolbox.php
r3393408 r3395024 6 6 * @author The Network Crew Pty Ltd (TNC & Co.) 7 7 * @license gplv3 8 * @version 2.0. 48 * @version 2.0.5 9 9 * 10 10 * @wordpress-plugin … … 12 12 * Plugin URI: https://merlot.digital 13 13 * Description: Adds functionality to WP - designed for NGINX-powered Servers on cPanel+WHM. Made to help you fly online! 14 * Version: 2.0. 414 * Version: 2.0.5 15 15 * Author: The Network Crew Pty Ltd (TNC & Co.) 16 16 * Author URI: https://tnc.works … … 30 30 31 31 // Plugin version 32 define('TNCTOOLBOX_VERSION', '2.0. 4');32 define('TNCTOOLBOX_VERSION', '2.0.5'); 33 33 34 34 // Plugin Root File -
tnc-toolbox/trunk/vendor/cpanel-uapi.php
r3393408 r3395024 48 48 * Get stored API configuration 49 49 * 50 * @param bool $skip_cap_check Skip capability check for internal requests 50 51 * @return array|false API config, or false if not set 51 52 */ 52 public static function get_config( ) {53 // Cleanly return if user can't edit post 54 if (! current_user_can('manage_options')) {53 public static function get_config($skip_cap_check = false) { 54 // Cleanly return if user can't edit post and not skipping check 55 if (!$skip_cap_check && !current_user_can('manage_options')) { 55 56 return false; 56 57 } … … 101 102 * @param string $endpoint API endpoint (e.g. 'NginxCaching/clear_cache') 102 103 * @param array $body Request body parameters 104 * @param bool $skip_cap_check Skip capability check for internal requests 103 105 * @return array Response data array with 'success', 'message', and optional 'data' 104 106 */ 105 public static function make_api_request($endpoint, $body = [] ) {107 public static function make_api_request($endpoint, $body = [], $skip_cap_check = false) { 106 108 try { 107 $config = self::get_config( );109 $config = self::get_config($skip_cap_check); 108 110 if (!$config) { 109 111 self::log_error('API configuration not set');
Note: See TracChangeset
for help on using the changeset viewer.