Automattic\WooCommerce\Internal\Admin\ProductReviews
ReviewsListTable::column_rating()
Renders the rating column.
Method of the class: ReviewsListTable{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->column_rating( $item ) : void;
- $item(WP_Comment|mixed) (required)
- Review or reply being rendered.
ReviewsListTable::column_rating() ReviewsListTable::column rating code WC 9.4.2
<?php protected function column_rating( $item ) : void { $rating = get_comment_meta( $item->comment_ID, 'rating', true ); ob_start(); if ( ! empty( $rating ) && is_numeric( $rating ) ) { $rating = (int) $rating; $accessibility_label = sprintf( /* translators: 1: number representing a rating */ __( '%1$d out of 5', 'woocommerce' ), $rating ); $stars = str_repeat( '★', $rating ); $stars .= str_repeat( '☆', 5 - $rating ); ?> <span aria-label="<?php echo esc_attr( $accessibility_label ); ?>"><?php echo esc_html( $stars ); ?></span> <?php } echo $this->filter_column_output( 'rating', ob_get_clean(), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }