Changeset 45583 for trunk/src/wp-admin/includes/misc.php
- Timestamp:
- 07/01/2019 12:50:14 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/misc.php
r45580 r45583 137 137 138 138 // Split out the existing file into the preceding lines, and those that appear after the marker 139 $pre_lines = $post_lines = $existing_lines = array(); 140 $found_marker = $found_end_marker = false; 139 $pre_lines = array(); 140 $post_lines = array(); 141 $existing_lines = array(); 142 $found_marker = false; 143 $found_end_marker = false; 141 144 foreach ( $lines as $line ) { 142 145 if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) { … … 597 600 check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); 598 601 599 if ( ! $user = wp_get_current_user() ) { 602 $user = wp_get_current_user(); 603 if ( ! $user ) { 600 604 return; 601 605 } … … 965 969 if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { 966 970 foreach ( $data['wp-check-locked-posts'] as $key ) { 967 if ( ! $post_id = absint( substr( $key, 5 ) ) ) { 971 $post_id = absint( substr( $key, 5 ) ); 972 if ( ! $post_id ) { 968 973 continue; 969 974 } 970 975 971 if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) { 972 $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); 973 974 if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { 975 $send['avatar_src'] = $matches[1]; 976 $user_id = wp_check_post_lock( $post_id ); 977 if ( $user_id ) { 978 $user = get_userdata( $user_id ); 979 if ( $user && current_user_can( 'edit_post', $post_id ) ) { 980 $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); 981 982 $avatar = get_avatar( $user->ID, 18 ); 983 if ( $avatar && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { 984 $send['avatar_src'] = $matches[1]; 985 } 986 987 $checked[ $key ] = $send; 976 988 } 977 978 $checked[ $key ] = $send;979 989 } 980 990 } … … 1003 1013 $send = array(); 1004 1014 1005 if ( ! $post_id = absint( $received['post_id'] ) ) { 1015 $post_id = absint( $received['post_id'] ); 1016 if ( ! $post_id ) { 1006 1017 return $response; 1007 1018 } … … 1011 1022 } 1012 1023 1013 if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { 1024 $user_id = wp_check_post_lock( $post_id ); 1025 $user = get_userdata( $user_id ); 1026 if ( $user ) { 1014 1027 $error = array( 1015 1028 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ), 1016 1029 ); 1017 1030 1018 if ( $avatar = get_avatar( $user->ID, 64 ) ) { 1031 $avatar = get_avatar( $user->ID, 64 ); 1032 if ( $avatar ) { 1019 1033 if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { 1020 1034 $error['avatar_src'] = $matches[1]; … … 1024 1038 $send['lock_error'] = $error; 1025 1039 } else { 1026 if ( $new_lock = wp_set_post_lock( $post_id ) ) { 1040 $new_lock = wp_set_post_lock( $post_id ); 1041 if ( $new_lock ) { 1027 1042 $send['new_lock'] = implode( ':', $new_lock ); 1028 1043 } … … 1050 1065 $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); 1051 1066 1052 if ( ! $post_id = absint( $received['post_id'] ) ) { 1067 $post_id = absint( $received['post_id'] ); 1068 if ( ! $post_id ) { 1053 1069 return $response; 1054 1070 }
Note: See TracChangeset
for help on using the changeset viewer.