Ticket #15130: 15130.add-id-to-lock.2.diff
| File 15130.add-id-to-lock.2.diff, 1.6 KB (added by duck_, 3 years ago) |
|---|
-
wp-admin/includes/post.php
1145 1145 if ( !$post = get_post( $post_id ) ) 1146 1146 return false; 1147 1147 1148 $lock = get_post_meta( $post->ID, '_edit_lock', true );1149 $last = get_post_meta( $post->ID, '_edit_last', true );1148 if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) 1149 return false; 1150 1150 1151 list( $user, $time ) = explode( ':', $lock ); 1151 1152 $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); 1152 1153 1153 if ( $ lock && $lock > time() - $time_window && $last!= get_current_user_id() )1154 return $ last;1154 if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) 1155 return $user; 1155 1156 return false; 1156 1157 } 1157 1158 … … 1166 1167 function wp_set_post_lock( $post_id ) { 1167 1168 if ( !$post = get_post( $post_id ) ) 1168 1169 return false; 1169 if ( 0 == get_current_user_id() )1170 if ( 0 == ($user_id = get_current_user_id()) ) 1170 1171 return false; 1171 1172 1172 1173 $now = time(); 1174 $lock = "$user_id:$now"; 1173 1175 1174 update_post_meta( $post->ID, '_edit_lock', $ now);1176 update_post_meta( $post->ID, '_edit_lock', $lock ); 1175 1177 } 1176 1178 1177 1179 /** … … 1182 1184 */ 1183 1185 function _admin_notice_post_locked() { 1184 1186 global $post; 1185 $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ); 1187 list( $user, $time ) = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1188 $last_user = get_userdata( $user ); 1186 1189 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); 1187 1190 1188 1191 switch ($post->post_type) {