WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Widget_Rating_Filter::widget() public WC 1.0

Widget function.

Это метод класса: WC_Widget_Rating_Filter{}

Возвращает

Null. Ничего.

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

$WC_Widget_Rating_Filter = new WC_Widget_Rating_Filter();
$WC_Widget_Rating_Filter->widget( $args, $instance );
$args(массив) (обязательный)
Arguments.
$instance(массив) (обязательный)
Widget instance.

Заметки

Код WC_Widget_Rating_Filter::widget() WC 4.5.2

woocommerce/includes/widgets/class-wc-widget-rating-filter.php
<?php
public function widget( $args, $instance ) {
	if ( ! is_shop() && ! is_product_taxonomy() ) {
		return;
	}

	if ( ! WC()->query->get_main_query()->post_count ) {
		return;
	}

	ob_start();

	$found         = false;
	$rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) ) : array(); // WPCS: input var ok, CSRF ok, sanitization ok.
	$base_link     = remove_query_arg( 'paged', $this->get_current_page_url() );

	$this->widget_start( $args, $instance );

	echo '<ul>';

	for ( $rating = 5; $rating >= 1; $rating-- ) {
		$count = $this->get_filtered_product_count( $rating );
		if ( empty( $count ) ) {
			continue;
		}
		$found = true;
		$link  = $base_link;

		if ( in_array( $rating, $rating_filter, true ) ) {
			$link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) );
		} else {
			$link_ratings = implode( ',', array_merge( $rating_filter, array( $rating ) ) );
		}

		$class       = in_array( $rating, $rating_filter, true ) ? 'wc-layered-nav-rating chosen' : 'wc-layered-nav-rating';
		$link        = apply_filters( 'woocommerce_rating_filter_link', $link_ratings ? add_query_arg( 'rating_filter', $link_ratings, $link ) : remove_query_arg( 'rating_filter' ) );
		$rating_html = wc_get_star_rating_html( $rating );
		$count_html  = wp_kses(
			apply_filters( 'woocommerce_rating_filter_count', "({$count})", $count, $rating ),
			array(
				'em'     => array(),
				'span'   => array(),
				'strong' => array(),
			)
		);

		printf( '<li class="%s"><a href="%s"><span class="star-rating">%s</span> %s</a></li>', esc_attr( $class ), esc_url( $link ), $rating_html, $count_html ); // WPCS: XSS ok.
	}

	echo '</ul>';

	$this->widget_end( $args );

	if ( ! $found ) {
		ob_end_clean();
	} else {
		echo ob_get_clean(); // WPCS: XSS ok.
	}
}