wp_register_font_collection()WP 6.5.0

Registers a new font collection in the font library.

See https://schemas.wp.org/trunk/font-collection.json for the schema the font collection data must adhere to.

No Hooks.

Returns

WP_Font_Collection|WP_Error. A font collection if it was registered successfully, or WP_Error object on failure.

Usage

wp_register_font_collection( $slug, $args );
$slug(string) (required)
Font collection slug. May only contain alphanumeric characters, dashes, and underscores. See sanitize_title().
$args(array) (required)

Font collection data.

  • name(string)
    Required. Name of the font collection shown in the Font Library.

  • description(string)
    Optional. A short descriptive summary of the font collection.
    Default: ''

  • font_families(array|string)
    Required. Array of font family definitions that are in the collection, or a string containing the path or URL to a JSON file containing the font collection.

  • categories(array)
    Optional. Array of categories, each with a name and slug, that are used by the fonts in the collection.
    Default: ''

Changelog

Since 6.5.0 Introduced.

wp_register_font_collection() code WP 6.8.1

function wp_register_font_collection( string $slug, array $args ) {
	return WP_Font_Library::get_instance()->register_font_collection( $slug, $args );
}