Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use Yoda conditions where appropriate.

See #49222.

File:
1 edited

Legend:

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

    r47202 r47219  
    636636    $img = '<span class="wp-media-buttons-icon"></span> ';
    637637
    638     $id_attribute = $instance === 1 ? ' id="insert-media-button"' : '';
     638    $id_attribute = 1 === $instance ? ' id="insert-media-button"' : '';
    639639
    640640    printf(
     
    768768                $image_alt = wp_unslash( $attachment['image_alt'] );
    769769
    770                 if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) {
     770                if ( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) !== $image_alt ) {
    771771                    $image_alt = wp_strip_all_tags( $image_alt, true );
    772772
     
    948948    }
    949949
    950     if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'type_url' ) {
     950    if ( isset( $_GET['tab'] ) && 'type_url' === $_GET['tab'] ) {
    951951        $type = 'image';
    952952
     
    10041004            return $id;
    10051005            // If attachment id was requested, return it early.
    1006         } elseif ( $return === 'id' ) {
     1006        } elseif ( 'id' === $return ) {
    10071007            return $id;
    10081008        }
     
    10131013    // Finally, check to make sure the file has been saved, then return the HTML.
    10141014    if ( ! empty( $src ) ) {
    1015         if ( $return === 'src' ) {
     1015        if ( 'src' === $return ) {
    10161016            return $src;
    10171017        }
     
    12121212    $url = '';
    12131213
    1214     if ( $url_type == 'file' ) {
     1214    if ( 'file' === $url_type ) {
    12151215        $url = $file;
    1216     } elseif ( $url_type == 'post' ) {
     1216    } elseif ( 'post' === $url_type ) {
    12171217        $url = $link;
    12181218    }
     
    13251325        $size  = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
    13261326        $alt   = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
    1327         $rel   = ( strpos( $url, 'attachment_id' ) || $url === get_attachment_link( $attachment_id ) );
     1327        $rel   = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
    13281328
    13291329        return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
     
    14921492        $post = get_post( $post_id );
    14931493
    1494         if ( $post && $post->post_type == 'attachment' ) {
     1494        if ( $post && 'attachment' === $post->post_type ) {
    14951495            $attachments = array( $post->ID => $post );
    14961496        } else {
     
    15141514    $output = '';
    15151515    foreach ( (array) $attachments as $id => $attachment ) {
    1516         if ( $attachment->post_status == 'trash' ) {
     1516        if ( 'trash' === $attachment->post_status ) {
    15171517            continue;
    15181518        }
     
    17361736
    17371737    foreach ( $form_fields as $id => $field ) {
    1738         if ( $id[0] == '_' ) {
     1738        if ( '_' === $id[0] ) {
    17391739            continue;
    17401740        }
     
    17481748        $name  = "attachments[$attachment_id][$id]";
    17491749
    1750         if ( $field['input'] == 'hidden' ) {
     1750        if ( 'hidden' === $field['input'] ) {
    17511751            $hidden_fields[ $name ] = $field['value'];
    17521752            continue;
     
    17621762        if ( ! empty( $field[ $field['input'] ] ) ) {
    17631763            $item .= $field[ $field['input'] ];
    1764         } elseif ( $field['input'] == 'textarea' ) {
     1764        } elseif ( 'textarea' === $field['input'] ) {
    17651765            if ( 'post_content' == $id && user_can_richedit() ) {
    17661766                // Sanitize_post() skips the post_content when user_can_richedit.
     
    19201920
    19211921    foreach ( $form_fields as $id => $field ) {
    1922         if ( $id[0] == '_' ) {
     1922        if ( '_' === $id[0] ) {
    19231923            continue;
    19241924        }
     
    19381938        }
    19391939
    1940         if ( $field['input'] == 'hidden' ) {
     1940        if ( 'hidden' === $field['input'] ) {
    19411941            $hidden_fields[ $name ] = $field['value'];
    19421942            continue;
     
    19551955        if ( ! empty( $field[ $field['input'] ] ) ) {
    19561956            $item .= $field[ $field['input'] ];
    1957         } elseif ( $field['input'] == 'textarea' ) {
     1957        } elseif ( 'textarea' === $field['input'] ) {
    19581958            if ( 'post_content' == $id && user_can_richedit() ) {
    19591959                // sanitize_post() skips the post_content when user_can_richedit.
     
    27172717            list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    27182718        }
    2719         if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
     2719        if ( empty( $_GET['post_mime_type'] ) || 'all' === $_GET['post_mime_type'] ) {
    27202720            $class = ' class="current"';
    27212721        } else {
     
    28012801
    28022802            foreach ( $arc_result as $arc_row ) {
    2803                 if ( $arc_row->yyear == 0 ) {
     2803                if ( 0 == $arc_row->yyear ) {
    28042804                    continue;
    28052805                }
     
    29272927            <th scope="row" class="label"><p><label for="align">' . __( 'Alignment' ) . '</label></p></th>
    29282928            <td class="field">
    2929                 <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'none' ? ' checked="checked"' : '' ) . ' />
     2929                <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'none' === $default_align ? ' checked="checked"' : '' ) . ' />
    29302930                <label for="align-none" class="align image-align-none-label">' . __( 'None' ) . '</label>
    2931                 <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'left' ? ' checked="checked"' : '' ) . ' />
     2931                <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'left' === $default_align ? ' checked="checked"' : '' ) . ' />
    29322932                <label for="align-left" class="align image-align-left-label">' . __( 'Left' ) . '</label>
    2933                 <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'center' ? ' checked="checked"' : '' ) . ' />
     2933                <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'center' === $default_align ? ' checked="checked"' : '' ) . ' />
    29342934                <label for="align-center" class="align image-align-center-label">' . __( 'Center' ) . '</label>
    2935                 <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( $default_align == 'right' ? ' checked="checked"' : '' ) . ' />
     2935                <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ( 'right' === $default_align ? ' checked="checked"' : '' ) . ' />
    29362936                <label for="align-right" class="align image-align-right-label">' . __( 'Right' ) . '</label>
    29372937            </td>
     
    32733273            echo esc_html( strtoupper( $matches[1] ) );
    32743274            list( $mime_type ) = explode( '/', $post->post_mime_type );
    3275             if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
    3276                 if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
     3275            if ( 'image' !== $mime_type && ! empty( $meta['mime_type'] ) ) {
     3276                if ( "$mime_type/" . strtolower( $matches[1] ) !== $meta['mime_type'] ) {
    32773277                    echo ' (' . $meta['mime_type'] . ')';
    32783278                }
     
    35363536        $created_timestamp = wp_get_media_creation_timestamp( $data );
    35373537
    3538         if ( $created_timestamp !== false ) {
     3538        if ( false !== $created_timestamp ) {
    35393539            $metadata['created_timestamp'] = $created_timestamp;
    35403540        }
Note: See TracChangeset for help on using the changeset viewer.