VAT
Your cart

Your cart is empty.

Background actions hooks

This page lists the 10 hooks of this group. Each entry shows its type, the version it arrived in, where it runs, its arguments and a starting point.

adba_background_follow_ups

FilterSince 2.33.0 Runs in src/Modules/Background/FollowUps.php.

Filters whether the actions a background change schedules for the next minute run right after it, so what a normal save sets in motion (Order Sync to other stores, for one) happens at the same time.

ArgumentTypeDescription
$runboolDefault true.
add_filter( 'adba_background_follow_ups', function ( $run ) {
	return $run;
} );

adba_background_handler

FilterSince 2.27.0 Runs in src/Modules/Background/Handlers.php.

Filters the handler of a background task: a callable that gets the ids of one batch and the task, and returns array( 'done' => int[], 'skipped' => int[], 'failed' => array<int, string> ). It runs as the user who started the task; check the capability per item. Return a handler for a bulk action of your plugin that you also added to adba_async_bulk_actions.

ArgumentTypeDescription
$handlercallable|nullBuilt-in handler, null when there is none.
$typestringObject type: post, order or comment.
$actionstringBulk action, such as trash, mark_completed or edit.
add_filter( 'adba_background_handler', function ( $handler, $type, $action ) {
	return $handler;
}, 10, 3 );

adba_background_mode

FilterSince 2.27.0 Runs in src/Modules/Background/Modes.php.

Filters how a kind of action runs for the current user: direct (the page waits for the server), browser (the screen changes at once, the request runs in the background) or server (a task for Action Scheduler). A mode the kind does not allow is ignored.

Kinds: status, trash, quickedit, bulk, bulkedit, save_posts, save_products, save_orders, transfer.

ArgumentTypeDescription
$modestringMode after the settings, the user preference and ADBA_BACKGROUND_ACTIONS.
$kindstringKind of action.
add_filter( 'adba_background_mode', function ( $mode, $kind ) {
	return $mode;
}, 10, 2 );

adba_background_save_early

FilterSince 2.28.0 Runs in src/Modules/Background/SaveAccept.php.

Filters whether a background save answers "accepted" before it is done. On by default where PHP can end the answer early (PHP-FPM, LiteSpeed). Return false when a proxy holds the answer back anyway; return true only on a server that sends output as soon as it is flushed.

ArgumentTypeDescription
$earlyboolWhether fastcgi_finish_request() or litespeed_finish_request() exists.
add_filter( 'adba_background_save_early', function ( $early ) {
	return $early;
} );

adba_background_save_limit

FilterSince 2.28.0 Runs in src/Modules/Background/SaveAccept.php.

Filters how many background saves of one user run at the same time. Every running save keeps a PHP process busy; a save beyond the limit waits in the browser until one ends.

ArgumentTypeDescription
$limitintSaves, 2 by default.
add_filter( 'adba_background_save_limit', function ( $limit ) {
	return $limit;
} );

adba_background_task_done

ActionSince 2.27.0 Runs in src/Modules/Background/Worker.php.

Fires when a background task is done. Items that failed are in $task['failed'] (id => reason).

ArgumentTypeDescription
$taskarray<string, mixed>Task: id, user, kind, object, action, ids, done, skipped, failed.
add_action( 'adba_background_task_done', function ( $task ) {
	// ...
} );

adba_background_task_failed

ActionSince 2.27.0 Runs in src/Modules/Background/Worker.php.

Fires when a background task ended without changing anything.

ArgumentTypeDescription
$taskarray<string, mixed>Task: id, user, kind, object, action, ids, done, skipped, failed (id => reason).
add_action( 'adba_background_task_failed', function ( $task ) {
	// ...
} );

adba_background_task_started

ActionSince 2.27.0 Runs in src/Modules/Background/TasksController.php.

Fires when a background task was created and its first batch was handed to Action Scheduler.

ArgumentTypeDescription
$taskarray<string, mixed>Task: id, user, kind, object, action, post_type, ids, params.
add_action( 'adba_background_task_started', function ( $task ) {
	// ...
} );

adba_bulk_server_threshold

FilterSince 2.27.0 Runs in src/Modules/Background/Modes.php.

Filters the number of selected items from which a bulk action or bulk edit with the mode Background (server) runs as a task for Action Scheduler. Smaller selections run in batches from the browser.

ArgumentTypeDescription
$thresholdintItems, 50 by default.
add_filter( 'adba_bulk_server_threshold', function ( $threshold ) {
	return $threshold;
} );

adba_save_preflight

FilterSince 2.28.0 Runs in src/Modules/Background/SaveController.php.

Filters the problems that stop a background save before it is sent. Only for rules the server must check, such as a unique value; rules the browser can check belong in the JS filter adba.save.preflight. The check has about 300 ms: a slower answer is skipped and the save goes ahead.

ArgumentTypeDescription
$errorsarray<int, array{field: string, message: string}>Problems: the name of the field and a message.
$typestringproduct, order, post or page.
$idintItem id.
$fieldsarray<string, string>Fields the page sent to check.
add_filter( 'adba_save_preflight', function ( $errors, $type, $id, $fields ) {
	return $errors;
}, 10, 4 );

Ready to connect your AI to real tools?

Start free trial