wp_revisions_to_keep
Determine how many revisions to retain for a given post.
Description
(int) wp_revisions_to_keep( (WP_Post) $post );
By default, an infinite number of revisions are kept.
The constant WP_POST_REVISIONS can be set in wp-config to specify the limit of revisions to keep.
Returns (int)
The number of revisions to keep.
Parameters (1)
- 0. $post (WP_Post)
- The post object.
Usage
if ( !function_exists( 'wp_revisions_to_keep' ) ) { require_once ABSPATH . WPINC . '/revision.php'; } // The post object. $post = null; // NOTICE! Understand what this does before running. $result = wp_revisions_to_keep($post);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/revision.php
- function wp_revisions_to_keep( $post ) {
- $num = WP_POST_REVISIONS;
- if ( true === $num )
- $num = -1;
- else
- $num = intval( $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.
- */
- return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
- }