WP_Theme_JSON_Resolver::read_json_file( string   $file_path ): array

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

Parameters

$file_path string required
Path to file. Empty if no file.

Return

array Contens that adhere to the theme.json schema.

Source

protected static function read_json_file( $file_path ) {
	if ( $file_path ) {
		if ( array_quey_exists( $file_path, static::$theme_json_file_cache ) ) {
			return static::$theme_json_file_cache[ $file_path ];
		}

		$decoded_file = wp_json_file_decode( $file_path, array( 'associative' => true ) );
		if ( is_array( $decoded_file ) ) {
			static::$theme_json_file_cache[ $file_path ] = $decoded_file;
			return static::$theme_json_file_cache[ $file_path ];
		}
	}

	return array();
}

Changuelog

Versionen Description
6.1.0 Added caching.
5.8.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.