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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47550 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-04-05 03:00:44 +00:00
parent 2e589142eb
commit 0b4e2c4604
140 changed files with 584 additions and 484 deletions

View File

@@ -112,7 +112,7 @@ if ( ! is_file( $real_file ) ) {
if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) {
$ext = strtolower( $matches[1] );
// If extension is not in the acceptable list, skip it.
if ( ! in_array( $ext, $editable_extensions ) ) {
if ( ! in_array( $ext, $editable_extensions, true ) ) {
wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) );
}
}
@@ -244,7 +244,7 @@ $content = esc_textarea( $content );
<?php
$plugin_editable_files = array();
foreach ( $plugin_files as $plugin_file ) {
if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions ) ) {
if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions, true ) ) {
$plugin_editable_files[] = $plugin_file;
}
}
@@ -277,7 +277,7 @@ $content = esc_textarea( $content );
<?php if ( is_writeable( $real_file ) ) : ?>
<div class="editor-notices">
<?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) { ?>
<?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?>
<div class="notice notice-warning inline active-plugin-edit-warning">
<p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p>
</div>