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.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2020-04-05 03:02:11 +00:00
parent 10e3e44219
commit 38676936ba
141 changed files with 585 additions and 485 deletions

View File

@@ -523,7 +523,7 @@ function _get_dropins() {
* @return bool True, if in the active plugins list. False, not in the list.
*/
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}
/**
@@ -644,7 +644,7 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
return $requirements;
}
if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current, true ) ) ) {
if ( ! empty( $redirect ) ) {
// We'll override this later if the plugin can be included without fatal error.
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
@@ -783,7 +783,7 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
}
if ( true !== $network_wide ) {
$key = array_search( $plugin, $current );
$key = array_search( $plugin, $current, true );
if ( false !== $key ) {
$do_blog = true;
unset( $current[ $key ] );