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

@@ -39,8 +39,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
)
);
$status_whitelist = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' );
$status = 'all';
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ) ) ) {
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $status_whitelist, true ) ) {
$status = $_REQUEST['plugin_status'];
}
@@ -243,7 +245,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$totals[ $type ] = count( $list );
}
if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) {
if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) {
$status = 'all';
}
@@ -398,7 +400,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
global $status;
return array(
'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '<input type="checkbox" />' : '',
'name' => __( 'Plugin' ),
'description' => __( 'Description' ),
);
@@ -542,7 +544,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
public function bulk_actions( $which = '' ) {
global $status;
if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
if ( in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
return;
}
@@ -556,7 +558,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
protected function extra_tablenav( $which ) {
global $status;
if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ) ) ) {
if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ), true ) ) {
return;
}
@@ -597,7 +599,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
public function display_rows() {
global $status;
if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
return;
}
@@ -831,7 +833,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$compatible_php = is_php_version_compatible( $requires_php );
$class = $is_active ? 'active' : 'inactive';
$checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) || ! $compatible_php ) {
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) {
$checkbox = '';
} else {
$checkbox = sprintf(
@@ -870,7 +872,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
foreach ( $columns as $column_name => $column_display_name ) {
$extra_classes = '';
if ( in_array( $column_name, $hidden ) ) {
if ( in_array( $column_name, $hidden, true ) ) {
$extra_classes = ' hidden';
}