Automattic\WooCommerce\Blocks\BlockTypes

ProductFilters::get_svg_iconprivateWC 1.0

Get SVG icon markup for a given icon name.

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

Хуков нет.

Возвращает

Строку. SVG markup for the icon, or empty string if icon not found.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_svg_icon( $name );
$name(строка) (обязательный)
The name of the icon to retrieve.

Код ProductFilters::get_svg_icon() WC 10.5.0

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