Changeset 7103 for trunk/wp-admin/includes/post.php
- Timestamp:
- 02/29/2008 09:51:36 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/post.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r6983 r7103 19 19 $now = time(); 20 20 $then = strtotime($post->post_date_gmt . ' +0000'); 21 // Keep autosave_interval in sync with autosave-js.php. 22 $delta = apply_filters( 'autosave_interval', 120 ) / 2; 21 $delta = get_option( 'autosave_interval' ) / 2; 23 22 if ( ($now - $then) < $delta ) 24 23 return $post_ID; … … 620 619 } 621 620 621 // false: not locked or locked by current user 622 // int: user ID of user with lock 623 function wp_check_post_lock( $post_id ) { 624 global $current_user; 625 626 if ( !$post = get_post( $post_id ) ) 627 return false; 628 629 $lock = get_post_meta( $post->ID, '_edit_lock', true ); 630 $last = get_post_meta( $post->ID, '_edit_last', true ); 631 632 $time_window = apply_filters( 'wp_check_post_lock_window', get_option( 'autosave_interval' ) * 2 ); 633 634 if ( $lock && $lock > time() - $time_window && $last != $current_user->ID ) 635 return $last; 636 return false; 637 } 638 639 function wp_set_post_lock( $post_id ) { 640 global $current_user; 641 if ( !$post = get_post( $post_id ) ) 642 return false; 643 if ( !$current_user || !$current_user->ID ) 644 return false; 645 646 $now = time(); 647 648 if ( !add_post_meta( $post->ID, '_edit_lock', $now, true ) ) 649 update_post_meta( $post->ID, '_edit_lock', $now ); 650 if ( !add_post_meta( $post->ID, '_edit_last', $current_user->ID, true ) ) 651 update_post_meta( $post->ID, '_edit_last', $current_user->ID ); 652 } 653 622 654 ?>
Note: See TracChangeset
for help on using the changeset viewer.