-
Notifications
You must be signed in to change notification settings - Fork 0
How To Add Tasks
TaskBot works as a batched system. The function below will add your items as a batch. By default, it will chunk into batches of 500 items (overridable in settings). It uses wp-cron to load a batch and process each item.
For each item in your batch it will do an ajax call to server and process the item.
// Function to add tasks
taskbot_add_items( array(
'task' => 'task_id', // this is the id of the task. saved to each batch, used during recess hook
'items' => array(), // the items to be processed. This would be something like array of user ids
'data' => array(), // extra data to use during each item process.
) );
// Hook your item process to a dynamic action hook.
function wp38282_process_item( $task_data ) {
}
add_action( 'taskbot_run_{task_id}', 'wp38282_process_item' );
{task_id} should be the task from taskbot_add_items function args. TaskBot will hit this action for each item. You can use any code you want process the item.
For example, you could add post ids as items and then process each post to delete comments that contain spam links.
To add a task to the admin UI see this Class example:
https://gist.github.com/modemlooper/31d27df65bd7610e48a2fd6734271cde