Filter
uncanny-automator
automator_extra_options_max_items
Filters the maximum number of items allowed in automator extra options, controlling the quantity of selectable items.
add_filter( 'automator_extra_options_max_items', $callback, 10, 1 );
Description
Filters the maximum number of items allowed in dynamic dropdowns and selects. Developers can use this to adjust the default limit of 200, preventing performance issues with excessively long lists. Ensure any custom limits are reasonable to maintain a good user experience.
Usage
add_filter( 'automator_extra_options_max_items', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Filter the maximum number of items allowed in an options list.
*
* This example increases the default limit to 500 items.
*
* @param int $max_items The current maximum number of items.
* @return int The new maximum number of items.
*/
add_filter( 'automator_extra_options_max_items', function( $max_items ) {
// Increase the limit to 500 items.
return 500;
}, 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/lib/class-automator-functions.php:1141
protected function strip_oversized_options( array $data ) {
$limit = (int) apply_filters( 'automator_extra_options_max_items', 200 );
if ( isset( $data['options'] ) && is_array( $data['options'] ) ) {
foreach ( $data['options'] as $i => $field ) {
if ( isset( $field['options'] ) && count( $field['options'] ) > $limit ) {
$data['options'][ $i ]['options'] = array_slice( $field['options'], 0, $limit );
}
}
}
if ( isset( $data['options_group'] ) && is_array( $data['options_group'] ) ) {
foreach ( $data['options_group'] as $group_key => $group_fields ) {
foreach ( $group_fields as $i => $field ) {
if ( isset( $field['options'] ) && count( $field['options'] ) > $limit ) {
$data['options_group'][ $group_key ][ $i ]['options'] = array_slice( $field['options'], 0, $limit );
}
}
}
}
return $data;
}