Make WordPress Core


Ignore:
Timestamp:
06/07/2024 12:27:59 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/includes/post.php.

Follow-up to [2718], [7103], [7338], [8857], [9036], [9103], [11807], [11908], [15315], [16901], [17078], [23725], [23735], [44141], [45583].

Props aristath, poena, afercia, SergeyBiryukov.
See #60700.

File:
1 edited

Legend:

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

    r58212 r58360  
    7373        }
    7474
    75         if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] )
     75        if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] !== $post_data['user_ID'] )
    7676                && ! current_user_can( $ptype->cap->edit_others_posts ) ) {
    7777
    … …  
    166166
    167167        foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) {
    168                 if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) {
     168                if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] !== $post_data[ $timeunit ] ) {
    169169                        $post_data['edit_date'] = '1';
    170170                        break;
    … …  
    376376                        }
    377377
    378                         if ( $meta->post_id != $post_id ) {
     378                        if ( (int) $meta->post_id !== $post_id ) {
    379379                                continue;
    380380                        }
    … …  
    403403                        }
    404404
    405                         if ( $meta->post_id != $post_id ) {
     405                        if ( (int) $meta->post_id !== $post_id ) {
    406406                                continue;
    407407                        }
    … …  
    517517        }
    518518
    519         if ( -1 == $post_data['_status'] ) {
     519        if ( '-1' === $post_data['_status'] ) {
    520520                $post_data['post_status'] = null;
    521521                unset( $post_data['post_status'] );
    … …  
    551551
    552552        foreach ( $reset as $field ) {
    553                 if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) {
     553                if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || '-1' === $post_data[ $field ] ) ) {
    554554                        unset( $post_data[ $field ] );
    555555                }
    … …  
    14051405 */
    14061406function postbox_classes( $box_id, $screen_id ) {
    1407         if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
     1407        if ( isset( $_GET['edit'] ) && $_GET['edit'] === $box_id ) {
    14081408                $classes = array( '' );
    14091409        } elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) {
    … …  
    15781578                // Encourage a pretty permalink setting.
    15791579                if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' )
    1580                         && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID )
     1580                        && ! ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID )
    15811581                ) {
    15821582                        $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __( 'Change Permalink Structure' ) . "</a></span>\n";
    … …  
    17141714        $lock = explode( ':', $lock );
    17151715        $time = $lock[0];
    1716         $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
     1716        $user = isset( $lock[1] ) ? (int) $lock[1] : (int) get_post_meta( $post->ID, '_edit_last', true );
    17171717
    17181718        if ( ! get_userdata( $user ) ) {
    … …  
    17231723        $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
    17241724
    1725         if ( $time && $time > time() - $time_window && get_current_user_id() != $user ) {
     1725        if ( $time && $time > time() - $time_window && get_current_user_id() !== $user ) {
    17261726                return $user;
    17271727        }
    … …  
    17531753        $user_id = get_current_user_id();
    17541754
    1755         if ( 0 == $user_id ) {
     1755        if ( 0 === $user_id ) {
    17561756                return false;
    17571757        }
    … …  
    18301830                $query_args = array();
    18311831                if ( get_post_type_object( $post->post_type )->public ) {
    1832                         if ( 'publish' === $post->post_status || $user->ID != $post->post_author ) {
     1832                        if ( 'publish' === $post->post_status || $user->ID !== (int) $post->post_author ) {
    18331833                                // Latest content is in autosave.
    18341834                                $nonce                       = wp_create_nonce( 'post_preview_' . $post->ID );
    … …  
    20822082        $is_autosave = false;
    20832083
    2084         if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author
     2084        if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
    20852085                && ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status )
    20862086        ) {
    … …  
    21572157        }
    21582158
    2159         if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author
     2159        if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
    21602160                && ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status )
    21612161        ) {
    … …  
    24092409                        $meta_boxes = (array) $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ];
    24102410                        foreach ( $meta_boxes as $meta_box ) {
    2411                                 if ( false == $meta_box || ! $meta_box['title'] ) {
     2411                                if ( false === $meta_box || ! $meta_box['title'] ) {
    24122412                                        continue;
    24132413                                }
Note: See TracChangeset for help on using the changeset viewer.