BatchPress
A little plugin to help process data in batches.
★ 5stars
9composer installs
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/lambry/batchpress/archive/refs/heads/master.zipAlso on Packagist as lambry/batchpress:
composer require lambry/batchpressFrom the readme
BatchPress
BatchPress is a little plugin to help process data in batches, with BatchPress you can run, monitor and cancel batched jobs.
Install: composer require lambry/batchpress
Usage
To use BatchPress create a new class per job and register those classes using the batchpress/jobs filter.
Job class outline:
- Required: label property to describe the job.
- Required: process method which is passed a single item for processing; any info/errors can be returned and will be displayed in the log.
- Optional|Required: items method is optional if the upload property is set to true, in this case it can be used to filter the uploaded content before staring the job. If upload if false or not defined the method is then required to return an array of items for processing.
- Optional: upload property to tell BatchPress if a CSV upload is required.
- Optional: batch property to set the number of items to process per batch.
- Optional: description property to provide extra details about the job.
Basic Example
Example with CSV upload
Registering jobs
Helpers
BatchPress provides some helper methods as well, to use them just include the Helpers trait in your job class.