public function mark_notification_as_read() { if (isset($_GET['ap_notification_read'])) { $id = (int) $_GET['ap_notification_read']; $notification = ap_get_notification_by_id($id); if ($notification && $notification['apmeta_actionid'] == get_current_user_id()) { $row = ap_notification_mark_as_read($id); } } }
/** * Handle ajax callback for mark all notification as read */ public function set_notifications_as_read() { $ids = sanitize_text_field($_POST['ids']); $ids = explode(',', $ids); if (count($ids) == 0) { wp_die(); } if (!ap_verify_default_nonce() && !is_user_logged_in()) { wp_die(); } foreach ($ids as $id) { $id = (int) $id; if (0 != $id) { ap_notification_mark_as_read($id, get_current_user_id()); } } $this->send(array('container' => '#ap-notification-dropdown', 'view' => array('notification_count' => ap_get_total_unread_notification()))); wp_die(); }