Automattic\WooCommerce\Internal\Admin\ProductReviews
Reviews::get_pending_count_bubble
Counts the number of pending product reviews/replies, and returns the notification bubble if there's more than zero.
Method of the class: Reviews{}
Hooks from the method
Returns
String. Empty string if there are no pending reviews, or bubble HTML if there are.
Usage
// protected - for code of main (parent) or child class $result = $this->get_pending_count_bubble(): string;
Reviews::get_pending_count_bubble() Reviews::get pending count bubble code WC 10.5.0
protected function get_pending_count_bubble(): string {
// Quirks related to https://github.com/woocommerce/woocommerce/issues/37464.
if ( method_exists( \WC_Comments::class, 'get_products_reviews_pending_moderation_counter' ) ) {
$count = \WC_Comments::get_products_reviews_pending_moderation_counter();
} else {
$count = (int) get_comments(
array(
'type__in' => array( 'review', 'comment' ),
'status' => '0',
'post_type' => 'product',
'count' => true,
)
);
}
/**
* Provides an opportunity to alter the pending comment count used within
* the product reviews admin list table.
*
* @since 7.0.0
*
* @param array $count Current count of comments pending review.
*/
$count = apply_filters( 'woocommerce_product_reviews_pending_count', $count );
if ( empty( $count ) ) {
return '';
}
return ' <span class="awaiting-mod count-' . esc_attr( $count ) . '"><span class="pending-count">' . esc_html( $count ) . '</span></span>';
}