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.


Top ↑

Parameters Parameters

$stats

(stdClass) (Required) Comment stats object. See the return of LLMS_Comments::wp_comment_counts() for object details.


Top ↑

Return Return

(stdClass) See LLMS_Comments::wp_comment_counts() for return object details.


Top ↑

Source Source

File: includes/class.llms.comments.php

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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