Skip to content

Commit

Permalink
Don't show msg if autoupdates aren't available or if plugin is deacti…
Browse files Browse the repository at this point in the history
…vated

e.g. If not connected to WC.com, updates for paid plugins won't be available, so we shouldn't show the autoupdated message. Also, plugins won't autoupdate if deactivated, so no message.
NickGreen committed Oct 17, 2024
1 parent 4470387 commit 095e5bd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions class-plugin-autoupdate-filter.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
* @package Plugin_Autoupdate_Filter
*/

use AutomateWoo\Error;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
@@ -169,7 +171,7 @@ public function filter_enforce_delay( $update, $item ): bool {
if ( false === $has_delay_passed ) {
$option_key = 'plugin_update_delays';
$delays = get_option( $option_key, array() );
if ( isset( $delays[ $plugin_file ][ $plugin_new_version ] ) && is_numeric( $delays[ $plugin_file ][ $plugin_new_version ] ) ) {
if ( isset( $delays[ $plugin_file ][ $plugin_new_version ] ) && is_numeric( $delays[ $plugin_file ][ $plugin_new_version ] ) && ( ! empty( $plugin_file ) && is_plugin_active( $plugin_file ) ) ) {
$delay_date = $delays[ $plugin_file ][ $plugin_new_version ];

// Get the site's date and time format settings.
@@ -180,8 +182,10 @@ public function filter_enforce_delay( $update, $item ): bool {
// adds message to update notice box for that plugin on the plugins page
add_filter(
"in_plugin_update_message-{$plugin_file}",
function() use ( $plugin_new_version, $formatted_date ) {
echo ' For stability, autoupdates operate on a slight delay. Autoupdate to version ' . esc_html( $plugin_new_version ) . ' is currently estimated to run after ' . esc_html( $formatted_date ) . ' UTC.';
function( $plugin_data, $response ) use ( $plugin_new_version, $formatted_date ) {
if ( ! empty( $response->package ) ) {
echo ' For stability, autoupdates operate on a slight delay. Autoupdate to version ' . esc_html( $plugin_new_version ) . ' is currently estimated to run after ' . esc_html( $formatted_date ) . ' UTC.';
}
},
10,
2

0 comments on commit 095e5bd

Please sign in to comment.