From fbd89188085217e3915b0f75516df62e0f91b042 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Thu, 14 Sep 2017 19:42:28 -0700 Subject: [PATCH] Move scheduling to a trait as it's mostly universal --- includes/class-delete-permanently.php | 16 ---------------- includes/class-edit.php | 16 ---------------- includes/class-move-to-trash.php | 16 ---------------- includes/class-restore-from-trash.php | 16 ---------------- includes/trait-bulk-actions.php | 16 ++++++++++++++++ 5 files changed, 16 insertions(+), 64 deletions(-) diff --git a/includes/class-delete-permanently.php b/includes/class-delete-permanently.php index e968758..4b80dff 100644 --- a/includes/class-delete-permanently.php +++ b/includes/class-delete-permanently.php @@ -23,22 +23,6 @@ class Delete_Permanently { const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_delete_permanently'; - /** - * Handle a request to delete selected posts from the trash - * - * @param object $vars Bulk-request variables. - */ - public static function process( $vars ) { - $action_scheduled = Main::next_scheduled( $vars ); - - if ( empty( $action_scheduled ) ) { - Main::schedule_processing( $vars ); - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, true ); - } else { - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, false ); - } - } - /** * Cron callback to move requested items to trash * diff --git a/includes/class-edit.php b/includes/class-edit.php index b39f753..42185cb 100644 --- a/includes/class-edit.php +++ b/includes/class-edit.php @@ -23,22 +23,6 @@ class Edit { const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_edit'; - /** - * Handle a request to edit some posts - * - * @param object $vars Bulk-request variables. - */ - public static function process( $vars ) { - $action_scheduled = Main::next_scheduled( $vars ); - - if ( empty( $action_scheduled ) ) { - Main::schedule_processing( $vars ); - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, true ); - } else { - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, false ); - } - } - /** * Cron callback to edit requested items * diff --git a/includes/class-move-to-trash.php b/includes/class-move-to-trash.php index 379dd25..d087726 100644 --- a/includes/class-move-to-trash.php +++ b/includes/class-move-to-trash.php @@ -23,22 +23,6 @@ class Move_To_Trash { const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_move_to_trash'; - /** - * Handle a request to move some posts to the trash - * - * @param object $vars Bulk-request variables. - */ - public static function process( $vars ) { - $action_scheduled = Main::next_scheduled( $vars ); - - if ( empty( $action_scheduled ) ) { - Main::schedule_processing( $vars ); - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, true ); - } else { - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, false ); - } - } - /** * Cron callback to move requested items to trash * diff --git a/includes/class-restore-from-trash.php b/includes/class-restore-from-trash.php index b36c6a5..65092a7 100644 --- a/includes/class-restore-from-trash.php +++ b/includes/class-restore-from-trash.php @@ -23,22 +23,6 @@ class Restore_From_Trash { const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_restore_from_trash'; - /** - * Handle a request to restore some posts from the trash - * - * @param object $vars Bulk-request variables. - */ - public static function process( $vars ) { - $action_scheduled = Main::next_scheduled( $vars ); - - if ( empty( $action_scheduled ) ) { - Main::schedule_processing( $vars ); - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, true ); - } else { - Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, false ); - } - } - /** * Cron callback to restore requested items from trash * diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php index 4c90149..163e574 100644 --- a/includes/trait-bulk-actions.php +++ b/includes/trait-bulk-actions.php @@ -28,6 +28,22 @@ trait Bulk_Actions { */ public static function register_extra_hooks() {} + /** + * Process request + * + * @param object $vars Bulk-request variables. + */ + public static function process( $vars ) { + $action_scheduled = Main::next_scheduled( $vars ); + + if ( empty( $action_scheduled ) ) { + Main::schedule_processing( $vars ); + Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, true ); + } else { + Main::do_admin_redirect( self::ADMIN_NOTICE_KEY, false ); + } + } + /** * When an edit is pending for a given post type, hide those posts in the admin * -- GitLab