WP_REST_Icons_Controller::get_iconpublicWP 1.0

Retrieves a specific icon from the registry.

Method of the class: WP_REST_Icons_Controller{}

No Hooks.

Returns

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

Usage

$WP_REST_Icons_Controller = new WP_REST_Icons_Controller();
$WP_REST_Icons_Controller->get_icon( $name );
$name(string) (required)
Icon name.

WP_REST_Icons_Controller::get_icon() code WP 7.0

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;
}