Notifications::get_notifications()
Description #
Ajax callback for loading user notifications dropdown.
Source #
File: addons/notifications/notifications.php
public function get_notifications() { if ( ! is_user_logged_in() ) { wp_die(); } $notifications = new \AnsPress\Notifications( array( 'user_id' => get_current_user_id() ) ); $items = array(); while ( $notifications->have() ) : $notifications->the_notification(); $items[] = array( 'ID' => $notifications->object->noti_id, 'verb' => $notifications->object->noti_verb, 'verb_label' => $notifications->get_verb(), 'icon' => $notifications->get_icon(), 'avatar' => $notifications->actor_avatar(), 'hide_actor' => $notifications->hide_actor(), 'actor' => $notifications->get_actor(), 'ref_title' => $notifications->get_ref_title(), 'ref_type' => $notifications->object->noti_ref_type, 'points' => $notifications->get_reputation_points(), 'date' => ap_human_time( $notifications->get_date(), false ), 'permalink' => $notifications->get_permalink(), 'seen' => $notifications->object->noti_seen, ); endwhile; ap_ajax_json( array( 'success' => true, 'notifications' => $items, 'total' => ap_count_unseen_notifications(), 'mark_args' => array( 'ap_ajax_action' => 'mark_notifications_seen', '__nonce' => wp_create_nonce( 'mark_notifications_seen' ), ), ) ); }
Expand full source code Collapse full source code View on GitHub: addons/notifications/notifications.php:568
Add your comment