From 76f650e106c3ba0d153ae2dd46324f34bbf89822 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Fri, 15 Sep 2017 16:19:05 -0700 Subject: [PATCH] Last? of the trait conversion --- includes/class-delete-all.php | 11 ++++++- includes/class-delete-permanently.php | 11 ++++++- includes/class-move-to-trash.php | 47 ++------------------------- includes/class-restore-from-trash.php | 11 ++++++- 4 files changed, 33 insertions(+), 47 deletions(-) diff --git a/includes/class-delete-all.php b/includes/class-delete-all.php index a7d15c7..14744d7 100644 --- a/includes/class-delete-all.php +++ b/includes/class-delete-all.php @@ -120,7 +120,7 @@ class Delete_All { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { if ( Main::get_action_next_scheduled( self::ACTION, $screen->post_type ) ) { $type = 'warning'; - $message = __( 'A pending request to empty the trash will be processed soon.', 'bulk-actions-cron-offload' ); + $message = self::admin_notice_hidden_pending_processing(); } } @@ -145,6 +145,15 @@ class Delete_All { return __( 'A request to empty the trash is already pending for this post type.', 'bulk-actions-cron-offload' ); } + /** + * Provide translated message when posts are hidden pending processing + * + * @return string + */ + public static function admin_notice_hidden_pending_processing() { + return __( 'A pending request to empty the trash will be processed soon.', 'bulk-actions-cron-offload' ); + } + /** * When a delete is pending for a given post type, hide those posts in the admin * diff --git a/includes/class-delete-permanently.php b/includes/class-delete-permanently.php index 7400593..7221433 100644 --- a/includes/class-delete-permanently.php +++ b/includes/class-delete-permanently.php @@ -88,7 +88,7 @@ class Delete_Permanently { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) { $type = 'warning'; - $message = __( 'Some items that would normally be shown here are waiting to be deleted permanently. These items are hidden until then.', 'bulk-actions-cron-offload' ); + $message = self::admin_notice_hidden_pending_processing(); } } @@ -113,6 +113,15 @@ class Delete_Permanently { return __( 'The selected posts are already scheduled to be deleted.', 'bulk-actions-cron-offload' ); } + /** + * Provide translated message when posts are hidden pending processing + * + * @return string + */ + public static function admin_notice_hidden_pending_processing() { + return __( 'Some items that would normally be shown here are waiting to be deleted permanently. These items are hidden until then.', 'bulk-actions-cron-offload' ); + } + /** * When a delete is pending for a given post type, hide those posts in the admin * diff --git a/includes/class-move-to-trash.php b/includes/class-move-to-trash.php index 74588f7..92f372d 100644 --- a/includes/class-move-to-trash.php +++ b/includes/class-move-to-trash.php @@ -74,34 +74,6 @@ class Move_To_Trash { } } - /** - * Let the user know what's going on - * - * Not used for post-request redirect - */ - public static function admin_notices() { - $screen = get_current_screen(); - - $type = ''; - $message = ''; - - if ( 'edit' === $screen->base ) { - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { - return; - } - - $status = isset( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; - $pending = Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, $status ); - - if ( ! empty( $pending ) ) { - $type = 'warning'; - $message = __( 'Some items that would normally be shown here are waiting to be moved to the trash. These items are hidden until they are moved.', 'bulk-actions-cron-offload' ); - } - } - - Main::render_admin_notice( $type, $message ); - } - /** * Provide post-redirect success message * @@ -121,25 +93,12 @@ class Move_To_Trash { } /** - * When a move is pending for a given post type, hide those posts in the admin + * Provide translated message when posts are hidden pending move * - * @param string $where Posts' WHERE clause. - * @param object $q WP_Query object. * @return string */ - public static function hide_posts( $where, $q ) { - if ( 'trash' === $q->get( 'post_status' ) ) { - return $where; - } - - $post__not_in = Main::get_post_ids_for_pending_events( self::ACTION, $q->get( 'post_type' ), $q->get( 'post_status' ) ); - - if ( ! empty( $post__not_in ) ) { - $post__not_in = implode( ',', $post__not_in ); - $where .= ' AND ID NOT IN(' . $post__not_in . ')'; - } - - return $where; + public static function admin_notice_hidden_pending_processing() { + return __( 'Some items that would normally be shown here are waiting to be moved to the trash. These items are hidden until they are moved.', 'bulk-actions-cron-offload' ); } } diff --git a/includes/class-restore-from-trash.php b/includes/class-restore-from-trash.php index c3bc234..7a65393 100644 --- a/includes/class-restore-from-trash.php +++ b/includes/class-restore-from-trash.php @@ -88,7 +88,7 @@ class Restore_From_Trash { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) { $type = 'warning'; - $message = __( 'Some items that would normally be shown here are waiting to be restored from the trash. These items are hidden until they are restored.', 'bulk-actions-cron-offload' ); + $message = self::admin_notice_hidden_pending_processing(); } } @@ -113,6 +113,15 @@ class Restore_From_Trash { return __( 'The selected posts are already scheduled to be restored.', 'bulk-actions-cron-offload' ); } + /** + * Provide translated message when posts are hidden pending restoration + * + * @return string + */ + public static function admin_notice_hidden_pending_processing() { + return __( 'Some items that would normally be shown here are waiting to be restored from the trash. These items are hidden until they are restored.', 'bulk-actions-cron-offload' );; + } + /** * When a restore is pending for a given post type, hide those posts in the admin * -- GitLab