WP_Font_Library::register_font_collection()publicWP 6.5.0

Register a new font collection.

Метод класса: WP_Font_Library{}

Хуков нет.

Возвращает

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

Использование

$WP_Font_Library = new WP_Font_Library();
$WP_Font_Library->register_font_collection( $slug, $args );
$slug(строка) (обязательный)
Font collection slug. May only contain alphanumeric characters, dashes, and underscores. See sanitize_title().
$args(массив) (обязательный)
Font collection data. See wp_register_font_collection() for information on accepted arguments.

Список изменений

С версии 6.5.0 Введена.

Код WP_Font_Library::register_font_collection() WP 6.7.1

public function register_font_collection( string $slug, array $args ) {
	$new_collection = new WP_Font_Collection( $slug, $args );

	if ( $this->is_collection_registered( $new_collection->slug ) ) {
		$error_message = sprintf(
			/* translators: %s: Font collection slug. */
			__( 'Font collection with slug: "%s" is already registered.' ),
			$new_collection->slug
		);
		_doing_it_wrong(
			__METHOD__,
			$error_message,
			'6.5.0'
		);
		return new WP_Error( 'font_collection_registration_error', $error_message );
	}
	$this->collections[ $new_collection->slug ] = $new_collection;
	return $new_collection;
}