返回介绍

wp_check_post_lock()

发布于 2017-09-11 11:41:56 字数 2912 浏览 923 评论 0 收藏 0

wp_check_post_lock( int $post_id )

Check to see if the post is currently being edited by another user.


description


参数

$post_id

(int) (Required) ID of the post to check for editing.


返回值

(int|false) ID of the user with lock. False if the post does not exist, post is not locked, the user with lock does not exist, or the post is locked by current user.


源代码

File: wp-admin/includes/post.php

function wp_check_post_lock( $post_id ) {
	if ( ! $post = get_post( $post_id ) ) {
		return false;
	}

	if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) {
		return false;
	}

	$lock = explode( ':', $lock );
	$time = $lock[0];
	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );

	if ( ! get_userdata( $user ) ) {
		return false;
	}

	/** This filter is documented in wp-admin/includes/ajax-actions.php */
	$time_window = apply_filters( 'wp_check_post_lock_window', 150 );

	if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
		return $user;
	}

	return false;
}

更新日志

Versiondescription
2.5.0Introduced.

相关函数

Uses

  • wp-admin/includes/ajax-actions.php: wp_check_post_lock_window
  • wp-includes/pluggable.php: get_userdata()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/user.php: get_current_user_id()
  • wp-includes/post.php: get_post_meta()
  • wp-includes/post.php: get_post()
  • Show 1 more use Hide more uses

Used By

  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::column_title()
  • wp-admin/includes/revision.php: wp_print_revision_templates()
  • wp-admin/includes/misc.php: wp_check_locked_posts()
  • wp-admin/includes/misc.php: wp_refresh_post_lock()
  • wp-admin/includes/post.php: _admin_notice_post_locked()
  • wp-admin/includes/post.php: post_preview()
  • wp-admin/includes/post.php: wp_autosave()
  • wp-admin/includes/post.php: bulk_edit_posts()
  • wp-admin/includes/ajax-actions.php: wp_ajax_inline_save()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::single_row()
  • Show 5 more used by Hide more used by

User Contributed Notes

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

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

发布评论

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