Changeset 40423
- Timestamp:
- 04/13/2017 11:01:20 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r39710 r40423 1449 1449 * @since 2.5.0 1450 1450 * 1451 * @param int $post_id ID of the post to check for editing 1452 * @return integer False: not locked or locked by current user. Int: user ID of user with lock. 1451 * @param int $post_id ID of the post to check for editing. 1452 * @return int|false ID of the user with lock. False if the post does not exist, post is not locked, 1453 * or post is locked by current user. 1453 1454 */ 1454 1455 function wp_check_post_lock( $post_id ) { 1455 if ( ! $post = get_post( $post_id ) )1456 if ( ! $post = get_post( $post_id ) ) { 1456 1457 return false; 1457 1458 if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) 1458 } 1459 1460 if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { 1459 1461 return false; 1462 } 1460 1463 1461 1464 $lock = explode( ':', $lock ); … … 1466 1469 $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); 1467 1470 1468 if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) 1471 if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) { 1469 1472 return $user; 1473 } 1474 1470 1475 return false; 1471 1476 } … … 1476 1481 * @since 2.5.0 1477 1482 * 1478 * @param int $post_id ID of the post to being edited1479 * @return bool|array Returns false if the post doesn't exist of there is no current user, or1480 * an array of the lock time and the user ID.1483 * @param int $post_id ID of the post being edited. 1484 * @return array|false Array of the lock time and user ID. False if the post does not exist or there 1485 * is no current user. 1481 1486 */ 1482 1487 function wp_set_post_lock( $post_id ) { 1483 if ( ! $post = get_post( $post_id ) )1488 if ( ! $post = get_post( $post_id ) ) { 1484 1489 return false; 1485 if ( 0 == ($user_id = get_current_user_id()) ) 1490 } 1491 1492 if ( 0 == ( $user_id = get_current_user_id() ) ) { 1486 1493 return false; 1494 } 1487 1495 1488 1496 $now = time(); … … 1490 1498 1491 1499 update_post_meta( $post->ID, '_edit_lock', $lock ); 1500 1492 1501 return array( $now, $user_id ); 1493 1502 }
Note: See TracChangeset
for help on using the changeset viewer.