PluginProbe
The GDPR Framework By Data443 / 2.1.0
The GDPR Framework By Data443 v2.1.0
2.5.0 2.4.0 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.3 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 All 41 releases
gdpr-framework / src / Admin / AdminNotice.php

AdminNotice.php in The GDPR Framework By Data443 2.1.0, at src/Admin/AdminNotice.php

40 lines 855 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Codelight\GDPR\Admin;
4
5 class AdminNotice
6 {
7 protected $template;
8
9 protected $data;
10
11 /**
12 * AdminNotice constructor.
13 */
14 public function __construct()
15 {
16 if (did_action('admin_notices')) {
17 trigger_error('AdminNotice class called incorrectly - admin_notices action has already ran!', E_USER_ERROR);
18 }
19
20 add_action('admin_notices', [$this, 'render'], 9999);
21 }
22
23 public function add($template, $data = [])
24 {
25 $this->template = $template;
26 $this->data = $data;
27 }
28
29 public function render()
30 {
31 if (!$this->template) {
32 return;
33 }
34
35 echo gdpr('view')->render('admin/notices/header');
36 echo gdpr('view')->render($this->template, $this->data);
37 echo gdpr('view')->render('admin/notices/footer');
38 }
39 }
40