WP_REST_Icons_Controller::get_icon( string $name ): array|WP_Error

In this article

Retrieves a specific icon from the registry.

Parameters

$namestringrequired
Icon name.

Return

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

Source

public function get_icon( $name ) {
	$registry = WP_Icons_Registry::get_instance();
	$icon     = $registry->get_registered_icon( $name );

	if ( null === $icon ) {
		return new WP_Error(
			'rest_icon_not_found',
			sprintf(
				// translators: %s is the name of any user-provided name
				__( 'Icon not found: "%s".' ),
				$name
			),
			array( 'status' => 404 )
		);
	}

	return $icon;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.