wp_ajax_wp_remove_post_lock
Ajax handler for removing a post lock.
Description
wp_ajax_wp_remove_post_lock();
Usage
if ( !function_exists( 'wp_ajax_wp_remove_post_lock' ) ) { require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; } // NOTICE! Understand what this does before running. $result = wp_ajax_wp_remove_post_lock();
Defined (1)
The function is defined in the following location(s).
- /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 );
- }