Advertisements

wp_check_post_lock

Definition:
function wp_check_post_lock( $post_id ) {}

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

Parameters

  • int $post_id: ID of the post to check for editing

Return values

returns:False: not locked or locked by current user. Int: user ID of user with lock.

Defined filters

  • wp_check_post_lock_window
    apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 )

Source code

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 );



	$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );



	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )

		return $user;

	return false;

}

3471

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: