Filter: bricks/global_history/keep_latest
Since Bricks 2.5, bricks/global_history/keep_latest changes how many of an item’s latest Global Data Revisions entries are protected from automatic cleanup.
Parameter and return value
Section titled “Parameter and return value”$latest(int): The number of latest entries to keep per resource/item pair. Default:20.- Return the desired count. Bricks casts it to an integer and uses a minimum of
1. Returning0orfalsedoes not disable retention or request unlimited history.
Example usage
Section titled “Example usage”Keep at least the latest 40 entries for each recorded item:
add_filter( 'bricks/global_history/keep_latest', function( $latest ) { return 40;} );Add the filter in a plugin or child theme that loads during WP-Cron requests.
How it combines with the age limit
Section titled “How it combines with the age limit”Bricks also keeps every entry within the period set by bricks/global_history/keep_days, which defaults to 90 days. Cleanup deletes an entry only when it is both outside the protected latest count and older than that period.
With the example above, an item can keep more than 40 entries if they are recent. It can also keep 40 entries older than 90 days when those are its latest entries. The count is a minimum retained per item, not a storage cap.
The filter is read during the scheduled daily cleanup. Changing it does not prune records immediately or recover records already removed. WP-Cron must run for scheduled cleanup to take place.
Was this helpful?
A quick vote and short notes help us improve these docs faster.
Leave a note for us
Please do not include passwords, license keys, or personal data. We store submitted notes to improve the docs.
Thanks for sharing feedback. We're using it to improve these docs.