WC_Comments::maybe_adjust_products_reviews_pending_moderation_counter
Handles transition_comment_status processing and actualizes the counter.
Метод класса: WC_Comments{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Comments::maybe_adjust_products_reviews_pending_moderation_counter( $new_status, $old_status, $comment ): void;
- $new_status(int|строка) (обязательный)
- New status.
- $old_status(int|строка) (обязательный)
- Old status.
- $comment(WP_Comment) (обязательный)
- Comment object.
Код WC_Comments::maybe_adjust_products_reviews_pending_moderation_counter() WC Comments::maybe adjust products reviews pending moderation counter WC 10.5.2
public static function maybe_adjust_products_reviews_pending_moderation_counter( $new_status, $old_status, $comment ): void {
$needs_adjustments = 'unapproved' === $new_status || 'unapproved' === $old_status;
if ( $needs_adjustments && in_array( $comment->comment_type, array( 'review', 'comment', '' ), true ) ) {
$is_product = 'product' === get_post_type( $comment->comment_post_ID );
if ( $is_product ) {
if ( '0' === $comment->comment_approved ) {
wp_cache_incr( self::PRODUCT_REVIEWS_PENDING_COUNT_CACHE_KEY, 1, self::COMMENT_COUNT_CACHE_GROUP );
} else {
wp_cache_decr( self::PRODUCT_REVIEWS_PENDING_COUNT_CACHE_KEY, 1, self::COMMENT_COUNT_CACHE_GROUP );
}
}
}
}