Make WordPress Core


Ignore:
Timestamp:
04/09/2020 03:41:04 PM (5 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-includes/class-wp-query.php

    r47550 r47557  
    31383138            // Loop over posts and relocate stickies to the front.
    31393139            for ( $i = 0; $i < $num_posts; $i++ ) {
    3140                 if ( in_array( $this->posts[ $i ]->ID, $sticky_posts ) ) {
     3140                if ( in_array( $this->posts[ $i ]->ID, $sticky_posts, true ) ) {
    31413141                    $sticky_post = $this->posts[ $i ];
    31423142                    // Remove sticky from current position.
     
    31473147                    $sticky_offset++;
    31483148                    // Remove post from sticky posts array.
    3149                     $offset = array_search( $sticky_post->ID, $sticky_posts );
     3149                    $offset = array_search( $sticky_post->ID, $sticky_posts, true );
    31503150                    unset( $sticky_posts[ $offset ] );
    31513151                }
Note: See TracChangeset for help on using the changeset viewer.