Changeset 57751 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 03/02/2024 01:39:43 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r57717 r57751 1066 1066 } 1067 1067 1068 // Check if the value is an array and requires further processing. 1069 if ( is_array( $value ) && is_array( $schema[ $key ] ) ) { 1070 // Determine if it is an associative or indexed array. 1071 $schema_is_assoc = self::is_assoc( $value ); 1072 1073 if ( $schema_is_assoc ) { 1074 // If associative, process as a single object. 1075 $tree[ $key ] = self::remove_keys_not_in_schema( $value, $schema[ $key ] ); 1076 1077 if ( empty( $tree[ $key ] ) ) { 1078 unset( $tree[ $key ] ); 1079 } 1080 } else { 1068 if ( is_array( $schema[ $key ] ) ) { 1069 if ( ! is_array( $value ) ) { 1070 unset( $tree[ $key ] ); 1071 } elseif ( wp_is_numeric_array( $value ) ) { 1081 1072 // If indexed, process each item in the array. 1082 1073 foreach ( $value as $item_key => $item_value ) { … … 1088 1079 } 1089 1080 } 1090 } 1091 } elseif ( is_array( $schema[ $key ] ) && ! is_array( $tree[ $key ] ) ) { 1092 unset( $tree[ $key ] ); 1093 } 1094 } 1095 1081 } else { 1082 // If associative, process as a single object. 1083 $tree[ $key ] = self::remove_keys_not_in_schema( $value, $schema[ $key ] ); 1084 1085 if ( empty( $tree[ $key ] ) ) { 1086 unset( $tree[ $key ] ); 1087 } 1088 } 1089 } 1090 } 1096 1091 return $tree; 1097 }1098 1099 /**1100 * Checks if the given array is associative.1101 *1102 * @since 6.5.01103 * @param array $data The array to check.1104 * @return bool True if the array is associative, false otherwise.1105 */1106 protected static function is_assoc( $data ) {1107 if ( array() === $data ) {1108 return false;1109 }1110 return array_keys( $data ) !== range( 0, count( $data ) - 1 );1111 1092 } 1112 1093
Note: See TracChangeset
for help on using the changeset viewer.