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_upsadba_background_handleradba_background_modeadba_background_save_earlyadba_background_save_limitadba_background_task_doneadba_background_task_failedadba_background_task_startedadba_bulk_server_thresholdadba_save_preflight
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.
| Argument | Type | Description |
|---|---|---|
$run | bool | Default 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.
| Argument | Type | Description |
|---|---|---|
$handler | callable|null | Built-in handler, null when there is none. |
$type | string | Object type: post, order or comment. |
$action | string | Bulk 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.
| Argument | Type | Description |
|---|---|---|
$mode | string | Mode after the settings, the user preference and ADBA_BACKGROUND_ACTIONS. |
$kind | string | Kind 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.
| Argument | Type | Description |
|---|---|---|
$early | bool | Whether 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.
| Argument | Type | Description |
|---|---|---|
$limit | int | Saves, 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).
| Argument | Type | Description |
|---|---|---|
$task | array<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.
| Argument | Type | Description |
|---|---|---|
$task | array<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.
| Argument | Type | Description |
|---|---|---|
$task | array<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.
| Argument | Type | Description |
|---|---|---|
$threshold | int | Items, 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.
| Argument | Type | Description |
|---|---|---|
$errors | array<int, array{field: string, message: string}> | Problems: the name of the field and a message. |
$type | string | product, order, post or page. |
$id | int | Item id. |
$fields | array<string, string> | Fields the page sent to check. |
add_filter( 'adba_save_preflight', function ( $errors, $type, $id, $fields ) {
return $errors;
}, 10, 4 );