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