wp_ajax_wp_remove_post_lock() - WordPress 函数参考中文文档

返回介绍

wp_ajax_wp_remove_post_lock()

发布于 2017-09-11 字数2021 浏览 1023 评论 0

wp_ajax_wp_remove_post_lock()

Ajax handler for removing a post lock.


描述


源代码

File: wp-admin/includes/ajax-actions.php

function wp_ajax_wp_remove_post_lock() {
	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
		wp_die( 0 );
	$post_id = (int) $_POST['post_ID'];
	if ( ! $post = get_post( $post_id ) )
		wp_die( 0 );

	check_ajax_referer( 'update-post_' . $post_id );

	if ( ! current_user_can( 'edit_post', $post_id ) )
		wp_die( -1 );

	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
	if ( $active_lock[1] != get_current_user_id() )
		wp_die( 0 );

	/**
	 * Filters the post lock window duration.
	 *
	 * @since 3.3.0
	 *
	 * @param int $interval The interval in seconds the post lock duration
	 *                      should last, plus 5 seconds. Default 150.
	 */
	$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1];
	update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
	wp_die( 1 );
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-admin/includes/ajax-actions.php:
    wp_check_post_lock_window
  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/pluggable.php:
    check_ajax_referer()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/user.php:
    get_current_user_id()
  • wp-includes/post.php:
    update_post_meta()
  • wp-includes/post.php:
    get_post()
  • Show 3 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!