Changeset 8718
- Timestamp:
- 07/29/2014 06:52:10 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-activity/bp-activity-template.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-template.php
r8717 r8718 2147 2147 2148 2148 /** 2149 * Return the content of the activity comment currently being displayed. 2150 * 2151 * The content is run through two filters. 'bp_get_activity_content' 2152 * will apply all filters applied to activity items in general. Use 2153 * 'bp_activity_comment_content' to modify the content of activity 2154 * comments only. 2149 * Return the comment count of an activity item. 2155 2150 * 2156 2151 * @since BuddyPress (1.2) … … 2159 2154 * @uses bp_activity_recurse_comment_count() 2160 2155 * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook. 2161 * @todo deprecate $args2162 * 2163 * @param array $args Deprecated.2156 * 2157 * @param array $deprecated Deprecated. 2158 * 2164 2159 * @return int $count The activity comment count. 2165 2160 */ 2166 function bp_activity_get_comment_count( $args = '' ) { 2167 global $activities_template; 2168 2169 if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children ) 2170 return 0; 2171 2172 $count = bp_activity_recurse_comment_count( $activities_template->activity ); 2161 function bp_activity_get_comment_count( $deprecated = null ) { 2162 global $activities_template; 2163 2164 // Deprecated notice about $args 2165 if ( ! empty( $deprecated ) ) { 2166 _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) ); 2167 } 2168 2169 // Get the count using the purpose-built recursive function 2170 $count = ! empty( $activities_template->activity->children ) 2171 ? bp_activity_recurse_comment_count( $activities_template->activity ) 2172 : 0; 2173 2173 2174 2174 return apply_filters( 'bp_activity_get_comment_count', (int) $count ); … … 2176 2176 2177 2177 /** 2178 * Return the content of the activity comment currently being displayed.2178 * Return the total number of comments to the current comment. 2179 2179 * 2180 * The content is run through two filters. 'bp_get_activity_content' 2181 * will apply all filters applied to activity items in general. 2182 * Use bp_activity_comment_content to modify the content of 2183 * activity comments only. 2180 * This function recursively adds the total number of comments each 2181 * activity child has, and returns them. 2184 2182 * 2185 2183 * @since BuddyPress (1.2) 2186 2184 * 2187 2185 * @uses bp_activity_recurse_comment_count() 2188 * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook 2189 * @todo investigate why bp_activity_recurse_comment_count() is used while being declared 2186 * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook 2190 2187 * 2191 2188 * @param object $comment Activity comment object. 2192 2189 * @param int $count The current iteration count. 2190 * 2193 2191 * @return int $count The activity comment count. 2194 2192 */ 2195 2193 function bp_activity_recurse_comment_count( $comment, $count = 0 ) { 2196 2194 2197 if ( empty( $comment->children ) ) 2198 return $count; 2199 2200 foreach ( (array) $comment->children as $comment ) { 2201 $count++; 2202 $count = bp_activity_recurse_comment_count( $comment, $count ); 2195 // Copy the count 2196 $new_count = $count; 2197 2198 // Loop through children and recursively count comments 2199 if ( ! empty( $comment->children ) ) { 2200 foreach ( (array) $comment->children as $comment ) { 2201 $new_count++; 2202 $new_count = bp_activity_recurse_comment_count( $comment, $new_count ); 2203 } 2203 2204 } 2204 2205 2205 return $count; 2206 // Filter and return 2207 return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count ); 2206 2208 } 2207 2209
Note: See TracChangeset
for help on using the changeset viewer.