Allow developers to easily register batch processes through code, and run them through the admin UI
PHP JavaScript Shell CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
bin
includes
languages
templates
tests
.eslintrc.js
.gitignore
.scrutinizer.yml
.travis.yml
CHANGELOG.md
README.md
codecoverage.xml.dist
composer.json
composer.lock
gulpfile.js
locomotive.php
multisite.xml.dist
package.json
phpunit.xml.dist
ruleset.xml
screenshot.png

README.md

Locomotive

Scrutinizer Code Quality Code Coverage

About

Locomotive Menu

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 ) );
}

Contributors

Changelog

See CHANGELOG.md.

Pull requests are very much welcome and encouraged.