wp-includes/revision.php:812Determines how many revisions to retain for a given post.
$postWP_Postint2 hooks fire while wp_revisions_to_keep() runs, in this order:
Filters the number of revisions to save for the given post.
Filters the number of revisions to save for the given post by its post type.
function wp_revisions_to_keep( $post ) { $num = WP_POST_REVISIONS; if ( true === $num ) { $num = -1; } else { $num = (int) $num; } if ( ! post_type_supports( $post->post_type, 'revisions' ) ) { $num = 0; } /** * Filters the number of revisions to save for the given post. * * Overrides the value of WP_POST_REVISIONS. * * @since 3.6.0 * * @param int $num Number of revisions to store. * @param WP_Post $post Post object. */ $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. * * Possible hook names include: * * - `wp_post_revisions_to_keep` * - `wp_page_revisions_to_keep` * * @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;}Introduced in 3.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/revision.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.