#51550 closed enhancement (fixed)
Revisions: Add a post type-specific filter to `wp_revisions_to_keep()`
Reported by: | dlh | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Revisions | Keywords: | has-patch has-unit-tests needs-dev-note commit |
Focuses: | Cc: |
Description
The attached patch proposes a post type-specific filter for wp_revisions_to_keep()
to complement the wp_revisions_to_keep
filter.
wp_revisions_to_keep
is a perfectly capable filter; the one proposed here offers just some added developer convenience for simpler cases. For example:
add_filter( 'wp_post_revisions_to_keep', fn () => 500 );
add_filter( 'wp_page_revisions_to_keep', '__return_zero' );
Attachments (2)
Change History (9)
#3
@
4 years ago
- Keywords has-unit-tests added
Thanks for the review, @adamsilverstein!
51550.2.diff updates the docs of the new filter to note its relationship to the existing filter, and it adds tests for the behavior of each filter.
This ticket was mentioned in PR #1272 on WordPress/wordpress-develop by adamsilverstein.
3 years ago
#4
Trac ticket: https://core.trac.wordpress.org/ticket/51550
Note: See
TracTickets for help on using
tickets.
Thanks for the patch @dlh - looks good. The only think I would add is a note on the doc block indicating that the filter also overrides the existing
wp_revisions_to_keep
filter when used.In addition, some basic unit tests to confirm both of these filters works as expected would be a good addition.