WP_REST_Icon_Collections_Controller::get_icon_collection │ public │ WP 7.1.0

Retrieves a specific icon collection from the registry.

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

Хуков нет.

Возвращает

array|WP_Error. Icon collection data on success, or WP_Error object on failure.

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

$WP_REST_Icon_Collections_Controller = new WP_REST_Icon_Collections_Controller();
$WP_REST_Icon_Collections_Controller->get_icon_collection( $slug );
$slug(строка) (обязательный)
Icon collection slug.

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

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

Код WP_REST_Icon_Collections_Controller::get_icon_collection() WP 7.1.4

public function get_icon_collection( $slug ) {
	$registry   = WP_Icon_Collections_Registry::get_instance();
	$collection = $registry->get_registered( $slug );

	if ( null === $collection ) {
		return new WP_Error(
			'rest_icon_collection_not_found',
			sprintf(
				/* translators: %s: Icon collection slug. */
				__( 'Icon collection not found: "%s".' ),
				$slug
			),
			array( 'status' => 404 )
		);
	}

	return $collection;
}