确定为给定帖子保留的修订数量。

原型

wp_revisions_to_keep( WP_Post $post )

描述

默认情况下,保留无限次修订。

参数

$post (WP_Post) (Required) 帖子对象。

返回值

(int)  要保留的修订数量。

源文件

路径:wp-includes/revision.php

<?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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_revisions_to_keep/