Make WordPress Core

Changeset 47785


Ignore:
Timestamp:
05/12/2020 06:30:03 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in some wp-admin files.

Props pikamander2, mukesh27, SergeyBiryukov.
Fixes #49239.

Location:
trunk/src/wp-admin
Files:
24 edited

Legend:

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

    r47771 r47785  
    4545}
    4646
    47 if ( $admin_title == $title ) {
     47if ( $admin_title === $title ) {
    4848    /* translators: Admin screen title. %s: Admin screen name. */
    4949    $admin_title = sprintf( __( '%s — WordPress' ), $title );
     
    148148do_action( 'admin_head' );
    149149
    150 if ( get_user_setting( 'mfold' ) == 'f' ) {
     150if ( get_user_setting( 'mfold' ) === 'f' ) {
    151151    $admin_body_class .= ' folded';
    152152}
  • trunk/src/wp-admin/admin.php

    r47233 r47785  
    4646     */
    4747    do_action( 'after_db_upgrade' );
    48 } elseif ( get_option( 'db_version' ) != $wp_db_version && empty( $_POST ) ) {
     48} elseif ( get_option( 'db_version' ) !== $wp_db_version && empty( $_POST ) ) {
    4949    if ( ! is_multisite() ) {
    5050        wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
  • trunk/src/wp-admin/async-upload.php

    r47198 r47785  
    4343    $id   = intval( $_REQUEST['attachment_id'] );
    4444    $post = get_post( $id );
    45     if ( 'attachment' != $post->post_type ) {
     45    if ( 'attachment' !== $post->post_type ) {
    4646        wp_die( __( 'Invalid post type.' ) );
    4747    }
  • trunk/src/wp-admin/comment.php

    r47550 r47785  
    2323}
    2424
    25 if ( 'cdc' == $action ) {
     25if ( 'cdc' === $action ) {
    2626    $action = 'delete';
    27 } elseif ( 'mac' == $action ) {
     27} elseif ( 'mac' === $action ) {
    2828    $action = 'approve';
    2929}
    3030
    3131if ( isset( $_GET['dt'] ) ) {
    32     if ( 'spam' == $_GET['dt'] ) {
     32    if ( 'spam' === $_GET['dt'] ) {
    3333        $action = 'spam';
    34     } elseif ( 'trash' == $_GET['dt'] ) {
     34    } elseif ( 'trash' === $_GET['dt'] ) {
    3535        $action = 'trash';
    3636    }
     
    7272        }
    7373
    74         if ( 'trash' == $comment->comment_approved ) {
     74        if ( 'trash' === $comment->comment_approved ) {
    7575            comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
    7676        }
     
    102102
    103103        // No need to re-approve/re-trash/re-spam a comment.
    104         if ( str_replace( '1', 'approve', $comment->comment_approved ) == $action ) {
     104        if ( str_replace( '1', 'approve', $comment->comment_approved ) === $action ) {
    105105            wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
    106106            die();
     
    110110
    111111        $formaction    = $action . 'comment';
    112         $nonce_action  = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
     112        $nonce_action  = ( 'approve' === $action ) ? 'approve-comment_' : 'delete-comment_';
    113113        $nonce_action .= $comment_id;
    114114
     
    138138        }
    139139
    140         if ( '0' != $comment->comment_approved ) { // If not unapproved.
     140        if ( '0' !== $comment->comment_approved ) { // If not unapproved.
    141141            $message = '';
    142142            switch ( $comment->comment_approved ) {
     
    272272        }
    273273
    274         if ( '' != wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
     274        if ( wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
    275275            $redir = wp_get_referer();
    276         } elseif ( '' != wp_get_original_referer() && ! $noredir ) {
     276        } elseif ( wp_get_original_referer() && ! $noredir ) {
    277277            $redir = wp_get_original_referer();
    278278        } elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
     
    349349         */
    350350        $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
     351
    351352        wp_redirect( $location );
    352 
    353         exit();
     353        exit;
    354354
    355355    default:
  • trunk/src/wp-admin/edit-comments.php

    r47219 r47785  
    2525    check_admin_referer( 'bulk-comments' );
    2626
    27     if ( 'delete_all' == $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
     27    if ( 'delete_all' === $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
    2828        $comment_status = wp_unslash( $_REQUEST['comment_status'] );
    2929        $delete_time    = wp_unslash( $_REQUEST['pagegen_timestamp'] );
     
    3232    } elseif ( isset( $_REQUEST['delete_comments'] ) ) {
    3333        $comment_ids = $_REQUEST['delete_comments'];
    34         $doaction    = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
     34        $doaction    = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
    3535    } elseif ( isset( $_REQUEST['ids'] ) ) {
    3636        $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
  • trunk/src/wp-admin/edit-form-advanced.php

    r47410 r47785  
    7777$action  = isset( $action ) ? $action : '';
    7878
    79 if ( get_option( 'page_for_posts' ) == $post_ID && empty( $post->post_content ) ) {
     79if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
    8080    add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
    8181    remove_post_type_support( $post_type, 'editor' );
     
    229229$notice     = false;
    230230$form_extra = '';
    231 if ( 'auto-draft' == $post->post_status ) {
    232     if ( 'edit' == $action ) {
     231if ( 'auto-draft' === $post->post_status ) {
     232    if ( 'edit' === $action ) {
    233233        $post->post_title = '';
    234234    }
     
    277277);
    278278
    279 if ( 'post' == $post_type ) {
     279if ( 'post' === $post_type ) {
    280280    $customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
    281281
     
    314314            '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    315315    );
    316 } elseif ( 'page' == $post_type ) {
     316} elseif ( 'page' === $post_type ) {
    317317    $about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
    318318        '<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
     
    332332            '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    333333    );
    334 } elseif ( 'attachment' == $post_type ) {
     334} elseif ( 'attachment' === $post_type ) {
    335335    get_current_screen()->add_help_tab(
    336336        array(
     
    352352}
    353353
    354 if ( 'post' == $post_type || 'page' == $post_type ) {
     354if ( 'post' === $post_type || 'page' === $post_type ) {
    355355    $inserting_media  = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
    356356    $inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. <a href="https://wordpress.org/support/article/embeds/">Learn more about embeds</a>.' ) . '</p>';
     
    365365}
    366366
    367 if ( 'post' == $post_type ) {
     367if ( 'post' === $post_type ) {
    368368    $publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
    369369    $publish_box .= '<ul><li>' .
     
    403403        )
    404404    );
    405 } elseif ( 'page' == $post_type ) {
     405} elseif ( 'page' === $post_type ) {
    406406    $page_attributes = '<p>' . __( '<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
    407407        '<p>' . __( '<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.' ) . '</p>' .
     
    472472    <?php
    473473}
    474 if ( 'draft' != get_post_status( $post ) ) {
     474if ( 'draft' !== get_post_status( $post ) ) {
    475475    wp_original_referer_field( true, 'previous' );
    476476}
     
    496496
    497497<div id="poststuff">
    498 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
     498<div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
    499499<div id="post-body-content">
    500500
     
    536536
    537537            if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
    538                 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
     538                $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
     539                    '<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
     540                    __( 'Get Shortlink' ) .
     541                    '</button>';
    539542            }
    540543        }
    541544
    542         if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    543             $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     545        if ( $post_type_object->public
     546            && ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
     547        ) {
     548            $has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
    544549            ?>
    545550    <div id="edit-slug-box" class="hide-if-no-js">
     
    609614    <span class="autosave-message">&nbsp;</span>
    610615    <?php
    611     if ( 'auto-draft' != $post->post_status ) {
     616    if ( 'auto-draft' !== $post->post_status ) {
    612617        echo '<span id="last-edit">';
    613618        $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
     
    643648<?php
    644649
    645 if ( 'page' == $post_type ) {
     650if ( 'page' === $post_type ) {
    646651    /**
    647652     * Fires before meta boxes with 'side' context are output for the 'page' post type.
     
    677682do_meta_boxes( null, 'normal', $post );
    678683
    679 if ( 'page' == $post_type ) {
     684if ( 'page' === $post_type ) {
    680685    /**
    681686     * Fires after 'normal' context meta boxes have been output for the 'page' post type.
  • trunk/src/wp-admin/edit-form-comment.php

    r47410 r47785  
    119119</fieldset>
    120120</div><!-- .misc-pub-section -->
    121    
     121
    122122<div class="misc-pub-section curtime misc-pub-curtime">
    123123<?php
  • trunk/src/wp-admin/edit-link-form.php

    r47410 r47785  
    109109<div id="poststuff">
    110110
    111 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
     111<div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
    112112<div id="post-body-content">
    113113<div id="namediv" class="stuffbox">
  • trunk/src/wp-admin/edit-tag-form.php

    r47198 r47785  
    1313
    1414// Back compat hooks.
    15 if ( 'category' == $taxonomy ) {
     15if ( 'category' === $taxonomy ) {
    1616    /**
    1717     * Fires before the Edit Category form.
     
    2323     */
    2424    do_action_deprecated( 'edit_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    25 } elseif ( 'link_category' == $taxonomy ) {
     25} elseif ( 'link_category' === $taxonomy ) {
    2626    /**
    2727     * Fires before the Edit Link Category form.
     
    178178                wp_dropdown_categories( $dropdown_args );
    179179                ?>
    180                 <?php if ( 'category' == $taxonomy ) : ?>
     180                <?php if ( 'category' === $taxonomy ) : ?>
    181181                    <p class="description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
    182182                <?php else : ?>
     
    193193        <?php
    194194        // Back compat hooks.
    195         if ( 'category' == $taxonomy ) {
     195        if ( 'category' === $taxonomy ) {
    196196            /**
    197197             * Fires after the Edit Category form fields are displayed.
     
    203203             */
    204204            do_action_deprecated( 'edit_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
    205         } elseif ( 'link_category' == $taxonomy ) {
     205        } elseif ( 'link_category' === $taxonomy ) {
    206206            /**
    207207             * Fires after the Edit Link Category form fields are displayed.
     
    240240<?php
    241241// Back compat hooks.
    242 if ( 'category' == $taxonomy ) {
     242if ( 'category' === $taxonomy ) {
    243243    /** This action is documented in wp-admin/edit-tags.php */
    244244    do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
    245 } elseif ( 'link_category' == $taxonomy ) {
     245} elseif ( 'link_category' === $taxonomy ) {
    246246    /** This action is documented in wp-admin/edit-tags.php */
    247247    do_action_deprecated( 'edit_link_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
  • trunk/src/wp-admin/edit.php

    r47550 r47785  
    333333    /* translators: %s: Number of posts. */
    334334    'updated'   => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
    335     'locked'    => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
     335    'locked'    => ( 1 === $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
    336336                    /* translators: %s: Number of posts. */
    337337                    _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ),
     
    346346    /* translators: %s: Number of pages. */
    347347    'updated'   => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ),
    348     'locked'    => ( 1 == $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) :
     348    'locked'    => ( 1 === $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) :
    349349                    /* translators: %s: Number of pages. */
    350350                    _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ),
     
    359359    /* translators: %s: Number of blocks. */
    360360    'updated'   => _n( '%s block updated.', '%s blocks updated.', $bulk_counts['updated'] ),
    361     'locked'    => ( 1 == $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.' ) :
     361    'locked'    => ( 1 === $bulk_counts['locked'] ) ? __( '1 block not updated, somebody is editing it.' ) :
    362362                    /* translators: %s: Number of blocks. */
    363363                    _n( '%s block not updated, somebody is editing it.', '%s blocks not updated, somebody is editing them.', $bulk_counts['locked'] ),
  • trunk/src/wp-admin/export.php

    r47272 r47785  
    6363    $args = array();
    6464
    65     if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) {
     65    if ( ! isset( $_GET['content'] ) || 'all' === $_GET['content'] ) {
    6666        $args['content'] = 'all';
    67     } elseif ( 'posts' == $_GET['content'] ) {
     67    } elseif ( 'posts' === $_GET['content'] ) {
    6868        $args['content'] = 'post';
    6969
     
    8484            $args['status'] = $_GET['post_status'];
    8585        }
    86     } elseif ( 'pages' == $_GET['content'] ) {
     86    } elseif ( 'pages' === $_GET['content'] ) {
    8787        $args['content'] = 'page';
    8888
     
    9999            $args['status'] = $_GET['page_status'];
    100100        }
    101     } elseif ( 'attachment' == $_GET['content'] ) {
     101    } elseif ( 'attachment' === $_GET['content'] ) {
    102102        $args['content'] = 'attachment';
    103103
     
    145145        WHERE post_type = %s AND post_status != 'auto-draft'
    146146        ORDER BY post_date DESC
    147     ",
     147            ",
    148148            $post_type
    149149        )
     
    151151
    152152    $month_count = count( $months );
    153     if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
     153    if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) {
    154154        return;
    155155    }
    156156
    157157    foreach ( $months as $date ) {
    158         if ( 0 == $date->year ) {
     158        if ( 0 === (int) $date->year ) {
    159159            continue;
    160160        }
  • trunk/src/wp-admin/import.php

    r47198 r47785  
    4343if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) {
    4444    $importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id'];
    45     if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops.
     45    if ( $importer_id !== $_GET['invalid'] ) { // Prevent redirect loops.
    4646        wp_redirect( admin_url( 'admin.php?import=' . $importer_id ) );
    4747        exit;
  • trunk/src/wp-admin/includes/upgrade.php

    r47597 r47785  
    23472347    $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
    23482348
    2349     if ( $wpdb->get_var( $query ) == $table_name ) {
     2349    if ( $wpdb->get_var( $query ) === $table_name ) {
    23502350        return true;
    23512351    }
     
    23552355
    23562356    // We cannot directly tell that whether this succeeded!
    2357     if ( $wpdb->get_var( $query ) == $table_name ) {
     2357    if ( $wpdb->get_var( $query ) === $table_name ) {
    23582358        return true;
    23592359    }
     2360
    23602361    return false;
    23612362}
     
    23742375function drop_index( $table, $index ) {
    23752376    global $wpdb;
     2377
    23762378    $wpdb->hide_errors();
     2379
    23772380    $wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" );
     2381
    23782382    // Now we need to take out all the extra ones we may have created.
    23792383    for ( $i = 0; $i < 25; $i++ ) {
    23802384        $wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" );
    23812385    }
     2386
    23822387    $wpdb->show_errors();
     2388
    23832389    return true;
    23842390}
     
    23972403function add_clean_index( $table, $index ) {
    23982404    global $wpdb;
     2405
    23992406    drop_index( $table, $index );
    24002407    $wpdb->query( "ALTER TABLE `$table` ADD INDEX ( `$index` )" );
     2408
    24012409    return true;
    24022410}
     
    24162424function maybe_add_column( $table_name, $column_name, $create_ddl ) {
    24172425    global $wpdb;
     2426
    24182427    foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    2419         if ( $column == $column_name ) {
     2428        if ( $column === $column_name ) {
    24202429            return true;
    24212430        }
     
    24272436    // We cannot directly tell that whether this succeeded!
    24282437    foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    2429         if ( $column == $column_name ) {
     2438        if ( $column === $column_name ) {
    24302439            return true;
    24312440        }
    24322441    }
     2442
    24332443    return false;
    24342444}
  • trunk/src/wp-admin/install-helper.php

    r47219 r47785  
    5252    function maybe_create_table( $table_name, $create_ddl ) {
    5353        global $wpdb;
     54
    5455        foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
    55             if ( $table == $table_name ) {
    56                 return true;
    57             }
    58         }
     56            if ( $table === $table_name ) {
     57                return true;
     58            }
     59        }
     60
    5961        // Didn't find it, so try to create it.
    6062        $wpdb->query( $create_ddl );
     
    6264        // We cannot directly tell that whether this succeeded!
    6365        foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
    64             if ( $table == $table_name ) {
    65                 return true;
    66             }
    67         }
     66            if ( $table === $table_name ) {
     67                return true;
     68            }
     69        }
     70
    6871        return false;
    6972    }
     
    8588    function maybe_add_column( $table_name, $column_name, $create_ddl ) {
    8689        global $wpdb;
     90
    8791        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    88 
    89             if ( $column == $column_name ) {
     92            if ( $column === $column_name ) {
    9093                return true;
    9194            }
     
    97100        // We cannot directly tell that whether this succeeded!
    98101        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    99             if ( $column == $column_name ) {
    100                 return true;
    101             }
    102         }
     102            if ( $column === $column_name ) {
     103                return true;
     104            }
     105        }
     106
    103107        return false;
    104108    }
     
    119123function maybe_drop_column( $table_name, $column_name, $drop_ddl ) {
    120124    global $wpdb;
     125
    121126    foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    122         if ( $column == $column_name ) {
     127        if ( $column === $column_name ) {
    123128
    124129            // Found it, so try to drop it.
     
    127132            // We cannot directly tell that whether this succeeded!
    128133            foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    129                 if ( $column == $column_name ) {
     134                if ( $column === $column_name ) {
    130135                    return false;
    131136                }
     
    133138        }
    134139    }
     140
    135141    // Else didn't find it.
    136142    return true;
     
    168174function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null ) {
    169175    global $wpdb;
     176
    170177    $diffs   = 0;
    171178    $results = $wpdb->get_results( "DESC $table_name" );
     
    173180    foreach ( $results as $row ) {
    174181
    175         if ( $row->Field == $col_name ) {
     182        if ( $row->Field === $col_name ) {
    176183
    177184            // Got our column, check the params.
    178             if ( ( null != $col_type ) && ( $row->Type != $col_type ) ) {
    179                 ++$diffs;
    180             }
    181             if ( ( null != $is_null ) && ( $row->Null != $is_null ) ) {
    182                 ++$diffs;
    183             }
    184             if ( ( null != $key ) && ( $row->Key != $key ) ) {
    185                 ++$diffs;
    186             }
    187             if ( ( null != $default ) && ( $row->Default != $default ) ) {
    188                 ++$diffs;
    189             }
    190             if ( ( null != $extra ) && ( $row->Extra != $extra ) ) {
    191                 ++$diffs;
    192             }
     185            if ( ( null !== $col_type ) && ( $row->Type !== $col_type ) ) {
     186                ++$diffs;
     187            }
     188            if ( ( null !== $is_null ) && ( $row->Null !== $is_null ) ) {
     189                ++$diffs;
     190            }
     191            if ( ( null !== $key ) && ( $row->Key !== $key ) ) {
     192                ++$diffs;
     193            }
     194            if ( ( null !== $default ) && ( $row->Default !== $default ) ) {
     195                ++$diffs;
     196            }
     197            if ( ( null !== $extra ) && ( $row->Extra !== $extra ) ) {
     198                ++$diffs;
     199            }
     200
    193201            if ( $diffs > 0 ) {
    194202                return false;
    195203            }
     204
    196205            return true;
    197206        } // End if found our column.
    198207    }
     208
    199209    return false;
    200210}
  • trunk/src/wp-admin/install.php

    r47746 r47785  
    9292    global $wpdb;
    9393
    94     $sql        = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) );
    95     $user_table = ( $wpdb->get_var( $sql ) != null );
     94    $user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null );
    9695
    9796    // Ensure that sites appear in search engines by default.
     
    370369            display_setup_form( __( 'Please provide a valid username.' ) );
    371370            $error = true;
    372         } elseif ( sanitize_user( $user_name, true ) != $user_name ) {
     371        } elseif ( sanitize_user( $user_name, true ) !== $user_name ) {
    373372            display_setup_form( __( 'The username you provided has invalid characters.' ) );
    374373            $error = true;
    375         } elseif ( $admin_password != $admin_password_check ) {
     374        } elseif ( $admin_password !== $admin_password_check ) {
    376375            // TODO: Poka-yoke.
    377376            display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
  • trunk/src/wp-admin/link-manager.php

    r47198 r47785  
    2424    $bulklinks   = (array) $_REQUEST['linkcheck'];
    2525
    26     if ( 'delete' == $doaction ) {
     26    if ( 'delete' === $doaction ) {
    2727        foreach ( $bulklinks as $link_id ) {
    2828            $link_id = (int) $link_id;
  • trunk/src/wp-admin/link-parse-opml.php

    r47397 r47785  
    2828 * @global array $feeds
    2929 *
    30  * @param resource $parser XML Parser resource.
    31  * @param string $tagName XML element name.
    32  * @param array $attrs XML element attributes.
     30 * @param resource $parser   XML Parser resource.
     31 * @param string   $tag_name XML element name.
     32 * @param array    $attrs    XML element attributes.
    3333 */
    34 function startElement( $parser, $tagName, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
     34function startElement( $parser, $tag_name, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    3535    global $names, $urls, $targets, $descriptions, $feeds;
    3636
    37     if ( 'OUTLINE' === $tagName ) {
     37    if ( 'OUTLINE' === $tag_name ) {
    3838        $name = '';
    3939        if ( isset( $attrs['TEXT'] ) ) {
     
    6666 * @access private
    6767 *
    68  * @param resource $parser XML Parser resource.
    69  * @param string $tagName XML tag name.
     68 * @param resource $parser   XML Parser resource.
     69 * @param string   $tag_name XML tag name.
    7070 */
    71 function endElement( $parser, $tagName ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
     71function endElement( $parser, $tag_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    7272    // Nothing to do.
    7373}
  • trunk/src/wp-admin/link.php

    r47198 r47785  
    3636
    3737        // For each link id (in $linkcheck[]) change category to selected value.
    38         if ( count( $linkcheck ) == 0 ) {
     38        if ( count( $linkcheck ) === 0 ) {
    3939            wp_redirect( $this_file );
    4040            exit;
     
    5757
    5858        // For each link id (in $linkcheck[]) change category to selected value.
    59         if ( count( $linkcheck ) == 0 ) {
     59        if ( count( $linkcheck ) === 0 ) {
    6060            wp_redirect( $this_file );
    6161            exit;
  • trunk/src/wp-admin/load-styles.php

    r47550 r47785  
    3838}
    3939
    40 $rtl            = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] );
     40$rtl            = ( isset( $_GET['dir'] ) && 'rtl' === $_GET['dir'] );
    4141$expires_offset = 31536000; // 1 year.
    4242$out            = '';
  • trunk/src/wp-admin/media-upload.php

    r47218 r47785  
    3030
    3131// IDs should be integers.
    32 $ID      = isset( $ID ) ? (int) $ID : 0;
     32$ID      = isset( $ID ) ? (int) $ID : 0; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
    3333$post_id = isset( $post_id ) ? (int) $post_id : 0;
    3434
    3535// Require an ID for the edit screen.
    36 if ( isset( $action ) && 'edit' == $action && ! $ID ) {
     36if ( isset( $action ) && 'edit' === $action && ! $ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
    3737    wp_die(
    3838        '<h1>' . __( 'Something went wrong.' ) . '</h1>' .
     
    8282
    8383// Let the action code decide how to handle the request.
    84 if ( 'type' == $tab || 'type_url' == $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) {
     84if ( 'type' === $tab || 'type_url' === $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) {
    8585    /**
    8686     * Fires inside specific upload-type views in the legacy (pre-3.5.0)
  • trunk/src/wp-admin/media.php

    r47218 r47785  
    3030            $referer  = wp_get_original_referer();
    3131            if ( $referer ) {
    32                 if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) == $attachment_id ) ) {
     32                if ( false !== strpos( $referer, 'upload.php' ) || ( url_to_postid( $referer ) === $attachment_id ) ) {
    3333                    $location = $referer;
    3434                }
     
    7070            wp_die( __( 'You attempted to edit an item that isn&#8217;t an attachment. Please go back and try again.' ) );
    7171        }
    72         if ( 'trash' == $att->post_status ) {
     72        if ( 'trash' === $att->post_status ) {
    7373            wp_die( __( 'You can&#8217;t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.' ) );
    7474        }
  • trunk/src/wp-admin/menu-header.php

    r47122 r47785  
    8989        }
    9090
    91         if ( ( $parent_file && $item[2] == $parent_file ) || ( empty( $typenow ) && $self == $item[2] ) ) {
     91        if ( ( $parent_file && $item[2] === $parent_file ) || ( empty( $typenow ) && $self === $item[2] ) ) {
    9292            if ( ! empty( $submenu_items ) ) {
    9393                $class[] = 'wp-has-current-submenu wp-menu-open';
     
    155155            $menu_file     = $submenu_items[0][2];
    156156            $pos           = strpos( $menu_file, '?' );
     157
    157158            if ( false !== $pos ) {
    158159                $menu_file = substr( $menu_file, 0, $pos );
    159160            }
    160             if ( ! empty( $menu_hook ) || ( ( 'index.php' != $submenu_items[0][2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
     161
     162            if ( ! empty( $menu_hook )
     163                || ( ( 'index.php' !== $submenu_items[0][2] )
     164                    && file_exists( WP_PLUGIN_DIR . "/$menu_file" )
     165                    && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
     166            ) {
    161167                $admin_is_parent = true;
    162168                echo "<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>$title</div></a>";
     
    168174            $menu_file = $item[2];
    169175            $pos       = strpos( $menu_file, '?' );
     176
    170177            if ( false !== $pos ) {
    171178                $menu_file = substr( $menu_file, 0, $pos );
    172179            }
    173             if ( ! empty( $menu_hook ) || ( ( 'index.php' != $item[2] ) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) ) ) {
     180
     181            if ( ! empty( $menu_hook )
     182                || ( ( 'index.php' !== $item[2] )
     183                    && file_exists( WP_PLUGIN_DIR . "/$menu_file" )
     184                    && ! file_exists( ABSPATH . "/wp-admin/$menu_file" ) )
     185            ) {
    174186                $admin_is_parent = true;
    175187                echo "\n\t<a href='admin.php?page={$item[2]}'$class $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style>$img</div><div class='wp-menu-name'>{$item[0]}</div></a>";
     
    193205                $class           = array();
    194206                $aria_attributes = '';
     207
    195208                if ( $first ) {
    196209                    $class[] = 'wp-first-item';
     
    199212
    200213                $menu_file = $item[2];
    201 
    202                 $pos = strpos( $menu_file, '?' );
     214                $pos       = strpos( $menu_file, '?' );
     215
    203216                if ( false !== $pos ) {
    204217                    $menu_file = substr( $menu_file, 0, $pos );
     
    209222
    210223                if ( isset( $submenu_file ) ) {
    211                     if ( $submenu_file == $sub_item[2] ) {
     224                    if ( $submenu_file === $sub_item[2] ) {
    212225                        $class[]          = 'current';
    213226                        $aria_attributes .= ' aria-current="page"';
     
    216229                    // This allows plugin pages with the same hook to exist under different parents.
    217230                } elseif (
    218                     ( ! isset( $plugin_page ) && $self == $sub_item[2] ) ||
    219                     ( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists( $menu_file ) === false ) )
     231                    ( ! isset( $plugin_page ) && $self === $sub_item[2] )
     232                    || ( isset( $plugin_page ) && $plugin_page === $sub_item[2]
     233                        && ( $item[2] === $self_type || $item[2] === $self || file_exists( $menu_file ) === false ) )
    220234                ) {
    221235                    $class[]          = 'current';
     
    238252                $title = wptexturize( $sub_item[0] );
    239253
    240                 if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) {
     254                if ( ! empty( $menu_hook )
     255                    || ( ( 'index.php' !== $sub_item[2] )
     256                        && file_exists( WP_PLUGIN_DIR . "/$sub_file" )
     257                        && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) )
     258                ) {
    241259                    // If admin.php is the current page or if the parent exists as a file in the plugins or admin directory.
    242260                    if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) ) {
  • trunk/src/wp-admin/ms-delete-site.php

    r47218 r47785  
    1818}
    1919
    20 if ( isset( $_GET['h'] ) && '' != $_GET['h'] && false != get_option( 'delete_blog_hash' ) ) {
     20if ( isset( $_GET['h'] ) && '' !== $_GET['h'] && false !== get_option( 'delete_blog_hash' ) ) {
    2121    if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) {
    2222        wpmu_delete_blog( get_current_blog_id() );
     
    4343echo '<h1>' . esc_html( $title ) . '</h1>';
    4444
    45 if ( isset( $_POST['action'] ) && 'deleteblog' == $_POST['action'] && isset( $_POST['confirmdelete'] ) && '1' == $_POST['confirmdelete'] ) {
     45if ( isset( $_POST['action'] ) && 'deleteblog' === $_POST['action'] && isset( $_POST['confirmdelete'] ) && '1' === $_POST['confirmdelete'] ) {
    4646    check_admin_referer( 'delete-blog' );
    4747
  • trunk/src/wp-admin/my-sites.php

    r47550 r47785  
    2323
    2424$updated = false;
    25 if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
     25if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) {
    2626    check_admin_referer( 'update-my-sites' );
    2727
     
    108108     */
    109109    $settings_html = apply_filters( 'myblogs_options', '', 'global' );
    110     if ( '' != $settings_html ) {
     110
     111    if ( $settings_html ) {
    111112        echo '<h3>' . __( 'Global Settings' ) . '</h3>';
    112113        echo $settings_html;
    113114    }
     115
    114116    reset( $blogs );
    115117
     
    135137         */
    136138        $actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog );
     139
    137140        echo "<p class='my-sites-actions'>" . $actions . '</p>';
    138141
    139142        /** This filter is documented in wp-admin/my-sites.php */
    140143        echo apply_filters( 'myblogs_options', '', $user_blog );
     144
    141145        echo '</li>';
    142146
Note: See TracChangeset for help on using the changeset viewer.