bp_nouveau_notifications_sort( array $filters = array() )
Sort Notifications according to their position arguments.
Description
Parameters
- $filters
-
(Optional) The notifications filters to order.
Default value: array()
Return
(array) The sorted filters.
Source
File: bp-templates/bp-nouveau/includes/notifications/functions.php
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | function bp_nouveau_notifications_sort( $filters = array () ) { $sorted = array (); if ( empty ( $filters ) || ! is_array ( $filters ) ) { return $sorted ; } foreach ( $filters as $filter ) { $position = 99; if ( isset( $filter [ 'position' ] ) ) { $position = (int) $filter [ '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 ] = $filter ; } 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.