Skip to content
Snippets Groups Projects
Commit a944eb75 authored by Erick Hitter's avatar Erick Hitter
Browse files

Load all of wp-admin's includes, for all actions, since these normally happen in that context

parent 76f650e1
Branches
No related tags found
No related merge requests found
......@@ -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 );
}
......
......@@ -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();
......
......@@ -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();
......
......@@ -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'] );
......
......@@ -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();
......
......@@ -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();
......
......@@ -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
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment