Locomotive
Allow developers to easily register batch processes through code, and run them through the admin UI
Install / Use
/learn @reaktivstudios/LocomotiveREADME
Locomotive
About

Creating batch processes in WordPress has never been so easy. If you've ever wanted to query a large dataset and perform simple and repeatable actions, then Locomotive is for you.
Locomotive allows developers to write a single function (or set of functions) to process actions across a large data set. These registered batch processes can be run with the click of a button from the WP admin as needed. Locomotive handles the complexity of batch processing by automatically chunking up data, checking for records that have already been processed and logging errors as they come in.
Links
Quick Start Example
Register a standard post query
function my_post_query_batch_process() {
register_batch_process( array(
'name' => 'Just another batch',
'type' => 'post',
'callback' => 'my_callback_function',
'args' => array(
'posts_per_page' => 1,
'post_type' => 'post',
),
) );
}
add_action( 'locomotive_init', 'my_post_query_batch_process' );
Hook In Callback Function
/**
* This is what we want to do with each individual result during a batch routine.
*
* @param array $result Individual result from batch query.
*/
function my_callback_function( $result ) {
error_log( print_r( $result->post_title, true ) );
}
Start Batch Process

Navigate to Tools->Batches in the admin, select your batch, and click Run.
Contributors
Changelog
See CHANGELOG.md.


