WC_Comments::maybe_bump_products_reviews_pending_moderation_counterpublic staticWC 1.0

Handles wp_insert_comment processing and actualizes the counter.

Method of the class: WC_Comments{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Comments::maybe_bump_products_reviews_pending_moderation_counter( $comment_id, $comment ): void;
$comment_id(int) (required)
Comment ID.
$comment(WP_Comment) (required)
Comment object.

WC_Comments::maybe_bump_products_reviews_pending_moderation_counter() code WC 10.5.0

public static function maybe_bump_products_reviews_pending_moderation_counter( $comment_id, $comment ): void {
	$needs_bump = '0' === $comment->comment_approved;
	if ( $needs_bump && in_array( $comment->comment_type, array( 'review', 'comment', '' ), true ) ) {
		$is_product = 'product' === get_post_type( $comment->comment_post_ID );
		if ( $is_product ) {
			wp_cache_incr( self::PRODUCT_REVIEWS_PENDING_COUNT_CACHE_KEY, 1, self::COMMENT_COUNT_CACHE_GROUP );
		}
	}
}