Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterChips::get_aria_labelprivateWC 1.0

Get aria label for filter item.

Method of the class: ProductFilterChips{}

No Hooks.

Returns

String. Aria label.

Usage

// private - for code of main (parent) class only
$result = $this->get_aria_label( $item, $show_counts );
$item(array) (required)
Filter item.
$show_counts(true|false) (required)
Whether to show counts.

ProductFilterChips::get_aria_label() code WC 10.8.1

private function get_aria_label( $item, $show_counts ) {
	if ( $show_counts ) {
		return sprintf(
			/* translators: %1$s: Product filter name, %2$d: Number of products */
			_n(
				'%1$s (%2$d product)',
				'%1$s (%2$d products)',
				$item['count'],
				'woocommerce'
			),
			$item['ariaLabel'] ?? $item['label'],
			$item['count']
		);
	}

	return $item['ariaLabel'] ?? $item['label'];
}