PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 1.9.4
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v1.9.4
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / inc / class-berqnotifications.php

class-berqnotifications.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 1.9.4, at inc/class-berqnotifications.php

63 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class berqNotifications {
4 // public $notices = [];
5
6 function __construct() {
7 add_action('admin_notices', [$this, 'notification']);
8 add_action('init', [$this, 'session']);
9 }
10
11 function session() {
12 if (is_admin()) {
13 session_start();
14 }
15 }
16
17 function notification() {
18
19 if (empty($_SESSION['berqwp_user_notice'])) {
20 return;
21 }
22
23 $notices = $_SESSION['berqwp_user_notice'];
24
25
26 if (!empty($notices)) {
27 foreach($notices as $notice) {
28 $msg = $notice[1];
29 $class = $notice[0];
30
31 $notice = '<div class="notice notice-'.$class.' is-dismissible">';
32 $notice .= '<p>';
33 $notice .= __($msg, 'searchpro');
34 $notice .= '</p>';
35 $notice .= '</div>';
36 echo wp_kses_post($notice);
37
38 }
39
40 $_SESSION['berqwp_user_notice'] = [];
41 }
42
43 }
44
45 function notice($text) {
46 $_SESSION['berqwp_user_notice'][] = ['info', $text];
47 }
48
49 function error($text) {
50 $_SESSION['berqwp_user_notice'][] = ['error', $text];
51 }
52
53 function warning($text) {
54 $_SESSION['berqwp_user_notice'][] = ['warning', $text];
55 }
56
57 function success($text) {
58 $_SESSION['berqwp_user_notice'][] = ['success', $text];
59 }
60 }
61
62 global $berqNotifications;
63 $berqNotifications = new berqNotifications();