adding the cookie content in a concatenated string to update and show cookie when content is changed

This commit is contained in:
Antoine M 2024-08-07 16:49:09 +02:00
parent 1d6a6e192b
commit 3adcc7e578

View File

@ -15,13 +15,13 @@ $notifications = get_field('notifications', 'option');
<?php if ($notifications) : ?>
<?php foreach ($notifications as $notification) : ?>
<?php
$notification_id = 'homegrade_notification_' . md5($notification['title']);
$notification_id = 'homegrade_notification_' . md5($notification['title'] . $notification['content']);
$cookie_already_hidden = isset($_COOKIE[$notification_id]) && $_COOKIE[$notification_id] === 'dismissed';
$notificationType = $notification['type'] ?? 'info';
if (!isset($_COOKIE[$notification_id])) {
// setcookie($notification_id, "visible", time() + (86400 * 30), "/"); // 86400 = 1 day
setcookie($notification_id, "visible", time() + 30, "/"); // 30 seconds
setcookie($notification_id, "visible", time() + (86400 * 30), "/");
}
?>