Make WordPress Core


Ignore:
Timestamp:
07/01/2019 12:50:14 PM (5 years ago)
Author:
pento
Message:

Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-admin.

See #47632.

File:
1 edited

Legend:

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

    r45580 r45583  
    137137
    138138    // 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;
    141144    foreach ( $lines as $line ) {
    142145        if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
     
    597600        check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
    598601
    599         if ( ! $user = wp_get_current_user() ) {
     602        $user = wp_get_current_user();
     603        if ( ! $user ) {
    600604            return;
    601605        }
     
    965969    if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
    966970        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 ) {
    968973                continue;
    969974            }
    970975
    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;
    976988                }
    977 
    978                 $checked[ $key ] = $send;
    979989            }
    980990        }
     
    10031013        $send     = array();
    10041014
    1005         if ( ! $post_id = absint( $received['post_id'] ) ) {
     1015        $post_id = absint( $received['post_id'] );
     1016        if ( ! $post_id ) {
    10061017            return $response;
    10071018        }
     
    10111022        }
    10121023
    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 ) {
    10141027            $error = array(
    10151028                'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
    10161029            );
    10171030
    1018             if ( $avatar = get_avatar( $user->ID, 64 ) ) {
     1031            $avatar = get_avatar( $user->ID, 64 );
     1032            if ( $avatar ) {
    10191033                if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
    10201034                    $error['avatar_src'] = $matches[1];
     
    10241038            $send['lock_error'] = $error;
    10251039        } else {
    1026             if ( $new_lock = wp_set_post_lock( $post_id ) ) {
     1040            $new_lock = wp_set_post_lock( $post_id );
     1041            if ( $new_lock ) {
    10271042                $send['new_lock'] = implode( ':', $new_lock );
    10281043            }
     
    10501065        $response['wp-refresh-post-nonces'] = array( 'check' => 1 );
    10511066
    1052         if ( ! $post_id = absint( $received['post_id'] ) ) {
     1067        $post_id = absint( $received['post_id'] );
     1068        if ( ! $post_id ) {
    10531069            return $response;
    10541070        }
Note: See TracChangeset for help on using the changeset viewer.