BP_Notifications_Notification::get_total_count( array $args )
Get a count of total notifications matching a set of arguments.
Description
See also
- BP_Notifications_Notification::get(): for a description of arguments.
Parameters
- $args
-
(Required) See BP_Notifications_Notification::get().
Return
(int) Count of located items.
Source
File: bp-notifications/classes/class-bp-notifications-notification.php
public static function get_total_count( $args ) {
global $wpdb;
// Parse the arguments.
$r = self::parse_args( $args );
// Load BuddyPress.
$bp = buddypress();
// METADATA.
$meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
// SELECT.
$select_sql = "SELECT COUNT(*)";
// FROM.
$from_sql = "FROM {$bp->notifications->table_name} n ";
// JOIN.
$join_sql = $meta_query_sql['join'];
// WHERE.
$where_sql = self::get_where_sql( array(
'id' => $r['id'],
'user_id' => $r['user_id'],
'item_id' => $r['item_id'],
'secondary_item_id' => $r['secondary_item_id'],
'component_name' => $r['component_name'],
'component_action' => $r['component_action'],
'is_new' => $r['is_new'],
'search_terms' => $r['search_terms'],
'date_query' => $r['date_query']
), $select_sql, $from_sql, $join_sql, $meta_query_sql );
// Concatenate query parts.
$sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql}";
// Return the queried results.
return (int) $wpdb->get_var( $sql );
}
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.