Make WordPress Core

Changeset 40423


Ignore:
Timestamp:
04/13/2017 11:01:20 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Improve the docs for wp_check_post_lock() and wp_set_post_lock().

See #39888.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r39710 r40423  
    14491449 * @since 2.5.0
    14501450 *
    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.
    14531454 */
    14541455function wp_check_post_lock( $post_id ) {
    1455     if ( !$post = get_post( $post_id ) )
     1456    if ( ! $post = get_post( $post_id ) ) {
    14561457        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 ) ) {
    14591461        return false;
     1462    }
    14601463
    14611464    $lock = explode( ':', $lock );
     
    14661469    $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
    14671470
    1468     if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
     1471    if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
    14691472        return $user;
     1473    }
     1474
    14701475    return false;
    14711476}
     
    14761481 * @since 2.5.0
    14771482 *
    1478  * @param int $post_id ID of the post to being edited
    1479  * @return bool|array Returns false if the post doesn't exist of there is no current user, or
    1480  *  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.
    14811486 */
    14821487function wp_set_post_lock( $post_id ) {
    1483     if ( !$post = get_post( $post_id ) )
     1488    if ( ! $post = get_post( $post_id ) ) {
    14841489        return false;
    1485     if ( 0 == ($user_id = get_current_user_id()) )
     1490    }
     1491
     1492    if ( 0 == ( $user_id = get_current_user_id() ) ) {
    14861493        return false;
     1494    }
    14871495
    14881496    $now = time();
     
    14901498
    14911499    update_post_meta( $post->ID, '_edit_lock', $lock );
     1500
    14921501    return array( $now, $user_id );
    14931502}
Note: See TracChangeset for help on using the changeset viewer.