| 1 |
<?php defined('ABSPATH') or die("Protected By WT!"); |
| 2 |
|
| 3 |
|
| 4 |
class WTSEC_LIBRARY_Session |
| 5 |
{ |
| 6 |
public static function notifications() |
| 7 |
{ |
| 8 |
$notification_types = [ |
| 9 |
"error","info","warning","success" |
| 10 |
]; |
| 11 |
|
| 12 |
//need upgrade code style |
| 13 |
$styles = [ |
| 14 |
"error" => ["color" => "red","class" => "wtotem_alert__img_cross", "img" => ""], |
| 15 |
"info" => ["color" => "","class" => "","img" => ""], |
| 16 |
"warning" => ["color" => "yellow","class" => "", "img" => '<img src="'.wtsec_getImagePath("alert-warning.svg").'">'], |
| 17 |
"success" => ["color" => "green","class" => "" ,"img" => '<img src="'.wtsec_getImagePath("alert-success.svg").'">'] |
| 18 |
]; |
| 19 |
$statuses = wtsec_getStatuses(); |
| 20 |
|
| 21 |
foreach ($notification_types as $type) { |
| 22 |
if ($notifications = get_option(WTSEC_PLUGIN_PREFIX.$type)) { |
| 23 |
if(is_array($notifications)) { |
| 24 |
foreach ($notifications as $notification) { |
| 25 |
$style = $styles[$type]; |
| 26 |
echo '<div class="wtotem_alert wt_card" id="wtotem_alert" style="margin-bottom:0"> |
| 27 |
<div class="wtotem_alert__desc"> |
| 28 |
<div class="wtotem_alert__img '.$style["class"].'">'.$style["img"].'</div> |
| 29 |
<div class="wtotem_alert__title wtotem_alert__title_'.$style["color"].'">'.$statuses[$type].': </div> |
| 30 |
<p class="wtotem_alert__text">'.$notification.'</p> |
| 31 |
</div> |
| 32 |
<div class="wtotem_alert__close" ></div> |
| 33 |
</div>'; |
| 34 |
} |
| 35 |
} |
| 36 |
self::deleteNotification($type); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
protected static function deleteNotification($name){ |
| 42 |
return delete_option(WTSEC_PLUGIN_PREFIX.$name); |
| 43 |
} |
| 44 |
|
| 45 |
public static function setNotification($type,$value){ |
| 46 |
if($notifications = get_option(WTSEC_PLUGIN_PREFIX.$type)){ |
| 47 |
if(!in_array($value,$notifications)){ |
| 48 |
$notifications[] = $value; |
| 49 |
update_option(WTSEC_PLUGIN_PREFIX.$type,$notifications); |
| 50 |
} |
| 51 |
}else{ |
| 52 |
update_option(WTSEC_PLUGIN_PREFIX.$type,[$value]); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
public static function _set($name, $value){ |
| 57 |
$_SESSION[WTSEC_PLUGIN_PREFIX . $name] = $value; |
| 58 |
} |
| 59 |
|
| 60 |
public static function _get($name){ |
| 61 |
return $_SESSION[WTSEC_PLUGIN_PREFIX . $name]; |
| 62 |
} |
| 63 |
|
| 64 |
} |