From ee296499e1ed074ccb655eb2f634573c56ca250a Mon Sep 17 00:00:00 2001 From: Erick Hitter <services@ethitter.com> Date: Wed, 1 Mar 2017 12:42:45 -0800 Subject: [PATCH] Display notice for anyone who accesses the trash while a purge is pending --- includes/class-delete-all.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/includes/class-delete-all.php b/includes/class-delete-all.php index 261bf5e..e897850 100644 --- a/includes/class-delete-all.php +++ b/includes/class-delete-all.php @@ -109,16 +109,26 @@ class Delete_All { * Let the user know what's going on */ public static function admin_notices() { - if ( ! isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { - return; + $screen = get_current_screen(); + + if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { + if ( 1 === (int) $_REQUEST[self::ADMIN_NOTICE_KEY] ) { + $class = 'notice-success'; + $message = __( 'Success! The trash will be emptied soon.', 'automattic-bulk-edit-cron-offload' ); + } else { + $class = 'notice-error'; + $message = __( 'A request to empty the trash is already pending for this post type.', 'automattic-bulk-edit-cron-offload' ); + } + } elseif ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { + if ( self::action_next_scheduled( self::CRON_EVENT, $screen->post_type ) ) { + $class = 'notice-warning'; + $message = __( 'A pending request to empty the trash will be processed soon.', 'automattic-bulk-edit-cron-offload' ); + } } - if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) { - $class = 'notice-success'; - $message = __( 'Success! The trash will be emptied soon.', 'automattic-bulk-edit-cron-offload' ); - } else { - $class = 'notice-error'; - $message = __( 'A request to empty the trash is already pending for this post type.', 'automattic-bulk-edit-cron-offload' ); + // Nothing to display + if ( ! isset( $class ) || ! isset( $message ) ) { + return; } ?> -- GitLab