Make WordPress Core

Changeset 58998


Ignore:
Timestamp:
09/08/2024 07:16:07 PM (5 months ago)
Author:
SergeyBiryukov
Message:

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

Follow-up to [2703], [3297], [3513], [6697], [14189], [25177], [27390], [38378], [38698], [39588], [48356], [48664].

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

File:
1 edited

Legend:

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

    r58099 r58998  
    4848        case 'remove_user':
    4949            // In multisite the user must be a super admin to remove themselves.
    50             if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
     50            if ( isset( $args[0] ) && $user_id === (int) $args[0] && ! is_super_admin( $user_id ) ) {
    5151                $caps[] = 'do_not_allow';
    5252            } else {
     
    6161        case 'edit_users':
    6262            // Allow user to edit themselves.
    63             if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id == $args[0] ) {
     63            if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id === (int) $args[0] ) {
    6464                break;
    6565            }
     
    104104            }
    105105
    106             if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
     106            if ( (int) get_option( 'page_for_posts' ) === $post->ID
     107                || (int) get_option( 'page_on_front' ) === $post->ID
     108            ) {
    107109                $caps[] = 'manage_options';
    108110                break;
     
    138140
    139141            // If the post author is set and the user is the author...
    140             if ( $post->post_author && $user_id == $post->post_author ) {
     142            if ( $post->post_author && $user_id === (int) $post->post_author ) {
    141143                // If the post is published or scheduled...
    142144                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
     
    241243
    242244            // If the post author is set and the user is the author...
    243             if ( $post->post_author && $user_id == $post->post_author ) {
     245            if ( $post->post_author && $user_id === (int) $post->post_author ) {
    244246                // If the post is published or scheduled...
    245247                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
     
    363365            }
    364366
    365             if ( $post->post_author && $user_id == $post->post_author ) {
     367            if ( $post->post_author && $user_id === (int) $post->post_author ) {
    366368                $caps[] = $post_type->cap->read;
    367369            } elseif ( $status_obj->private ) {
     
    731733
    732734            if ( 'delete_term' === $cap
    733                 && ( get_option( 'default_' . $term->taxonomy ) == $term->term_id
    734                     || get_option( 'default_term_' . $term->taxonomy ) == $term->term_id )
     735                && ( (int) get_option( 'default_' . $term->taxonomy ) === $term->term_id
     736                    || (int) get_option( 'default_term_' . $term->taxonomy ) === $term->term_id )
    735737            ) {
    736738                $caps[] = 'do_not_allow';
Note: See TracChangeset for help on using the changeset viewer.