Revisions: add a new filter for revisions to keep by post type.
Add a new `wp_{$post_type}_revisions_to_keep` filter that makes it convenient to filter the number of revisions created for a specific post type. Overrides both the value of WP_POST_REVISIONS and the `wp_revisions_to_keep` filter. Props dlh. Fixes #51550. Built from https://develop.svn.wordpress.org/trunk@50949 git-svn-id: http://core.svn.wordpress.org/trunk@50558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b2e311b85d
commit
5ddc1fb946
|
@ -564,7 +564,24 @@ function wp_revisions_to_keep( $post ) {
|
||||||
* @param int $num Number of revisions to store.
|
* @param int $num Number of revisions to store.
|
||||||
* @param WP_Post $post Post object.
|
* @param WP_Post $post Post object.
|
||||||
*/
|
*/
|
||||||
return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
|
$num = apply_filters( 'wp_revisions_to_keep', $num, $post );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the number of revisions to save for the given post by its post type.
|
||||||
|
*
|
||||||
|
* Overrides both the value of WP_POST_REVISIONS and the {@see 'wp_revisions_to_keep'} filter.
|
||||||
|
*
|
||||||
|
* The dynamic portion of the hook name, `$post->post_type`, refers to
|
||||||
|
* the post type slug.
|
||||||
|
*
|
||||||
|
* @since 5.8.0
|
||||||
|
*
|
||||||
|
* @param int $num Number of revisions to store.
|
||||||
|
* @param WP_Post $post Post object.
|
||||||
|
*/
|
||||||
|
$num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post );
|
||||||
|
|
||||||
|
return (int) $num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-alpha-50948';
|
$wp_version = '5.8-alpha-50949';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue