WP_Font_Collection::load_from_file( string $file ): array|WP_Error

In this article

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.

Loads the font collection data from a JSON file path.

Parameters

$filestringrequired
File path to a JSON file containing the font collection data.

Return

array|WP_Error An array containing the font collection data on success, else an instance of WP_Error on failure.

Source

private function load_from_file( $file ) {
	$data = wp_json_file_decode( $file, array( 'associative' => true ) );
	if ( empty( $data ) ) {
		return new WP_Error( 'font_collection_decode_error', __( 'Error decoding the font collection JSON file contents.' ) );
	}

	return $this->sanitize_and_validate_data( $data, array( 'font_families' ) );
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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