Add user id to lock. Props duck_. see #15130
git-svn-id: https://develop.svn.wordpress.org/trunk@16901 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6dc2d07bc4
commit
04e1d8553a
@ -1201,13 +1201,17 @@ function wp_check_post_lock( $post_id ) {
|
||||
if ( !$post = get_post( $post_id ) )
|
||||
return false;
|
||||
|
||||
$lock = get_post_meta( $post->ID, '_edit_lock', true );
|
||||
$last = get_post_meta( $post->ID, '_edit_last', true );
|
||||
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 ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
|
||||
return $last;
|
||||
if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
|
||||
return $user;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1222,12 +1226,13 @@ function wp_check_post_lock( $post_id ) {
|
||||
function wp_set_post_lock( $post_id ) {
|
||||
if ( !$post = get_post( $post_id ) )
|
||||
return false;
|
||||
if ( 0 == get_current_user_id() )
|
||||
if ( 0 == ($user_id = get_current_user_id()) )
|
||||
return false;
|
||||
|
||||
$now = time();
|
||||
$lock = "$now:$user_id";
|
||||
|
||||
update_post_meta( $post->ID, '_edit_lock', $now );
|
||||
update_post_meta( $post->ID, '_edit_lock', $lock );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1238,7 +1243,10 @@ function wp_set_post_lock( $post_id ) {
|
||||
*/
|
||||
function _admin_notice_post_locked() {
|
||||
global $post;
|
||||
$last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
|
||||
|
||||
$lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
|
||||
$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
|
||||
$last_user = get_userdata( $user );
|
||||
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
|
||||
|
||||
switch ($post->post_type) {
|
||||
|
Loading…
Reference in New Issue
Block a user