Skip to content

Commit

Permalink
v1.3.4: Fix auto-purge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lsthompson committed Jun 14, 2023
1 parent d90012b commit 0cf9496
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
17 changes: 8 additions & 9 deletions tnc-toolbox/core/includes/classes/class-tnc-wp-toolbox-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ private function add_hooks(){
add_action( 'admin_post_nginx_cache_on', array( $this, 'nginx_cache_on' ) );
add_action( 'admin_notices', array( $this, 'tnc_wp_toolbox_nginx_action_error_notice') );
add_action( 'admin_notices', array( $this, 'tnc_wp_toolbox_nginx_action_success_notice') );
add_action( 'save_post', array( $this, 'purge_cache_on_update' ), 10, 3 );
add_action( 'post_updated', array( $this, 'purge_cache_on_update' ), 10, 3 );

add_action( 'tnc_scheduled_cache_purge', array( $this, 'nginx_cache_purge' ) );
add_action( 'post_updated', array( $this, 'purge_cache_on_update' ), 10, 3 );
}

/**
Expand Down Expand Up @@ -148,9 +147,9 @@ public function enqueue_custom_css() {
wp_register_style( 'tnc_custom_css', false );
wp_enqueue_style( 'tnc_custom_css' );
$custom_css = "
/* .nginx-cache-btn.nginx-cache-off a { background-color: #d63638 !important; }
.nginx-cache-btn.nginx-cache-off a { background-color: #d63638 !important; }
.nginx-cache-btn.nginx-cache-purge a { background-color: #ff9500 !important; }
.nginx-cache-btn.nginx-cache-on a { background-color: green !important; } */
.nginx-cache-btn.nginx-cache-on a { background-color: green !important; }
";
wp_add_inline_style( 'tnc_custom_css', $custom_css );
}
Expand Down Expand Up @@ -288,11 +287,11 @@ function nginx_cache_purge() {
*
* @return void
*/
public function purge_cache_on_update( $post_id, $post, $update ){
public function purge_cache_on_update( $post_id, $post_after, $post_before ) {
// Check if the post is published or updated
if ( 'publish' === $post->post_status || $update ) {
// Purge the cache
$this->nginx_cache_purge();
if ( 'publish' === $post_after->post_status || ( $post_before->post_status === 'publish' && $post_after->post_status !== 'trash' ) ) {
// Schedule the cache purge to run after the current request
wp_schedule_single_event( time(), 'tnc_scheduled_cache_purge' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function render_settings_page() {
?>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<h4>To communicate with the cPanel API (UAPI), we need your API Token, Username & Server Hostname.</h4>
<form method="post">
<input type="hidden" name="action" value="tnc_toolbox_settings" />
<?php wp_nonce_field( 'tnc_toolbox_settings', 'tnc_toolbox_settings_nonce' ); ?>
Expand Down
7 changes: 5 additions & 2 deletions tnc-toolbox/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tags:
Requires at least:
Tested up to: 6.2
Requires PHP:
Stable tag: 1.3.3
Stable tag: 1.3.4
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -60,7 +60,10 @@ Most likely due to newline /n characters in your config files. Use the [script](

== Changelog ==

= 1.3.3: June 13, 2023 =
= 1.3.4: June 14, 2023 =
* Auto-purge: Fix GUI save issue

= 1.3.3: June 14, 2023 =
* Top bar links: Move into sub-menu

= 1.3.2: June 13, 2023 =
Expand Down
6 changes: 3 additions & 3 deletions tnc-toolbox/tnc-wp-toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* @package TNCWPTBOX
* @author The Network Crew Pty Ltd
* @license gplv2
* @version 1.3.3
* @version 1.3.4
*
* @wordpress-plugin
* Plugin Name: TNC Toolbox
* Plugin URI: https://leopard.host
* Description: Adds functionality to WP that ties into your NGINX-powered Hosting on cPanel.
* Version: 1.3.2
* Version: 1.3.4
* Author: The Network Crew Pty Ltd
* Author URI: https://thenetworkcrew.com.au
* Domain Path: /languages
Expand Down Expand Up @@ -46,7 +46,7 @@
define( 'TNCWPTBOX_NAME', 'TNC Toolbox' );

// Plugin version
define( 'TNCWPTBOX_VERSION', '1.3.3' );
define( 'TNCWPTBOX_VERSION', '1.3.4' );

// Plugin Root File
define( 'TNCWPTBOX_PLUGIN_FILE', __FILE__ );
Expand Down

0 comments on commit 0cf9496

Please sign in to comment.