WC_Widget_Recent_Reviews::widget()
Output widget.
Method of the class: WC_Widget_Recent_Reviews{}
Hooks from the method
Return
null
. Nothing (null).
Usage
$WC_Widget_Recent_Reviews = new WC_Widget_Recent_Reviews(); $WC_Widget_Recent_Reviews->widget( $args, $instance );
- $args(array) (required)
- Arguments.
- $instance(array) (required)
- Widget instance.
Notes
- See: WP_Widget
WC_Widget_Recent_Reviews::widget() WC Widget Recent Reviews::widget code WC 9.4.2
public function widget( $args, $instance ) { global $comments, $comment; if ( $this->get_cached_widget( $args ) ) { return; } ob_start(); $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; $comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product', 'parent' => 0, ) ); // WPCS: override ok. if ( $comments ) { $this->widget_start( $args, $instance ); echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_review_list', '<ul class="product_list_widget">' ) ); foreach ( (array) $comments as $comment ) { wc_get_template( 'content-widget-reviews.php', array( 'comment' => $comment, 'product' => wc_get_product( $comment->comment_post_ID ), ) ); } echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_review_list', '</ul>' ) ); $this->widget_end( $args ); } $content = ob_get_clean(); echo $content; // WPCS: XSS ok. $this->cache_widget( $args, $content ); }