From 16aba52c8a6d2be9987c5f0549e9d2abfd42c969 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Fri, 15 Sep 2017 16:02:12 -0700
Subject: [PATCH] Move another common function to the trait

---
 includes/class-custom-action.php | 37 ++++++++------------------------
 includes/class-edit.php          | 37 ++++++++------------------------
 includes/trait-bulk-actions.php  | 37 ++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/includes/class-custom-action.php b/includes/class-custom-action.php
index 01f6921..5aaeb31 100644
--- a/includes/class-custom-action.php
+++ b/includes/class-custom-action.php
@@ -55,34 +55,6 @@ class Custom_Action {
 		do_action( 'bulk_actions_cron_offload_custom_request_completed', $results, $vars );
 	}
 
-	/**
-	 * 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 processed. These items are hidden until processing completes.', 'bulk-actions-cron-offload' );
-			}
-		}
-
-		Main::render_admin_notice( $type, $message );
-	}
-
 	/**
 	 * Provide post-redirect success message
 	 *
@@ -101,6 +73,15 @@ class Custom_Action {
 		return __( 'The requested processing is already pending for the chosen posts.', 'bulk-actions-cron-offload' );
 	}
 
+	/**
+	 * Provide 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 processed. These items are hidden until processing completes.', 'bulk-actions-cron-offload' );
+	}
+
 	/**
 	 * When an edit is pending for a given post type, hide those posts in the admin
 	 *
diff --git a/includes/class-edit.php b/includes/class-edit.php
index 5361b30..d153944 100644
--- a/includes/class-edit.php
+++ b/includes/class-edit.php
@@ -75,34 +75,6 @@ class Edit {
 		do_action( 'bulk_actions_cron_offload_edit_request_completed', $results, $vars );
 	}
 
-	/**
-	 * 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 edited. These items are hidden until they are processed.', 'bulk-actions-cron-offload' );
-			}
-		}
-
-		Main::render_admin_notice( $type, $message );
-	}
-
 	/**
 	 * Provide post-redirect success message
 	 *
@@ -121,6 +93,15 @@ class Edit {
 		return __( 'The requested edits are already pending for the chosen posts.', 'bulk-actions-cron-offload' );
 	}
 
+	/**
+	 * Provide notice when posts are hidden pending edits
+	 *
+	 * @return string
+	 */
+	public static function admin_notice_hidden_pending_processing() {
+		return __( 'Some items that would normally be shown here are waiting to be edited. These items are hidden until they are processed.', 'bulk-actions-cron-offload' );
+	}
+
 	/**
 	 * When an edit is pending for a given post type, hide those posts in the admin
 	 *
diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php
index 4580755..3417e2a 100644
--- a/includes/trait-bulk-actions.php
+++ b/includes/trait-bulk-actions.php
@@ -67,6 +67,34 @@ trait Bulk_Actions {
 		self::admin_notices();
 	}
 
+	/**
+	 * 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 = self::admin_notice_hidden_pending_processing();
+			}
+		}
+
+		Main::render_admin_notice( $type, $message );
+	}
+
 	/**
 	 * Provide translated success message for bulk action
 	 *
@@ -85,6 +113,15 @@ trait Bulk_Actions {
 		return '';
 	}
 
+	/**
+	 * Provide translated message when posts are hidden pending processing
+	 *
+	 * @return string
+	 */
+	public static function admin_notice_hidden_pending_processing() {
+		return '';
+	}
+
 	/**
 	 * When an edit is pending for a given post type, hide those posts in the admin
 	 *
-- 
GitLab