diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index ba2a2dfa38..2a4303b5a3 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -1065,19 +1065,10 @@ class WP_Theme_JSON { continue; } - // Check if the value is an array and requires further processing. - if ( is_array( $value ) && is_array( $schema[ $key ] ) ) { - // Determine if it is an associative or indexed array. - $schema_is_assoc = self::is_assoc( $value ); - - if ( $schema_is_assoc ) { - // If associative, process as a single object. - $tree[ $key ] = self::remove_keys_not_in_schema( $value, $schema[ $key ] ); - - if ( empty( $tree[ $key ] ) ) { - unset( $tree[ $key ] ); - } - } else { + if ( is_array( $schema[ $key ] ) ) { + if ( ! is_array( $value ) ) { + unset( $tree[ $key ] ); + } elseif ( wp_is_numeric_array( $value ) ) { // If indexed, process each item in the array. foreach ( $value as $item_key => $item_value ) { if ( isset( $schema[ $key ][0] ) && is_array( $schema[ $key ][0] ) ) { @@ -1087,29 +1078,19 @@ class WP_Theme_JSON { $tree[ $key ][ $item_key ] = $item_value; } } + } else { + // If associative, process as a single object. + $tree[ $key ] = self::remove_keys_not_in_schema( $value, $schema[ $key ] ); + + if ( empty( $tree[ $key ] ) ) { + unset( $tree[ $key ] ); + } } - } elseif ( is_array( $schema[ $key ] ) && ! is_array( $tree[ $key ] ) ) { - unset( $tree[ $key ] ); } } - return $tree; } - /** - * Checks if the given array is associative. - * - * @since 6.5.0 - * @param array $data The array to check. - * @return bool True if the array is associative, false otherwise. - */ - protected static function is_assoc( $data ) { - if ( array() === $data ) { - return false; - } - return array_keys( $data ) !== range( 0, count( $data ) - 1 ); - } - /** * Returns the existing settings for each block. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 71e059594d..cd74b468ea 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-beta3-57750'; +$wp_version = '6.5-beta3-57751'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.