wp_ajax_wp_remove_post_lock

Ajax handler for removing a post lock.

Description

wp_ajax_wp_remove_post_lock(); 

Usage

  1. if ( !function_exists( 'wp_ajax_wp_remove_post_lock' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_wp_remove_post_lock(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_wp_remove_post_lock() { 
  2. if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) 
  3. wp_die( 0 ); 
  4. $post_id = (int) $_POST['post_ID']; 
  5. if ( ! $post = get_post( $post_id ) ) 
  6. wp_die( 0 ); 
  7.  
  8. check_ajax_referer( 'update-post_' . $post_id ); 
  9.  
  10. if ( ! current_user_can( 'edit_post', $post_id ) ) 
  11. wp_die( -1 ); 
  12.  
  13. $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); 
  14. if ( $active_lock[1] != get_current_user_id() ) 
  15. wp_die( 0 ); 
  16.  
  17. /** 
  18. * Filters the post lock window duration. 
  19. * @since 3.3.0 
  20. * @param int $interval The interval in seconds the post lock duration 
  21. * should last, plus 5 seconds. Default 150. 
  22. */ 
  23. $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; 
  24. update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); 
  25. wp_die( 1 );