Filter
uncanny-automator
automator_display_log_size_notification_threshold_size_in_mb
Filters the maximum size in MB for the Automator log size notification threshold.
add_filter( 'automator_display_log_size_notification_threshold_size_in_mb', $callback, 10, 1 );
Description
Filters the threshold size (in MB) for displaying database log size notifications. Developers can use this to customize the size limit before a warning appears, defaulting to 1024 MB.
Usage
add_filter( 'automator_display_log_size_notification_threshold_size_in_mb', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Filters the threshold size in MB for displaying log size notifications.
*
* This function modifies the default threshold size. If the database size
* exceeds this threshold, a notification might be displayed to the user.
*
* @param int $threshold_size The current threshold size in MB. Defaults to 1024 MB.
*
* @return int The modified threshold size in MB.
*/
add_filter(
'automator_display_log_size_notification_threshold_size_in_mb',
function( $threshold_size ) {
// Example: Reduce the threshold to 512 MB to trigger notifications sooner.
$new_threshold_size = 512;
// Ensure we don't accidentally set a non-positive threshold.
if ( $new_threshold_size > 0 ) {
return $new_threshold_size;
}
// If the new threshold is invalid, return the original one.
return $threshold_size;
},
10, // Priority: Execute this filter relatively early.
1 // Accepted args: The filter callback expects only one argument.
);
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/views/table-size-exceeds.php:26
src/core/admin/class-prune-logs.php:152
slot="icon"
src="<?php echo esc_url( Utilities::automator_get_asset( 'build/img/credits-left-hundred.svg' ) ); ?>"
width="90px"
>
<p>
<?php
$threshold_size = apply_filters( 'automator_display_log_size_notification_threshold_size_in_mb', 1024 );
$threshold_size = Uncanny_AutomatorPrune_Logs::format_number_in_kb_mb_gb( $threshold_size );
?>
<?php
printf(
/* translators: %s: Size threshold (e.g., "1 GB") */
esc_html_x( 'U-bot has been working hard on your automations and noticed that the size of your logs now exceeds %s. Consider removing records you no longer need by clicking the button below to set up data management options.', 'Reviews banner', 'uncanny-automator' ),
esc_html( $threshold_size )