BP_Notifications_Notification::get_order_by_sql( array $args = array() )
Assemble the ORDER BY clause of a get() SQL statement.
Description
Used by BP_Notifications_Notification::get() to create its ORDER BY clause.
Parameters
- $args
-
(Optional) See BP_Notifications_Notification::get() for more details.
Default value: array()
Return
(string) ORDER BY clause.
Source
File: bp-notifications/classes/class-bp-notifications-notification.php
protected static function get_order_by_sql( $args = array() ) {
// Setup local variable.
$conditions = array();
$retval = '';
// Order by.
if ( ! empty( $args['order_by'] ) ) {
$order_by = implode( ', ', (array) $args['order_by'] );
$conditions['order_by'] = "{$order_by}";
}
// Sort order direction.
if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ) ) ) {
$sort_order = $args['sort_order'];
$conditions['sort_order'] = "{$sort_order}";
}
// Custom ORDER BY.
if ( ! empty( $conditions ) ) {
$retval = 'ORDER BY ' . implode( ' ', $conditions );
}
return $retval;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.9.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.