# acymailing/10.1.4/back/Core/wordpress/message.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 10.1.4. 50 lines.

- Page: https://pluginprobe.com/plugins/acymailing/10.1.4/code/back/Core/wordpress/message.php
- Raw: https://pluginprobe.com/plugins/acymailing/10.1.4/raw/back/Core/wordpress/message.php
- Modified: 2025-01-27T11:09:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/10.1.4/code/back/Core/wordpress/message.php#L10-L20`.

```php
<?php

use AcyMailing\Helpers\HeaderHelper;

function acym_enqueueMessage($message, $type = 'success', $addNotification = true)
{
    $type = str_replace(['notice', 'message'], ['info', 'success'], $type);
    $message = is_array($message) ? implode('<br/>', $message) : $message;

    $notification = new stdClass();
    $notification->message = $message;
    $notification->date = time();
    $notification->read = false;
    $notification->level = $type;

    $handledTypes = ['info', 'warning', 'error'];

    if ($addNotification && acym_isAdmin()) {
        $helperHeader = new HeaderHelper();
        $notification->id = $helperHeader->addNotification($notification);
    } else {
        $handledTypes[] = 'success';
    }

    if (in_array($type, $handledTypes)) {
        acym_session();
        if (empty($_SESSION['acymessage'.$type]) || !in_array($message, $_SESSION['acymessage'.$type])) {
            if (empty($notification->id)) {
                $_SESSION['acymessage'.$type][] = $message;
            } else {
                $_SESSION['acymessage'.$type][$notification->id] = $message;
            }
        }
    }

    return true;
}

function acym_displayMessages()
{
    $types = ['success', 'info', 'warning', 'error'];
    acym_session();
    foreach ($types as $type) {
        if (empty($_SESSION['acymessage'.$type])) continue;

        acym_display($_SESSION['acymessage'.$type], $type);
        unset($_SESSION['acymessage'.$type]);
    }
}

```
