mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-06 21:54:28 +00:00
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:
@@ -400,7 +400,7 @@ function populate_options( array $options = array() ) {
|
||||
$offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings
|
||||
if ( is_numeric( $offset_or_tz ) ) {
|
||||
$gmt_offset = $offset_or_tz;
|
||||
} elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) {
|
||||
} elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list(), true ) ) {
|
||||
$timezone_string = $offset_or_tz;
|
||||
}
|
||||
|
||||
@@ -563,11 +563,13 @@ function populate_options( array $options = array() ) {
|
||||
$existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||
|
||||
$insert = '';
|
||||
|
||||
foreach ( $options as $option => $value ) {
|
||||
if ( in_array( $option, $existing_options ) ) {
|
||||
if ( in_array( $option, $existing_options, true ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( in_array( $option, $fat_options ) ) {
|
||||
|
||||
if ( in_array( $option, $fat_options, true ) ) {
|
||||
$autoload = 'no';
|
||||
} else {
|
||||
$autoload = 'yes';
|
||||
@@ -576,9 +578,11 @@ function populate_options( array $options = array() ) {
|
||||
if ( is_array( $value ) ) {
|
||||
$value = serialize( $value );
|
||||
}
|
||||
|
||||
if ( ! empty( $insert ) ) {
|
||||
$insert .= ', ';
|
||||
}
|
||||
|
||||
$insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user