| @@ -8,8 +8,10 @@ | ||
| 8 | 8 | trait Subscription |
| 9 | 9 | { |
| 10 | 10 | public function removeNotification(): void |
| 11 | 11 | { |
| 12 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 13 | + | |
| 12 | 14 | $whichNotification = acym_getVar('string', 'id'); |
| 13 | 15 | |
| 14 | 16 | if ($whichNotification !== '0' && empty($whichNotification)) { |
| 15 | 17 | acym_sendAjaxResponse(acym_translation('ACYM_NOTIFICATION_NOT_FOUND'), [], false); |
| @@ -32,9 +34,9 @@ | ||
| 32 | 34 | |
| 33 | 35 | $this->config->saveConfig(['notifications' => json_encode($notifications)]); |
| 34 | 36 | $this->config->saveConfig(['dashboard_notif' => json_encode($dashboardNotifications)], false); |
| 35 | 37 | |
| 36 | - $helperHeader = new HeaderHelper(); | |
| 38 | + $headerHelper = new HeaderHelper(); | |
| 37 | 39 | $dashboardController = new DashboardController(); |
| 38 | 40 | |
| 39 | 41 | $data = [ |
| 40 | 42 | 'notifications' => $dashboardNotifications, |
| @@ -40,13 +42,18 @@ | ||
| 40 | 42 | 'notifications' => $dashboardNotifications, |
| 41 | 43 | ]; |
| 42 | 44 | $dashboardController->getDashboardNotifications($data); |
| 43 | 45 | |
| 46 | + | |
| 47 | + ob_start(); | |
| 48 | + $headerHelper->displayNotificationCenterInner($notifications); | |
| 49 | + $notificationCenter = ob_get_clean(); | |
| 50 | + | |
| 44 | 51 | acym_sendAjaxResponse( |
| 45 | 52 | '', |
| 46 | 53 | [ |
| 47 | - 'headerHtml' => $helperHeader->getNotificationCenterInner($notifications), | |
| 48 | - 'dashboardHtml' => $data['dashboardNotifications'], | |
| 54 | + 'headerHtml' => $notificationCenter, | |
| 55 | + 'dashboardNotifications' => $data['dashboardNotifications'], | |
| 49 | 56 | ] |
| 50 | 57 | ); |
| 51 | 58 | } |
| 52 | 59 | |
| @@ -51,8 +58,10 @@ | ||
| 51 | 58 | } |
| 52 | 59 | |
| 53 | 60 | public function markNotificationRead(): void |
| 54 | 61 | { |
| 62 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 63 | + | |
| 55 | 64 | $which = acym_getVar('string', 'id'); |
| 56 | 65 | |
| 57 | 66 | $notifications = json_decode($this->config->get('notifications', '[]'), true); |
| 58 | 67 | if (empty($notifications)) { |
| @@ -77,8 +86,10 @@ | ||
| 77 | 86 | } |
| 78 | 87 | |
| 79 | 88 | public function addNotification(): void |
| 80 | 89 | { |
| 90 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 91 | + | |
| 81 | 92 | $message = acym_getVar('string', 'message'); |
| 82 | 93 | $level = acym_getVar('string', 'level'); |
| 83 | 94 | |
| 84 | 95 | if (empty($message) || empty($level)) { |
| @@ -84,9 +95,9 @@ | ||
| 84 | 95 | if (empty($message) || empty($level)) { |
| 85 | 96 | acym_sendAjaxResponse(acym_translation('ACYM_ERROR'), [], false); |
| 86 | 97 | } |
| 87 | 98 | |
| 88 | - $helperHeader = new HeaderHelper(); | |
| 99 | + $headerHelper = new HeaderHelper(); | |
| 89 | 100 | |
| 90 | 101 | $newNotification = new \stdClass(); |
| 91 | 102 | $newNotification->message = $message; |
| 92 | 103 | $newNotification->level = $level; |
| @@ -92,11 +103,15 @@ | ||
| 92 | 103 | $newNotification->level = $level; |
| 93 | 104 | $newNotification->read = false; |
| 94 | 105 | $newNotification->date = time(); |
| 95 | 106 | |
| 96 | - $helperHeader->addNotification($newNotification); | |
| 107 | + $headerHelper->addNotification($newNotification); | |
| 97 | 108 | |
| 98 | - acym_sendAjaxResponse('', ['notificationCenter' => $helperHeader->getNotificationCenter()]); | |
| 109 | + ob_start(); | |
| 110 | + $headerHelper->displayNotificationCenter(); | |
| 111 | + $notificationCenter = ob_get_clean(); | |
| 112 | + | |
| 113 | + acym_sendAjaxResponse('', ['notificationCenter' => $notificationCenter]); | |
| 99 | 114 | } |
| 100 | 115 | |
| 101 | 116 | private function loadSurveyAnswers(array &$data): void |
| 102 | 117 | { |