Giter Site home page Giter Site logo

leepeterson / locomotive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reaktivstudios/locomotive

0.0 2.0 0.0 780 KB

Allow developers to easily register batch processes through code, and run them through the admin UI

JavaScript 22.56% CSS 2.48% Shell 3.95% PHP 71.01%

locomotive's Introduction

Locomotive

Scrutinizer Code Quality Code Coverage

About

Locomotive Logo

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

Locomotive Menu

Navigate to Tools->Batches in the admin, select your batch, and click Run.

Contributors

Changelog

See CHANGELOG.md.

Pull requests are very much welcome and encouraged.

locomotive's People

Contributors

zachwills avatar jasonhoffmann avatar jjeaton avatar norcross avatar shelob9 avatar

Watchers

James Cloos avatar Lee Peterson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.