返回介绍

wp_list_post_revisions()

发布于 2017-09-11 12:22:14 字数 2750 浏览 997 评论 0 收藏 0

wp_list_post_revisions( int|WP_Post $post_id,  string $type = 'all' )

Display list of a post’s revisions.


description

Can output either a UL with edit links or a TABLE with diff interface, and restore action links.


参数

$post_id

(int|WP_Post) (Optional) Post ID or WP_Post object. Default is global $post.

$type

(string) (Optional) 'all' (default), 'revision' or 'autosave'

Default value: 'all'


源代码

File: wp-includes/post-template.php

function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
	if ( ! $post = get_post( $post_id ) )
		return;

	// $args array with (parent, format, right, left, type) deprecated since 3.6
	if ( is_array( $type ) ) {
		$type = ! empty( $type['type'] ) ? $type['type']  : $type;
		_deprecated_argument( __FUNCTION__, '3.6.0' );
	}

	if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
		return;

	$rows = '';
	foreach ( $revisions as $revision ) {
		if ( ! current_user_can( 'read_post', $revision->ID ) )
			continue;

		$is_autosave = wp_is_post_autosave( $revision );
		if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) )
			continue;

		$rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
	}

	echo "<div class='hide-if-js'><p>" . __( 'JavaScript must be enabled to use this feature.' ) . "</p></div>\n";

	echo "<ul class='post-revisions hide-if-no-js'>\n";
	echo $rows;
	echo "</ul>";
}

更新日志

Versiondescription
2.6.0Introduced.

相关函数

Uses

  • wp-includes/capabilities.php: current_user_can()
  • wp-includes/l10n.php: __()
  • wp-includes/functions.php: _deprecated_argument()
  • wp-includes/post-template.php: wp_post_revision_title_expanded()
  • wp-includes/post.php: get_post()
  • wp-includes/revision.php: wp_get_post_revisions()
  • wp-includes/revision.php: wp_is_post_autosave()
  • Show 2 more uses Hide more uses

Used By

  • wp-admin/includes/meta-boxes.php: post_revisions_meta_box()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文