Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WP 6.4 Admin Notices #1073

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
11 changes: 8 additions & 3 deletions classes/ActionScheduler_AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ protected function check_pastdue_actions() {
), admin_url( 'tools.php' ) );

# Print notice.
echo '<div class="notice notice-warning"><p>';
printf(
$message = sprintf(
// translators: 1) is the number of affected actions, 2) is a link to an admin screen.
_n(
'<strong>Action Scheduler:</strong> %1$d <a href="%2$s">past-due action</a> found; something may be wrong. <a href="https://actionscheduler.org/faq/#my-site-has-past-due-actions-what-can-i-do" target="_blank">Read documentation &raquo;</a>',
Expand All @@ -202,7 +201,13 @@ protected function check_pastdue_actions() {
$num_pastdue_actions,
esc_attr( esc_url( $actions_url ) )
);
echo '</p></div>';
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 );
Expand Down
12 changes: 6 additions & 6 deletions classes/ActionScheduler_ListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand All @@ -401,7 +401,7 @@ public function display_admin_notices() {
}

$this->admin_notices[] = array(
'class' => 'notice notice-info',
'type' => 'info',
'message' => $async_request_message,
);
}
Expand All @@ -414,7 +414,7 @@ public function display_admin_notices() {
$action = $this->store->fetch_action( $notification['action_id'] );
$action_hook_html = '<strong><code>' . $action->get_hook() . '</code></strong>';
if ( 1 == $notification['success'] ) {
$class = 'updated';
$type = 'updated';
switch ( $notification['row_action_type'] ) {
case 'run' :
/* translators: %s: action HTML */
Expand All @@ -430,15 +430,15 @@ 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'] ) );
}

$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,
);
}
Expand Down
10 changes: 8 additions & 2 deletions classes/ActionScheduler_WPCommentCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -110,6 +110,12 @@ public static function print_admin_notice() {
'https://github.com/woocommerce/action-scheduler/issues/368'
);

echo '<div class="notice notice-warning"><p>' . wp_kses_post( $notice ) . '</p></div>';
wp_admin_notice(
$notice,
array(
'type' => 'warning',
'paragraph_wrap' => true,
)
);
}
}
14 changes: 10 additions & 4 deletions classes/abstracts/ActionScheduler_Abstract_ListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -675,9 +675,15 @@ protected function display_header() {
*/
protected function display_admin_notices() {
foreach ( $this->admin_notices as $notice ) {
echo '<div id="message" class="' . esc_attr( $notice['class'] ) . '">';
echo ' <p>' . wp_kses_post( $notice['message'] ) . '</p>';
echo '</div>';
wp_admin_notice(
$notice['message'],
array(
'id' => 'message',
'type' => $notice['type'] === 'updated' ? '' : $notice['type'],
'paragraph_wrap' => true,
'additional_classes' => ( $notice['type'] === 'updated' ? 'updated' : ''),
)
);
}
}

Expand Down
8 changes: 7 additions & 1 deletion classes/migration/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ public function hook_admin_notices() {
* Show a dashboard notice that migration is in progress.
*/
public function display_migration_notice() {
printf( '<div class="notice notice-warning"><p>%s</p></div>', 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
)
);
}

/**
Expand Down