Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterRating::get_rating_items()
Get the Rating list items.
Метод класса: ProductFilterRating{}
Хуков нет.
Возвращает
Массив
. The rating items.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_rating_items( $ratings, $selected, $with_counts );
- $ratings(массив) (обязательный)
- - The rating counts.
- $selected(массив) (обязательный)
- - an array of selected ratings.
- $with_counts(true|false) (обязательный)
- - Whether to show the counts.
Код ProductFilterRating::get_rating_items() ProductFilterRating::get rating items WC 9.6.1
private function get_rating_items( $ratings, $selected, $with_counts ) { return array_map( function ( $rating ) use ( $selected, $with_counts ) { $value = (string) $rating['rating']; $count_label = $with_counts ? "({$rating['count']})" : ''; $aria_label = sprintf( /* translators: %1$d is referring to rating value. Example: Rated 4 out of 5. */ __( 'Rated %s out of 5', 'woocommerce' ), $value, ); return array( 'id' => 'rating-' . $value, 'selected' => in_array( $value, $selected, true ), 'label' => $this->render_rating_label( (int) $value, $count_label ), 'aria_label' => $aria_label, 'value' => $value, ); }, $ratings ); }