Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterActive::render_list_item()privateWC 1.0

Render the list 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_list_item( $args );
$args(array) (required)
Item data.

ProductFilterActive::render_list_item() code WC 8.9.0

<?php
private function render_list_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="list-item-name">
			<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
			<button class="list-item-remove"  <?php echo $this->get_html_attributes( $attributes ); ?>>
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" 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>
				<span class="screen-reader-text"><?php echo esc_html( $remove_label ); ?></span>
			</button>
			<?php echo wp_kses_post( $title ); ?>
		</span>
	</li>
	<?php
}