Ticket #15130: 15130.add-id-to-lock.3.diff
| File 15130.add-id-to-lock.3.diff, 1.8 KB (added by duck_, 2 years ago) |
|---|
-
wp-admin/includes/post.php
1201 1201 if ( !$post = get_post( $post_id ) ) 1202 1202 return false; 1203 1203 1204 $lock = get_post_meta( $post->ID, '_edit_lock', true );1205 $last = get_post_meta( $post->ID, '_edit_last', true );1204 if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) 1205 return false; 1206 1206 1207 $lock = explode( ':', $lock ); 1208 $time = $lock[0]; 1209 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1210 1207 1211 $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); 1208 1212 1209 if ( $ lock && $lock > time() - $time_window && $last!= get_current_user_id() )1210 return $ last;1213 if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) 1214 return $user; 1211 1215 return false; 1212 1216 } 1213 1217 … … 1222 1226 function wp_set_post_lock( $post_id ) { 1223 1227 if ( !$post = get_post( $post_id ) ) 1224 1228 return false; 1225 if ( 0 == get_current_user_id() )1229 if ( 0 == ($user_id = get_current_user_id()) ) 1226 1230 return false; 1227 1231 1228 1232 $now = time(); 1233 $lock = "$now:$user_id"; 1229 1234 1230 update_post_meta( $post->ID, '_edit_lock', $ now);1235 update_post_meta( $post->ID, '_edit_lock', $lock ); 1231 1236 } 1232 1237 1233 1238 /** … … 1238 1243 */ 1239 1244 function _admin_notice_post_locked() { 1240 1245 global $post; 1241 $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ); 1246 1247 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1248 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1249 $last_user = get_userdata( $user ); 1242 1250 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); 1243 1251 1244 1252 switch ($post->post_type) {
