Automattic\WooCommerce\Blocks\BlockTypes

ProductFilters::get_svg_iconprivateWC 1.0

Get SVG icon markup for a given icon name.

Method of the class: ProductFilters{}

No Hooks.

Returns

String. SVG markup for the icon, or empty string if icon not found.

Usage

// private - for code of main (parent) class only
$result = $this->get_svg_icon( $name );
$name(string) (required)
The name of the icon to retrieve.

ProductFilters::get_svg_icon() code WC 9.9.4

private function get_svg_icon( string $name ) {
	$icons = array(
		'close'         => '<path d="M12 13.0607L15.7123 16.773L16.773 15.7123L13.0607 12L16.773 8.28772L15.7123 7.22706L12 10.9394L8.28771 7.22705L7.22705 8.28771L10.9394 12L7.22706 15.7123L8.28772 16.773L12 13.0607Z" fill="currentColor"/>',
		'filter-icon-2' => '<path d="M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" fill="currentColor"/>',
	);

	if ( ! isset( $icons[ $name ] ) ) {
		return '';
	}

	return sprintf(
		'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">%s</svg>',
		$icons[ $name ]
	);
}