Make WordPress Core


Ignore:
Timestamp:
04/05/2020 03:00:44 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.

This reduces the number of WordPress.PHP.StrictInArray.MissingTrueStrict issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

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

    r47546 r47550  
    524524 */
    525525function is_plugin_active( $plugin ) {
    526     return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );
     526    return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
    527527}
    528528
     
    645645    }
    646646
    647     if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
     647    if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current, true ) ) ) {
    648648        if ( ! empty( $redirect ) ) {
    649649            // We'll override this later if the plugin can be included without fatal error.
     
    784784
    785785        if ( true !== $network_wide ) {
    786             $key = array_search( $plugin, $current );
     786            $key = array_search( $plugin, $current, true );
    787787            if ( false !== $key ) {
    788788                $do_blog = true;
Note: See TracChangeset for help on using the changeset viewer.