WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (11 months 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/meta-boxes.php

    r47550 r47808  
    4747<div id="save-action">
    4848    <?php
    49     if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) {
     49    if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) {
    5050        $private_style = '';
    51         if ( 'private' == $post->post_status ) {
     51        if ( 'private' === $post->post_status ) {
    5252            $private_style = 'style="display:none"';
    5353        }
     
    5555<input <?php echo $private_style; ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Draft' ); ?>" class="button" />
    5656<span class="spinner"></span>
    57 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
     57<?php } elseif ( 'pending' === $post->post_status && $can_publish ) { ?>
    5858<input type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save as Pending' ); ?>" class="button" />
    5959<span class="spinner"></span>
     
    6464        <?php
    6565        $preview_link = esc_url( get_preview_post_link( $post ) );
    66         if ( 'publish' == $post->post_status ) {
     66        if ( 'publish' === $post->post_status ) {
    6767            $preview_button_text = __( 'Preview Changes' );
    6868        } else {
     
    121121</span>
    122122    <?php
    123     if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) {
     123    if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) {
    124124        $private_style = '';
    125         if ( 'private' == $post->post_status ) {
     125        if ( 'private' === $post->post_status ) {
    126126            $private_style = 'style="display:none"';
    127127        }
     
    130130
    131131<div id="post-status-select" class="hide-if-js">
    132 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' == $post->post_status ) ? 'draft' : $post->post_status ); ?>" />
     132<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" />
    133133<label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label>
    134134<select name="post_status" id="post_status">
    135         <?php if ( 'publish' == $post->post_status ) : ?>
     135        <?php if ( 'publish' === $post->post_status ) : ?>
    136136<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option>
    137 <?php elseif ( 'private' == $post->post_status ) : ?>
     137<?php elseif ( 'private' === $post->post_status ) : ?>
    138138<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option>
    139 <?php elseif ( 'future' == $post->post_status ) : ?>
     139<?php elseif ( 'future' === $post->post_status ) : ?>
    140140<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e( 'Scheduled' ); ?></option>
    141141<?php endif; ?>
    142142<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e( 'Pending Review' ); ?></option>
    143         <?php if ( 'auto-draft' == $post->post_status ) : ?>
     143        <?php if ( 'auto-draft' === $post->post_status ) : ?>
    144144<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
    145145<?php else : ?>
     
    211211
    212212    if ( 0 != $post->ID ) {
    213         if ( 'future' == $post->post_status ) { // Scheduled for publishing at a future date.
     213        if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date.
    214214            /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
    215215            $stamp = __( 'Scheduled for: %s' );
    216         } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // Already published.
     216        } elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published.
    217217            /* translators: Post date information. %s: Date on which the post was published. */
    218218            $stamp = __( 'Published on: %s' );
    219         } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
     219        } elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
    220220            $stamp = __( 'Publish <b>immediately</b>' );
    221221        } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified.
     
    709709    $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
    710710        esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
    711     if ( '' != $post->pinged ) {
     711
     712    if ( '' !== $post->pinged ) {
    712713        $pings          = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
    713714        $already_pinged = explode( "\n", trim( $post->pinged ) );
     
    10031004        do_action( 'page_attributes_misc_attributes', $post );
    10041005        ?>
    1005         <?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
     1006        <?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
    10061007<p class="post-attributes-help-text"><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p>
    10071008            <?php
     
    10561057<div id="delete-action">
    10571058    <?php
    1058     if ( ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] && current_user_can( 'manage_links' ) ) {
     1059    if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) {
    10591060        printf(
    10601061            '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
     
    11831184    $rels     = preg_split( '/\s+/', $link_rel );
    11841185
    1185     if ( '' != $value && in_array( $value, $rels, true ) ) {
     1186    if ( '' !== $value && in_array( $value, $rels, true ) ) {
    11861187        echo ' checked="checked"';
    11871188    }
    11881189
    1189     if ( '' == $value ) {
    1190         if ( 'family' == $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
     1190    if ( '' === $value ) {
     1191        if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
    11911192            echo ' checked="checked"';
    11921193        }
    1193         if ( 'friendship' == $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
     1194        if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
    11941195            echo ' checked="checked"';
    11951196        }
    1196         if ( 'geographical' == $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
     1197        if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
    11971198            echo ' checked="checked"';
    11981199        }
    1199         if ( 'identity' == $class && in_array( 'me', $rels, true ) ) {
     1200        if ( 'identity' === $class && in_array( 'me', $rels, true ) ) {
    12001201            echo ' checked="checked"';
    12011202        }
     
    14221423
    14231424    $publish_callback_args = array( '__back_compat_meta_box' => true );
    1424     if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) {
     1425    if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
    14251426        $revisions = wp_get_post_revisions( $post->ID );
    14261427
     
    14371438    }
    14381439
    1439     if ( 'attachment' == $post_type ) {
     1440    if ( 'attachment' === $post_type ) {
    14401441        wp_enqueue_script( 'image-edit' );
    14411442        wp_enqueue_style( 'imgareaselect' );
     
    15441545    }
    15451546
    1546     if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
     1547    if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    15471548        add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    15481549    }
Note: See TracChangeset for help on using the changeset viewer.