W3cubDocs

/WordPress

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

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

Version Description
6.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_font_collection/load_from_file