diff --git a/includes/class-custom-action.php b/includes/class-custom-action.php index f35e715d7b7dd70bbab587daa60b3d0fd352da8f..69753c0848cace2c10be519eb8488aad53ae234d 100644 --- a/includes/class-custom-action.php +++ b/includes/class-custom-action.php @@ -33,9 +33,6 @@ class Custom_Action { * @param object $vars Bulk-request variables. */ public static function process_via_cron( $vars ) { - // Normally processed in the admin context. - require_once( ABSPATH . 'wp-admin/includes/admin.php' ); - // Provide for capabilities checks. wp_set_current_user( $vars->user_id ); @@ -50,7 +47,7 @@ class Custom_Action { // Run the custom action as Core does. See note above. $return_url = apply_filters( 'handle_bulk_actions-' . $vars->current_screen->id, $return_url, $vars->action, $vars->posts ); - // + // Can't get much more than this in terms of success or failure. $results = compact( 'return_url', 'vars' ); do_action( 'bulk_actions_cron_offload_custom_request_completed', $results, $vars ); } diff --git a/includes/class-delete-all.php b/includes/class-delete-all.php index 14744d79c88d4761f040b132526f49245b9c7f1a..ec51f75536063ba495e6e86ec4da2cc11a94f4e7 100644 --- a/includes/class-delete-all.php +++ b/includes/class-delete-all.php @@ -64,8 +64,6 @@ class Delete_All { $count = 0; if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { - require_once ABSPATH . '/wp-admin/includes/post.php'; - $deleted = array(); $locked = array(); $auth_error = array(); diff --git a/includes/class-delete-permanently.php b/includes/class-delete-permanently.php index 7221433e485b4d3133a6acd10b1f527fbe569904..6b0419a156a42ae3a7a5f8cac64ba20b67362cc1 100644 --- a/includes/class-delete-permanently.php +++ b/includes/class-delete-permanently.php @@ -32,8 +32,6 @@ class Delete_Permanently { $count = 0; if ( is_array( $vars->posts ) && ! empty( $vars->posts ) ) { - require_once ABSPATH . '/wp-admin/includes/post.php'; - $deleted = array(); $locked = array(); $auth_error = array(); diff --git a/includes/class-edit.php b/includes/class-edit.php index 9f1b9f524a9df78943a75032aea376ffbb3052f9..595f984fc9cdfa2c2f468ba67fae152aa5bc6afb 100644 --- a/includes/class-edit.php +++ b/includes/class-edit.php @@ -35,9 +35,6 @@ class Edit { return; } - // We want to use `bulk_edit_posts()`. - require_once ABSPATH . '/wp-admin/includes/post.php'; - // `bulk_edit_posts()` takes an array, normally `$_REQUEST`, so we convert back. $request_array = get_object_vars( $vars ); unset( $request_array['action'] ); diff --git a/includes/class-move-to-trash.php b/includes/class-move-to-trash.php index 92f372d95e1832e685984632818a565c07fd5a60..8ccf2f0d587bb010e919ba3cb1906a6ca738dc58 100644 --- a/includes/class-move-to-trash.php +++ b/includes/class-move-to-trash.php @@ -32,8 +32,6 @@ class Move_To_Trash { $count = 0; if ( is_array( $vars->posts ) && ! empty( $vars->posts ) ) { - require_once ABSPATH . '/wp-admin/includes/post.php'; - $trashed = array(); $locked = array(); $auth_error = array(); diff --git a/includes/class-restore-from-trash.php b/includes/class-restore-from-trash.php index 7a65393a853b7dfd638471b044b374d99c8ab8f4..9100f0704078907bcb08502acc6e1c7c9929883f 100644 --- a/includes/class-restore-from-trash.php +++ b/includes/class-restore-from-trash.php @@ -32,8 +32,6 @@ class Restore_From_Trash { $count = 0; if ( is_array( $vars->posts ) && ! empty( $vars->posts ) ) { - require_once ABSPATH . '/wp-admin/includes/post.php'; - $restored = array(); $locked = array(); $auth_error = array(); diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php index b6214eeed5bbf66264ae7a40d77b07b51e33a632..a504c2bfe4ec5fb9b249743ef2495a7cbf3280f5 100644 --- a/includes/trait-bulk-actions.php +++ b/includes/trait-bulk-actions.php @@ -47,6 +47,18 @@ trait Bulk_Actions { } } + /** + * Prepare environment for individual actions + * + * @param object $vars Bulk-request variables. + */ + public static function process_via_cron( $vars ) { + // Normally processed in the admin context. + require_once( ABSPATH . 'wp-admin/includes/admin.php' ); + + parent::process_via_cron( $vars ); + } + /** * Render the post-redirect notice, or hand off to class for other notices */