Handles removing a post lock via AJAX.
Source
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'];
$post = get_post( $post_id );
if ( ! $post ) {
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 ( get_current_user_id() !== $active_lock[1] ) {
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 );
}
Hooks
- apply_filters( ‘wp_check_post_lock_window’,
int $interval ) Filters the post lock window duration.
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.