Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

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

    r47771 r47808  
    681681    $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url( 'media-upload.php' ) );
    682682
    683     if ( $type && 'media' != $type ) {
     683    if ( $type && 'media' !== $type ) {
    684684        $upload_iframe_src = add_query_arg( 'type', $type, $upload_iframe_src );
    685685    }
     
    866866        }
    867867
    868         if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
     868        if ( isset( $_POST['media_type'] ) && 'image' !== $_POST['media_type'] ) {
    869869            $title = esc_html( wp_unslash( $_POST['title'] ) );
    870870            if ( empty( $title ) ) {
     
    881881            if ( $ext ) {
    882882                $ext_type = wp_ext2type( $ext );
    883                 if ( 'audio' == $ext_type || 'video' == $ext_type ) {
     883                if ( 'audio' === $ext_type || 'video' === $ext_type ) {
    884884                    $type = $ext_type;
    885885                }
     
    11601160
    11611161        // Is this size selectable?
    1162         $enabled = ( $downsize[3] || 'full' == $size );
     1162        $enabled = ( $downsize[3] || 'full' === $size );
    11631163        $css_id  = "image-size-{$size}-{$post->ID}";
    11641164
     
    11701170                $check = '';
    11711171            }
    1172         } elseif ( ! $check && $enabled && 'thumbnail' != $size ) {
     1172        } elseif ( ! $check && $enabled && 'thumbnail' !== $size ) {
    11731173            /*
    11741174             * If $check is not enabled, default to the first available size
     
    13031303 */
    13041304function image_attachment_fields_to_save( $post, $attachment ) {
    1305     if ( substr( $post['post_mime_type'], 0, 5 ) == 'image' ) {
     1305    if ( 'image' === substr( $post['post_mime_type'], 0, 5 ) ) {
    13061306        if ( strlen( trim( $post['post_title'] ) ) == 0 ) {
    13071307            $attachment_url                           = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid'];
     
    13271327    $post = get_post( $attachment_id );
    13281328
    1329     if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
     1329    if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
    13301330        $url   = $attachment['url'];
    13311331        $align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
     
    14381438
    14391439    // This was formerly in image_attachment_fields_to_edit().
    1440     if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
     1440    if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
    14411441        $alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
    14421442
     
    16111611    $display_title = $parsed_args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . '</span></div>' : '';
    16121612
    1613     $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
     1613    $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' === $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' === $redir_tab ) );
    16141614    $order   = '';
    16151615
    16161616    foreach ( $form_fields as $key => $val ) {
    1617         if ( 'menu_order' == $key ) {
     1617        if ( 'menu_order' === $key ) {
    16181618            if ( $gallery ) {
    16191619                $order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' /></div>";
     
    17261726    }
    17271727
    1728     if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
    1729         && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
     1728    if ( 'image' === $type && $calling_post_id
     1729        && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
     1730        && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' )
     1731        && get_post_thumbnail_id( $calling_post_id ) != $attachment_id
     1732    ) {
    17301733
    17311734        $calling_post             = get_post( $calling_post_id );
     
    17701773            $item .= $field[ $field['input'] ];
    17711774        } elseif ( 'textarea' === $field['input'] ) {
    1772             if ( 'post_content' == $id && user_can_richedit() ) {
     1775            if ( 'post_content' === $id && user_can_richedit() ) {
    17731776                // Sanitize_post() skips the post_content when user_can_richedit.
    17741777                $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
     
    19631966            $item .= $field[ $field['input'] ];
    19641967        } elseif ( 'textarea' === $field['input'] ) {
    1965             if ( 'post_content' == $id && user_can_richedit() ) {
     1968            if ( 'post_content' === $id && user_can_richedit() ) {
    19661969                // sanitize_post() skips the post_content when user_can_richedit.
    19671970                $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
     
    23842387        var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';
    23852388
    2386         if ( '' == f.src.value || '' == t.width )
     2389        if ( '' === f.src.value || '' === t.width )
    23872390            return false;
    23882391
     
    28912894    }
    28922895
    2893     if ( 'image' == $default_view ) {
     2896    if ( 'image' === $default_view ) {
    28942897        $view        = 'image-only';
    28952898        $table_class = '';
Note: See TracChangeset for help on using the changeset viewer.