LLMS_Comments::wp_count_comments( stdClass|array $stats, int $post_id )

Remove order notes from the count when counting comments


Description Description

This method is hooked to wp_count_comments, called by wp_count_comments().

It handles two potential scenarios:

1) No other plugins have run the filter and the incoming $stats is an empty array. In this scenario we’ll utilize get_comment_count() to create a new $stats object

2) Another plugin has already generated a stats object and then incoming $stats is a stdClass.

In either scenario we query the number of order notes and subtract this number from the existing comment counts.


Parameters Parameters

$stats

(Required) Empty array or a stdClass of stats from another plugin.

$post_id

(Required) WP Post ID. 0 indicates comment stats for the entire site.


Top ↑

Return Return

(stdClass) The number of comments keyed by their status.

  • 'approved'
    (int) The number of approved comments.
  • 'moderated'
    (int) The number of comments awaiting moderation (a.k.a. pending).
  • 'spam'
    (int) The number of spam comments.
  • 'trash'
    (int) The number of trashed comments.
  • 'post-trashed'
    (int) The number of comments for posts that are in the trash.
  • 'total_comments'
    (int) The total number of non-trashed comments, including spam.
  • 'all'
    (int) The total number of pending or approved comments.


Top ↑

Source Source

File: includes/class.llms.comments.php


			

Top ↑

Changelog Changelog

Changelog
Version Description
3.37.12 Use strict comparisons. Fix issue encountered when $stats is an empty array. Modify the stats generation method.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.