bpln_process_notification_request

Filter on the heartbeat recieved data and inject the new notifications data.

Description

bpln_process_notification_request( (type) $response, (type) $data, (type) $screen_id ); 

Parameters (3)

0. $response (type)
The response.
1. $data (type)
The data.
2. $screen_id (type)
The screen id.

Usage

  1. if ( !function_exists( 'bpln_process_notification_request' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-live-notification/ajax.php'; 
  3.  
  4. // The response. 
  5. $response = null; 
  6.  
  7. // The data. 
  8. $data = null; 
  9.  
  10. // The screen id. 
  11. $screen_id = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bpln_process_notification_request($response, $data, $screen_id); 
  15.  

Defined (1)

The function is defined in the following location(s).

/ajax.php  
  1. function bpln_process_notification_request( $response, $data, $screen_id ) { 
  2.  
  3.  
  4. if ( isset( $data['bpln-data'] ) ) { 
  5.  
  6. $notifications = array(); 
  7. $notification_ids = array(); 
  8.  
  9. $request = $data['bpln-data']; 
  10.  
  11. $last_notified_id = absint( $request['last_notified'] ); 
  12.  
  13. if ( ! empty( $request ) ) { 
  14.  
  15. $notifications = bpln_get_new_notifications( get_current_user_id(), $last_notified_id ); 
  16.  
  17. $notification_ids = wp_list_pluck( $notifications, 'id' ); 
  18.  
  19. $notifications = bpln_get_notification_messages( $notifications ); 
  20.  
  21. //include our last notified id to the list 
  22. $notification_ids[] = $last_notified_id; 
  23. //find the max id that we are sending with this request 
  24. $last_notified_id = max( $notification_ids ); 
  25.  
  26. $response['bpln-data'] = array( 'messages' => $notifications, 'last_notified' => $last_notified_id ); 
  27.  
  28.  
  29. return $response;