BP_Buttons_Group::sort( $buttons )
Sort the Buttons of the group according to their position attribute
Description
Parameters
-
(Required) the list of buttons to sort.
Return
(array) the list of buttons sorted.
Source
File: bp-templates/bp-nouveau/includes/classes.php
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | public function sort( $buttons ) { $sorted = array (); foreach ( $buttons as $button ) { $position = 99; if ( isset( $button [ 'position' ] ) ) { $position = (int) $button [ 'position' ]; } // If position is already taken, move to the first next available if ( isset( $sorted [ $position ] ) ) { $sorted_keys = array_keys ( $sorted ); do { $position += 1; } while ( in_array( $position , $sorted_keys , true ) ); } $sorted [ $position ] = $button ; } ksort( $sorted ); return $sorted ; } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.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.