diff --git a/includes/class-custom-action.php b/includes/class-custom-action.php index 5aaeb31fb9640d02673abfab11b5393b5fc3aea0..f35e715d7b7dd70bbab587daa60b3d0fd352da8f 100644 --- a/includes/class-custom-action.php +++ b/includes/class-custom-action.php @@ -81,28 +81,6 @@ class Custom_Action { 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 - * - * @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; - } } Custom_Action::register_hooks(); diff --git a/includes/class-edit.php b/includes/class-edit.php index d153944baf79dc027a59e1bbf085ffff572fa3ca..9f1b9f524a9df78943a75032aea376ffbb3052f9 100644 --- a/includes/class-edit.php +++ b/includes/class-edit.php @@ -101,28 +101,6 @@ class Edit { 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 - * - * @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; - } } Edit::register_hooks(); diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php index 3417e2a57b6e49a051d72d9a2f5ad39d9c27436f..b6214eeed5bbf66264ae7a40d77b07b51e33a632 100644 --- a/includes/trait-bulk-actions.php +++ b/includes/trait-bulk-actions.php @@ -19,7 +19,7 @@ trait Bulk_Actions { add_action( Main::build_cron_hook( self::ACTION ), array( __CLASS__, 'process_via_cron' ) ); add_action( 'admin_notices', array( __CLASS__, 'render_admin_notices' ) ); - add_filter( 'posts_where', array( __CLASS__, 'hide_posts' ), 999, 2 ); + add_filter( 'posts_where', array( __CLASS__, 'hide_posts_common' ), 999, 2 ); add_filter( 'removable_query_args', array( __CLASS__, 'remove_notice_arg' ) ); @@ -123,13 +123,13 @@ trait Bulk_Actions { } /** - * When an edit is pending for a given post type, hide those posts in the admin + * When a process is pending for a given post type, hide those posts in the admin * * @param string $where Posts' WHERE clause. * @param object $q WP_Query object. * @return string */ - public static function hide_posts( $where, $q ) { + public static function hide_posts_common( $where, $q ) { if ( ! is_admin() || ! $q->is_main_query() ) { return $where; } @@ -138,7 +138,29 @@ trait Bulk_Actions { return $where; } - return parent::hide_posts( $where, $q ); + return self::hide_posts( $where, $q ); + } + + /** + * Hide posts pending processing + * + * @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; } /**