From b074a869fc38bf7bfc8bb812295b16bce8194f61 Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:04:42 +0200 Subject: [PATCH 1/6] refactor ActionScheduler_AdminView admin notice --- classes/ActionScheduler_AdminView.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index ed30950a7..154d93ea0 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -190,8 +190,7 @@ protected function check_pastdue_actions() { ), admin_url( 'tools.php' ) ); # Print notice. - echo '

'; - printf( + $message = sprintf( // translators: 1) is the number of affected actions, 2) is a link to an admin screen. _n( 'Action Scheduler: %1$d past-due action found; something may be wrong. Read documentation »', @@ -202,7 +201,13 @@ protected function check_pastdue_actions() { $num_pastdue_actions, esc_attr( esc_url( $actions_url ) ) ); - echo '

'; + wp_admin_notice( + $message, + array( + 'type' => 'warning', + 'paragraph_wrap' => true, + ) + ); # Facilitate third-parties to evaluate and print notices. do_action( 'action_scheduler_pastdue_actions_extra_notices', $query_args ); From 48d9874985505b5b394867949b41867111fc2c71 Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:04:54 +0200 Subject: [PATCH 2/6] refactor ActionScheduler_WPCommentCleaner admin notice --- classes/ActionScheduler_WPCommentCleaner.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/classes/ActionScheduler_WPCommentCleaner.php b/classes/ActionScheduler_WPCommentCleaner.php index 1ba552c50..1b58be17f 100644 --- a/classes/ActionScheduler_WPCommentCleaner.php +++ b/classes/ActionScheduler_WPCommentCleaner.php @@ -90,7 +90,7 @@ public static function delete_all_action_comments() { public static function register_admin_notice() { add_action( 'admin_notices', array( __CLASS__, 'print_admin_notice' ) ); } - + /** * Prints details about the orphaned action logs and includes information on where to learn more. */ @@ -110,6 +110,12 @@ public static function print_admin_notice() { 'https://github.com/woocommerce/action-scheduler/issues/368' ); - echo '

' . wp_kses_post( $notice ) . '

'; + wp_admin_notice( + $notice, + array( + 'type' => 'warning', + 'paragraph_wrap' => true, + ) + ); } } From 830756e9623c71725259bcb0cd2d1abdd8b1354b Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:05:10 +0200 Subject: [PATCH 3/6] refactor migration controller admin notice --- classes/migration/Controller.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/migration/Controller.php b/classes/migration/Controller.php index b2b618d8f..38e03eb7a 100644 --- a/classes/migration/Controller.php +++ b/classes/migration/Controller.php @@ -159,7 +159,13 @@ public function hook_admin_notices() { * Show a dashboard notice that migration is in progress. */ public function display_migration_notice() { - printf( '

%s

', esc_html__( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) ); + wp_admin_notice( + __('Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ), + array( + 'type' => 'warning', + 'paragraph_wrap' => true + ) + ); } /** From 1651f2ad7f660b69fa0d8778aa5a90f6afc6db8e Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:09:53 +0200 Subject: [PATCH 4/6] refactor ActionScheduler List Table classes admin notices --- classes/ActionScheduler_ListTable.php | 12 ++++++------ .../ActionScheduler_Abstract_ListTable.php | 13 +++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php index abf767ce6..5e5fba727 100644 --- a/classes/ActionScheduler_ListTable.php +++ b/classes/ActionScheduler_ListTable.php @@ -360,7 +360,7 @@ public function display_admin_notices() { foreach ( $table_list as $table_name ) { if ( ! in_array( $wpdb->prefix . $table_name, $found_tables ) ) { $this->admin_notices[] = array( - 'class' => 'error', + 'type' => 'error', 'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).' , 'action-scheduler' ), ); $this->recreate_tables(); @@ -374,7 +374,7 @@ public function display_admin_notices() { if ( $this->runner->has_maximum_concurrent_batches() ) { $claim_count = $this->store->get_claim_count(); $this->admin_notices[] = array( - 'class' => 'updated', + 'type' => 'updated', 'message' => sprintf( /* translators: %s: amount of claims */ _n( @@ -401,7 +401,7 @@ public function display_admin_notices() { } $this->admin_notices[] = array( - 'class' => 'notice notice-info', + 'type' => 'info', 'message' => $async_request_message, ); } @@ -414,7 +414,7 @@ public function display_admin_notices() { $action = $this->store->fetch_action( $notification['action_id'] ); $action_hook_html = '' . $action->get_hook() . ''; if ( 1 == $notification['success'] ) { - $class = 'updated'; + $type = 'updated'; switch ( $notification['row_action_type'] ) { case 'run' : /* translators: %s: action HTML */ @@ -430,7 +430,7 @@ public function display_admin_notices() { break; } } else { - $class = 'error'; + $type = 'error'; /* translators: 1: action HTML 2: action ID 3: error message */ $action_message_html = sprintf( __( 'Could not process change for action: "%1$s" (ID: %2$d). Error: %3$s', 'action-scheduler' ), $action_hook_html, esc_html( $notification['action_id'] ), esc_html( $notification['error_message'] ) ); } @@ -438,7 +438,7 @@ public function display_admin_notices() { $action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification ); $this->admin_notices[] = array( - 'class' => $class, + 'type' => $type, 'message' => $action_message_html, ); } diff --git a/classes/abstracts/ActionScheduler_Abstract_ListTable.php b/classes/abstracts/ActionScheduler_Abstract_ListTable.php index 3c480e3da..078295de5 100644 --- a/classes/abstracts/ActionScheduler_Abstract_ListTable.php +++ b/classes/abstracts/ActionScheduler_Abstract_ListTable.php @@ -103,7 +103,7 @@ abstract class ActionScheduler_Abstract_ListTable extends WP_List_Table { protected $status_counts = array(); /** - * Notices to display when loading the table. Array of arrays of form array( 'class' => {updated|error}, 'message' => 'This is the notice text display.' ). + * Notices to display when loading the table. Array of arrays of form array( 'type' => {updated|error}, 'message' => 'This is the notice text display.' ). * * @var array */ @@ -675,9 +675,14 @@ protected function display_header() { */ protected function display_admin_notices() { foreach ( $this->admin_notices as $notice ) { - echo '
'; - echo '

' . wp_kses_post( $notice['message'] ) . '

'; - echo '
'; + wp_admin_notice( + $notice['message'], + array( + 'type' => $notice['type'] === 'updated' ? '' : $notice['type'], + 'paragraph_wrap' => true, + 'additional_classes' => ( $notice['type'] === 'updated' ? 'updated' : '') + ) + ); } } From c142676fef7261095c326367bd0cf87c28055a79 Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:12:39 +0200 Subject: [PATCH 5/6] update WordPress version requirement --- action-scheduler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action-scheduler.php b/action-scheduler.php index 1727f2823..4cc18287e 100644 --- a/action-scheduler.php +++ b/action-scheduler.php @@ -7,7 +7,7 @@ * Author URI: https://automattic.com/ * Version: 3.8.0 * License: GPLv3 - * Requires at least: 6.2 + * Requires at least: 6.4 * Tested up to: 6.5 * Requires PHP: 5.6 * From 406a3d9354a1e068192166344bd69c9dbe357ef0 Mon Sep 17 00:00:00 2001 From: Beau Fiechter Date: Thu, 20 Jun 2024 17:16:37 +0200 Subject: [PATCH 6/6] add notice ID for List Table notice, fix codestyle --- classes/abstracts/ActionScheduler_Abstract_ListTable.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/abstracts/ActionScheduler_Abstract_ListTable.php b/classes/abstracts/ActionScheduler_Abstract_ListTable.php index 078295de5..2c7e51840 100644 --- a/classes/abstracts/ActionScheduler_Abstract_ListTable.php +++ b/classes/abstracts/ActionScheduler_Abstract_ListTable.php @@ -678,9 +678,10 @@ protected function display_admin_notices() { wp_admin_notice( $notice['message'], array( - 'type' => $notice['type'] === 'updated' ? '' : $notice['type'], - 'paragraph_wrap' => true, - 'additional_classes' => ( $notice['type'] === 'updated' ? 'updated' : '') + 'id' => 'message', + 'type' => $notice['type'] === 'updated' ? '' : $notice['type'], + 'paragraph_wrap' => true, + 'additional_classes' => ( $notice['type'] === 'updated' ? 'updated' : ''), ) ); }