WP_Theme_JSON_Resolver::read_json_file( string $file_path )

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Processes a file that adheres to the theme.json schema and returns an array with its contents, or a void array if none found.

Parameters

$file_path

(string) (Required) Path to file. Empty if no file.

Return

(array) Contents that adhere to the theme.json schema.

Source

File: wp-includes/class-wp-theme-json-resolver.php

private static function read_json_file( $file_path ) {
		$config = array();
		if ( $file_path ) {
			$decoded_file = json_decode(
				file_get_contents( $file_path ),
				true
			);

			$json_decoding_error = json_last_error();
			if ( JSON_ERROR_NONE !== $json_decoding_error ) {
				trigger_error( "Error when decoding a theme.json schema at path $file_path " . json_last_error_msg() );
				return $config;
			}

			if ( is_array( $decoded_file ) ) {
				$config = $decoded_file;
			}
		}
		return $config;
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/read_json_file