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 +19 -8 10.10.2 → 11.1.0 View file →
@@ -1,8 +1,14 @@
1 1 <?php
2 2
3 +defined('ABSPATH') || die('Restricted Access');
4 +
3 5 use AcyMailing\Helpers\HeaderHelper;
4 6
7 +/**
8 + * @param array|string $message The message to display
9 + * @param string $type The type (success, error, warning, info, message, notice)
10 + */
5 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;
@@ -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();
@@ -65,12 +74,14 @@
65 74
66 75 function acym_displayMessages(): void
67 76 {
68 77 $types = ['success', 'info', 'warning', 'error'];
69 - acym_session();
70 78 foreach ($types as $type) {
71 - if (empty($_SESSION['acymessage'.$type])) continue;
79 + $messages = acym_getVar('array', 'acymessage'.$type, [], 'SESSION', ACYM_ALLOWHTML);
80 + if (empty($messages)) {
81 + continue;
82 + }
72 83
73 - acym_display($_SESSION['acymessage'.$type], $type);
74 - unset($_SESSION['acymessage'.$type]);
84 + acym_display($messages, $type);
85 + acym_setSession('acymessage'.$type, null, true);
75 86 }
76 87 }