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/translation-install.php

    r47230 r47550  
    2121    require ABSPATH . WPINC . '/version.php';
    2222
    23     if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) {
     23    if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
    2424        return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
    2525    }
     
    177177                esc_attr( current( $language['iso'] ) ),
    178178                esc_attr( $language['strings']['continue'] ?: 'Continue' ),
    179                 in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
     179                in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
    180180                esc_html( $language['native_name'] )
    181181            );
     
    191191            esc_attr( current( $language['iso'] ) ),
    192192            esc_attr( $language['strings']['continue'] ?: 'Continue' ),
    193             in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
     193            in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
    194194            esc_html( $language['native_name'] )
    195195        );
     
    212212function wp_download_language_pack( $download ) {
    213213    // Check if the translation is already installed.
    214     if ( in_array( $download, get_available_languages() ) ) {
     214    if ( in_array( $download, get_available_languages(), true ) ) {
    215215        return $download;
    216216    }
Note: See TracChangeset for help on using the changeset viewer.