Make WordPress Core


Ignore:
Timestamp:
04/09/2020 03:41:04 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() and array_search().

This addresses all the remaining WordPress.PHP.StrictInArray.MissingTrueStrict issues in core.

Includes minor code layout fixes for better readability.

Follow-up to [47550].

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-walker-category-checklist.php

    r47550 r47557  
    8484        $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
    8585
    86         $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
     86        $class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
    8787
    8888        $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
     
    9292            $inner_class  = 'category';
    9393
    94             if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
     94            if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
    9595                $inner_class .= ' selected';
    9696                $aria_checked = 'true';
     
    103103                esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
    104104        } else {
     105            $is_selected = in_array( $category->term_id, $args['selected_cats'], true );
     106            $is_disabled = ! empty( $args['disabled'] );
     107
    105108            $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
    106109                '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
    107                 checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
    108                 disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
     110                checked( $is_selected, true, false ) .
     111                disabled( $is_disabled, true, false ) . ' /> ' .
    109112                /** This filter is documented in wp-includes/category-template.php */
    110113                esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
Note: See TracChangeset for help on using the changeset viewer.