Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/13/2009 05:39:04 PM (16 years ago)
Author:
apeatling
Message:

Added function to recurse and return the activity comment count for an activity item.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r2088 r2092  
    407407
    408408            return $content;
     409        }
     410
     411function bp_activity_comment_count() {
     412    echo bp_activity_get_comment_count();
     413}
     414    function bp_activity_get_comment_count( $args = '' ) {
     415        global $activities_template, $bp;
     416
     417        if ( !$activities_template->activity->children )
     418            return 0;
     419
     420        $count = bp_activity_recurse_comment_count( $activities_template->activity );
     421
     422        return apply_filters( 'bp_activity_get_comment_count', (int)$count );
     423    }
     424        function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
     425            global $activities_template, $bp;
     426
     427            if ( !$comment->children )
     428                return $count;
     429
     430            foreach ( $comment->children as $comment ) {
     431                $count++;
     432                $count = bp_activity_recurse_comment_count( $comment, $count );
     433            }
     434
     435            return $count;
    409436        }
    410437
Note: See TracChangeset for help on using the changeset viewer.