Automattic\WooCommerce\Admin\API
OnboardingPlugins::get_scheduled_installs
Returns current status of given job.
Method of the class: OnboardingPlugins{}
No Hooks.
Returns
Array|WP_REST_Response.
Usage
$OnboardingPlugins = new OnboardingPlugins(); $OnboardingPlugins->get_scheduled_installs( $request );
- $request(WP_REST_Request) (required)
- WP_REST_Request object.
OnboardingPlugins::get_scheduled_installs() OnboardingPlugins::get scheduled installs code WC 10.3.6
public function get_scheduled_installs( WP_REST_Request $request ) {
$job_id = $request->get_param( 'job_id' );
$actions = WC()->queue()->search(
array(
'hook' => 'woocommerce_plugins_install_and_activate_async_callback',
'search' => $job_id,
'orderby' => 'date',
'order' => 'DESC',
)
);
$actions = array_filter(
PluginsHelper::get_action_data( $actions ),
function ( $action ) use ( $job_id ) {
return $action['job_id'] === $job_id;
}
);
if ( empty( $actions ) ) {
return new WP_REST_Response( null, 404 );
}
$response = array(
'job_id' => $actions[0]['job_id'],
'status' => $actions[0]['status'],
);
$option = get_option( 'woocommerce_onboarding_plugins_install_and_activate_async_' . $job_id );
if ( isset( $option['plugins'] ) ) {
$response['plugins'] = $option['plugins'];
}
return $response;
}