/** * Handle ajax callback for delete notification */ public function delete_notification() { if (!ap_verify_nonce('delete_notification') && !is_user_logged_in()) { $this->something_wrong(); } $notification = ap_get_notification_by_id((int) $_POST['id']); if ($notification && (get_current_user_id() == $notification->noti_user_id || is_super_admin())) { $row = ap_delete_notification($notification->noti_id); if (false !== $row) { $this->send(array('message' => 'delete_notification', 'action' => 'delete_notification', 'container' => '#ap-notification-' . $notification->noti_id)); } } $this->something_wrong(); }
public function delete_notification() { if (!wp_verify_nonce($_POST['__nonce'], 'delete_notification') && !is_user_logged_in()) { ap_send_json(ap_ajax_responce('something_wrong')); return; } $notification = ap_get_notification_by_id((int) $_POST['id']); if ($notification && ($notification['apmeta_userid'] == get_current_user_id() || is_super_admin())) { $row = ap_delete_notification($notification['apmeta_id']); if ($row !== false) { ap_send_json(ap_ajax_responce(array('message' => 'delete_notification', 'action' => 'delete_notification', 'container' => '#ap-notification-' . $notification['apmeta_id']))); } } //if process reached here then there must be something wrong ap_send_json(ap_ajax_responce('something_wrong')); }