WP_Theme_JSON::preserve_valid_typed_settings │ private static │ WP 7.0.0

Preserves valid typed settings from input to output based on type markers in schema.

Recursively iterates through the schema and validates/preserves settings that have type markers (e.g., boolean) in VALID_SETTINGS.

Метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WP_Theme_JSON::preserve_valid_typed_settings( $input, $output, $schema, $path );
$input(массив) (обязательный)
Input settings to process.
$output(массив) (обязательный) (передается по ссылке — &)
Output settings array (passed by reference).
$schema(массив) (обязательный)
Schema to validate against (typically VALID_SETTINGS).
$path(array<string|int>)
Current path in the schema (for recursive calls).
По умолчанию: array()

Список изменений

С версии 7.0.0 Введена.

Код WP_Theme_JSON::preserve_valid_typed_settings() WP 7.1.4

private static function preserve_valid_typed_settings( $input, &$output, $schema, $path = array() ) {
	foreach ( $schema as $key => $schema_value ) {
		$current_path = array_merge( $path, array( $key ) );

		// Validate boolean type markers.
		if ( is_bool( $schema_value ) ) {
			$value = _wp_array_get( $input, $current_path, null );
			if ( is_bool( $value ) ) {
				_wp_array_set( $output, $current_path, $value ); // Preserve boolean value.
			}
		} elseif ( is_array( $schema_value ) ) {
			self::preserve_valid_typed_settings( $input, $output, $schema_value, $current_path ); // Recurse into nested structure.
		}
	}
}