Ticket #24572: 24572.patch
File 24572.patch, 3.0 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
1744 1744 function wp_ajax_wp_remove_post_lock() { 1745 1745 if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) 1746 1746 wp_die( 0 ); 1747 1747 1748 $post_id = (int) $_POST['post_ID']; 1748 1749 if ( ! $post = get_post( $post_id ) ) 1749 1750 wp_die( 0 ); … … 1753 1754 if ( ! current_user_can( 'edit_post', $post_id ) ) 1754 1755 wp_die( -1 ); 1755 1756 1756 $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); 1757 if ( $active_lock[1] != get_current_user_id() ) 1757 if ( ! wp_remove_post_lock( $post_id ) ) 1758 1758 wp_die( 0 ); 1759 1759 1760 $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 120 ) + 5 ) . ':' . $active_lock[1];1761 update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );1762 1760 wp_die( 1 ); 1763 1761 } 1764 1762 -
wp-admin/includes/post.php
1176 1176 } 1177 1177 1178 1178 /** 1179 * Mark the post as currently being edited by the current user 1179 * Mark the post as currently being edited by the current user. 1180 1180 * 1181 1181 * @since 2.5.0 1182 1182 * … … 1185 1185 * an array of the lock time and the user ID. 1186 1186 */ 1187 1187 function wp_set_post_lock( $post_id ) { 1188 if ( ! $post = get_post( $post_id ) )1188 if ( ! $post = get_post( $post_id ) ) 1189 1189 return false; 1190 if ( 0 == ($user_id = get_current_user_id()) ) 1190 1191 if ( 0 == ( $user_id = get_current_user_id() ) ) 1191 1192 return false; 1192 1193 1193 1194 $now = time(); 1194 1195 $lock = "$now:$user_id"; 1195 1196 1196 1197 update_post_meta( $post->ID, '_edit_lock', $lock ); 1198 1197 1199 return array( $now, $user_id ); 1198 1200 } 1199 1201 1200 1202 /** 1203 * Mark the post as no longer being edited by the current user by setting the 1204 * last lock timestamp to a time in the recent past. 1205 * 1206 * @since 3.6.0 1207 * 1208 * @param int $post_id ID of the post to being edited 1209 * @return bool|array Returns false if the post doesn't exist of there is no current user, or 1210 * an array of the last lock time and the user ID. 1211 */ 1212 function wp_remove_post_lock( $post_id ) { 1213 if ( ! $post = get_post( $post_id ) ) 1214 return false; 1215 1216 if ( 0 == ( $user_id = get_current_user_id() ) ) 1217 return false; 1218 1219 // Set post lock time to a time in recent past 1220 $then = time() - apply_filters( 'wp_check_post_lock_window', 120 ) + 5; 1221 $removal_lock = "$then:$user_id"; 1222 1223 update_post_meta( $post->ID, '_edit_lock', $removal_lock ); 1224 1225 return array( $then, $user_id ); 1226 } 1227 1228 /** 1201 1229 * Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post. 1202 1230 * 1203 1231 * @since 2.8.5 … … 1213 1241 $locked = false; 1214 1242 } 1215 1243 1216 if ( $locked && ( $sendback = wp_get_referer() ) && 1244 if ( $locked && ( $sendback = wp_get_referer() ) && 1217 1245 false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { 1218 1246 1219 1247 $sendback_text = __('Go back');