BP_Activity_List_Table::flatten_activity_array( array $tree )
Flatten the activity array.
Description
In some cases, BuddyPress gives us a structured tree of activity items plus their comments. This method converts it to a flat array.
Parameters
- $tree
-
(Required) Source array.
Return
(array) Flattened array.
Source
File: bp-activity/classes/class-bp-activity-list-table.php
public static function flatten_activity_array( $tree ){
foreach ( (array) $tree as $node ) {
if ( isset( $node->children ) ) {
foreach ( BP_Activity_List_Table::flatten_activity_array( $node->children ) as $child ) {
$tree[] = $child;
}
unset( $node->children );
}
}
return $tree;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.