Filter
uncanny-automator
automator_loop_logs_runs_per_page
Filters the number of automator logs runs displayed per page on the frontend.
add_filter( 'automator_loop_logs_runs_per_page', $callback, 10, 1 );
Description
Filters the number of log runs displayed per page in the Automator logs. Developers can use this hook to customize the pagination for the loop logs endpoint, affecting how many runs appear before pagination is applied. The default value is defined by `self::DEFAULT_RUNS_PER_PAGE`.
Usage
add_filter( 'automator_loop_logs_runs_per_page', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Customizes the number of log runs displayed per page in the Automator logs.
*
* This function hooks into the 'automator_loop_logs_runs_per_page' filter
* to allow developers to change the default number of log runs displayed
* on the loop logs administration page.
*
* @param int $default_runs_per_page The default number of runs per page.
* @return int The modified number of runs per page.
*/
add_filter( 'automator_loop_logs_runs_per_page', function( $default_runs_per_page ) {
// Example: Increase the number of runs per page to 50 if the default is less than 50.
// In a real-world scenario, you might retrieve this value from a plugin setting.
$custom_runs_per_page = 50;
if ( $default_runs_per_page < $custom_runs_per_page ) {
return $custom_runs_per_page;
}
// If the default is already higher or equal, keep it.
return $default_runs_per_page;
}, 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/services/rest/endpoint/log-endpoint/resources/loop-logs-resources.php:73
src/core/admin/class-admin-menu.php:1416
public function __construct(
Loop_Logs_Queries $loop_logs_queries,
Formatters_Utils $utils,
Automator_Factory $automator_factory
) {
$this->utils = $utils;
$this->loop_logs_queries = $loop_logs_queries;
$this->automator_factory = $automator_factory;
$this->runs_per_page = (int) apply_filters( 'automator_loop_logs_runs_per_page', self::DEFAULT_RUNS_PER_PAGE );
}