| @@ -16,22 +16,20 @@ | ||
| 16 | 16 | * @see wp_check_post_lock() |
| 17 | 17 | * |
| 18 | 18 | * @since 2.6.0 bbPress (r6340) |
| 19 | 19 | * |
| 20 | - * @param int $post_id ID of the post to check for editing. | |
| 20 | + * @param int $post_id ID of the post to check for editing | |
| 21 | 21 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
| 22 | 22 | */ |
| 23 | 23 | function bbp_check_post_lock( $post_id = 0 ) { |
| 24 | 24 | |
| 25 | 25 | // Bail if no post |
| 26 | - $post = get_post( $post_id ); | |
| 27 | - if ( empty( $post ) ) { | |
| 26 | + if ( ! $post = get_post( $post_id ) ) { | |
| 28 | 27 | return false; |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | // Bail if no lock |
| 32 | - $lock = get_post_meta( $post->ID, '_edit_lock', true ); | |
| 33 | - if ( empty( $lock ) ) { | |
| 31 | + if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { | |
| 34 | 32 | return false; |
| 35 | 33 | } |
| 36 | 34 | |
| 37 | 35 | // Get lock |
| @@ -44,9 +42,9 @@ | ||
| 44 | 42 | // Filter editing window duration |
| 45 | 43 | $time_window = apply_filters( 'bbp_check_post_lock_window', 3 * MINUTE_IN_SECONDS ); |
| 46 | 44 | |
| 47 | 45 | // Return user who is or last edited |
| 48 | - if ( ! empty( $time ) && ( $time > ( time() - $time_window ) ) && ( bbp_get_current_user_id() ) !== $user ) { | |
| 46 | + if ( ! empty( $time ) && ( $time > ( time() - $time_window ) ) && ( $user !== bbp_get_current_user_id() ) ) { | |
| 49 | 47 | return (int) $user; |
| 50 | 48 | } |
| 51 | 49 | |
| 52 | 50 | return false; |
| @@ -52,27 +50,25 @@ | ||
| 52 | 50 | return false; |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | 53 | /** |
| 56 | - * Mark the post as currently being edited by the current user. | |
| 54 | + * Mark the post as currently being edited by the current user | |
| 57 | 55 | * |
| 58 | 56 | * @since 2.6.0 bbPress (r6340) |
| 59 | 57 | * |
| 60 | - * @param int $post_id ID of the post to being edited. | |
| 58 | + * @param int $post_id ID of the post to being edited | |
| 61 | 59 | * @return bool|array Returns false if the post doesn't exist of there is no current user, or |
| 62 | - * an array of the lock time and the user ID. | |
| 60 | + * an array of the lock time and the user ID. | |
| 63 | 61 | */ |
| 64 | 62 | function bbp_set_post_lock( $post_id = 0 ) { |
| 65 | 63 | |
| 66 | 64 | // Bail if no post |
| 67 | - $post = get_post( $post_id ); | |
| 68 | - if ( empty( $post ) ) { | |
| 65 | + if ( ! $post = get_post( $post_id ) ) { | |
| 69 | 66 | return false; |
| 70 | 67 | } |
| 71 | 68 | |
| 72 | 69 | // Bail if no user |
| 73 | - $user_id = get_current_user_id(); | |
| 74 | - if ( empty( $user_id ) ) { | |
| 70 | + if ( 0 == ( $user_id = get_current_user_id() ) ) { | |
| 75 | 71 | return false; |
| 76 | 72 | } |
| 77 | 73 | |
| 78 | 74 | // Get time & lock value |