Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterActive::render_chip_item()privateWC 1.0

Render the chip item of an active filter.

Method of the class: ProductFilterActive{}

No Hooks.

Return

String. Item HTML.

Usage

// private - for code of main (parent) class only
$result = $this->render_chip_item( $args );
$args(array) (required)
Item data.

ProductFilterActive::render_chip_item() code WC 8.9.0

<?php
private function render_chip_item( $args ) {
	list ( 'title' => $title, 'attributes' => $attributes ) = wp_parse_args(
		$args,
		array(
			'title'      => '',
			'attributes' => array(),
		)
	);

	if ( ! $title || empty( $attributes ) ) {
		return;
	}

	$remove_label = sprintf( 'Remove %s filter', wp_strip_all_tags( $title ) );
	?>
	<li class="list-item">
		<span class="is-removable wc-block-components-chip wc-block-components-chip--radius-large">
			<span aria-hidden="false" class="wc-block-components-chip__text"><?php echo wp_kses_post( $title ); ?></span>
			<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
			<button class="wc-block-components-chip__remove" aria-label="<?php echo esc_attr( $remove_label ); ?>" <?php echo $this->get_html_attributes( $attributes ); ?>>
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" role="img" class="wc-block-components-chip__remove-icon" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg>
			</button>
		</span>
	</li>
	<?php
}