Make WordPress Core


Ignore:
Timestamp:
07/12/2026 11:19:36 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use in_array() instead of array_search() for existence checks.

Several places in core use array_search() purely to determine whether a value exists in an array, comparing the result against false. In these cases the returned key/position is never used, so in_array() expresses the intent more clearly and avoids computing a return value that is discarded.

This commit replaces those existence-only array_search() calls with in_array(). The strict (true) comparison flag is preserved in every case, so there is no change in behavior.

Props Soean.
See #64897.

File:
1 edited

Legend:

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

    r62550 r62699  
    18641864                         */
    18651865
    1866                         if ( false === array_search( strtolower( $value ), $checkvalue, true ) ) {
     1866                        if ( ! in_array( strtolower( $value ), $checkvalue, true ) ) {
    18671867                                $ok = false;
    18681868                        }
Note: See TracChangeset for help on using the changeset viewer.