LLMS_Comments::modify_comment_stats( stdClass $stats )
Remove order notes from an existing comment count stats object.
Description Description
This method accepts a stats object, generated by another plugin (like WooCommerce) or using core information from get_comment_counts() and then subtracts LifterLMS order note comments from the existing comment counts which would have included order notes in the counts.
Parameters Parameters
- $stats
-
(stdClass) (Required) Comment stats object. See the return of LLMS_Comments::wp_comment_counts() for object details.
Return Return
(stdClass) See LLMS_Comments::wp_comment_counts() for return object details.
Source Source
File: includes/class.llms.comments.php
protected static function modify_comment_stats( $stats ) {
$counts = self::get_note_counts();
$map = self::get_approved_map();
foreach ( (array) $counts as $row ) {
if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) {
$stats->all -= $row['num_comments'];
$stats->total_comments -= $row['num_comments'];
}
if ( isset( $map[ $row['comment_approved'] ] ) ) {
$var = $map[ $row['comment_approved'] ];
$stats->$var -= $row['num_comments'];
}
}
set_transient( self::$count_transient_key, $stats );
return $stats;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.37.12 | Introduced. |