WP_Font_Collection::__construct()publicWP 6.5.0

WP_Font_Collection constructor.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WP_Font_Collection = new WP_Font_Collection();
$WP_Font_Collection->__construct( $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_Collection::__construct() WP 6.7.1

public function __construct( string $slug, array $args ) {
	$this->slug = sanitize_title( $slug );
	if ( $this->slug !== $slug ) {
		_doing_it_wrong(
			__METHOD__,
			/* translators: %s: Font collection slug. */
			sprintf( __( 'Font collection slug "%s" is not valid. Slugs must use only alphanumeric characters, dashes, and underscores.' ), $slug ),
			'6.5.0'
		);
	}

	$required_properties = array( 'name', 'font_families' );

	if ( isset( $args['font_families'] ) && is_string( $args['font_families'] ) ) {
		// JSON data is lazy loaded by ::get_data().
		$this->src = $args['font_families'];
		unset( $args['font_families'] );

		$required_properties = array( 'name' );
	}

	$this->data = $this->sanitize_and_validate_data( $args, $required_properties );
}