PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Core/wordpress/message.php +22 -13 10.2.2 → 11.1.0 View file →
@@ -1,9 +1,15 @@
1 1 <?php
2 2
3 +defined('ABSPATH') || die('Restricted Access');
4 +
3 5 use AcyMailing\Helpers\HeaderHelper;
4 6
5 -function acym_enqueueMessage($message, string $type = 'success', bool $addNotification = true, array $addDashboardNotification = [], bool $addHeaderNotification = true)
7 +/**
8 + * @param array|string $message The message to display
9 + * @param string $type The type (success, error, warning, info, message, notice)
10 + */
11 +function acym_enqueueMessage($message, string $type = 'success', bool $addNotification = true, array $addDashboardNotification = [], bool $addHeaderNotification = true): void
6 12 {
7 13 $type = str_replace(['notice', 'message'], ['info', 'success'], $type);
8 14 $message = is_array($message) ? implode('<br/>', $message) : $message;
9 15
@@ -22,16 +28,19 @@
22 28 $handledTypes[] = 'success';
23 29 }
24 30
25 31 if (in_array($type, $handledTypes) && $addHeaderNotification) {
26 - acym_session();
27 - if (empty($_SESSION['acymessage'.$type]) || !in_array($message, $_SESSION['acymessage'.$type])) {
32 + $messages = acym_getVar('array', 'acymessage'.$type, [], 'SESSION', ACYM_ALLOWHTML);
33 +
34 + if (empty($messages) || !in_array($message, $messages)) {
28 35 if (empty($notification->id)) {
29 - $_SESSION['acymessage'.$type][] = $message;
36 + $messages[] = $message;
30 37 } else {
31 - $_SESSION['acymessage'.$type][$notification->id] = $message;
38 + $messages[$notification->id] = $message;
32 39 }
33 40 }
41 +
42 + acym_setSession('acymessage'.$type, $messages);
34 43 }
35 44
36 45 if (!empty($addDashboardNotification)) {
37 46 $config = acym_config();
@@ -58,21 +67,21 @@
58 67 $existingNotifications[] = $dashboardNotification;
59 68 }
60 69 }
61 70
62 - $config->save(['dashboard_notif' => json_encode($existingNotifications)], false);
71 + $config->saveConfig(['dashboard_notif' => json_encode($existingNotifications)], false);
63 72 }
64 -
65 - return true;
66 73 }
67 74
68 -function acym_displayMessages()
75 +function acym_displayMessages(): void
69 76 {
70 77 $types = ['success', 'info', 'warning', 'error'];
71 - acym_session();
72 78 foreach ($types as $type) {
73 - if (empty($_SESSION['acymessage'.$type])) continue;
79 + $messages = acym_getVar('array', 'acymessage'.$type, [], 'SESSION', ACYM_ALLOWHTML);
80 + if (empty($messages)) {
81 + continue;
82 + }
74 83
75 - acym_display($_SESSION['acymessage'.$type], $type);
76 - unset($_SESSION['acymessage'.$type]);
84 + acym_display($messages, $type);
85 + acym_setSession('acymessage'.$type, null, true);
77 86 }
78 87 }