| 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 = ["error" => ["color" => "red","class" => "wtotem_alert__img_cross", "img" => ""],"info" => ["color" => "","class" => "","img" => ""],"warning" => ["color" => "yellow","class" => "", "img" => '<img src="'.wtsec_getImagePath("alert-warning.svg").'">'],"success" => ["color" => "green","class" => "" ,"img" => '<img src="'.wtsec_getImagePath("alert-success.svg").'">']]; |
| 14 |
|
| 15 |
foreach ($notification_types as $type) { |
| 16 |
if ($notifications = get_option(WTSEC_PLUGIN_PREFIX.$type)) { |
| 17 |
if(is_array($notifications)) { |
| 18 |
foreach ($notifications as $notification) { |
| 19 |
$style = $styles[$type]; |
| 20 |
echo '<div class="wtotem_alert wt_card" id="wtotem_alert" style="margin-bottom:0"> |
| 21 |
<div class="wtotem_alert__desc"> |
| 22 |
<div class="wtotem_alert__img '.$style["class"].'">'.$style["img"].'</div> |
| 23 |
<div class="wtotem_alert__title wtotem_alert__title_'.$style["color"].'">'.WTSEC_LIBRARY_Localization::lmsg('statuses.' . $type).': </div> |
| 24 |
<p class="wtotem_alert__text">'.$notification.'</p> |
| 25 |
</div> |
| 26 |
<div class="wtotem_alert__close" ></div> |
| 27 |
</div>'; |
| 28 |
} |
| 29 |
} |
| 30 |
self::deleteNotification($type); |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
protected static function deleteNotification($name){ |
| 36 |
return delete_option(WTSEC_PLUGIN_PREFIX.$name); |
| 37 |
} |
| 38 |
|
| 39 |
public static function setNotification($type,$value){ |
| 40 |
if($notifications = get_option(WTSEC_PLUGIN_PREFIX.$type)){ |
| 41 |
if(!in_array($value,$notifications)){ |
| 42 |
$notifications[] = $value; |
| 43 |
update_option(WTSEC_PLUGIN_PREFIX.$type,$notifications); |
| 44 |
} |
| 45 |
}else{ |
| 46 |
update_option(WTSEC_PLUGIN_PREFIX.$type,[$value]); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
public static function _set($name, $value){ |
| 51 |
$_SESSION[WTSEC_PLUGIN_PREFIX . $name] = $value; |
| 52 |
} |
| 53 |
|
| 54 |
public static function _get($name){ |
| 55 |
return $_SESSION[WTSEC_PLUGIN_PREFIX . $name]; |
| 56 |
} |
| 57 |
|
| 58 |
} |