PluginProbe
Age Gate / 3.7.3
Age Gate v3.7.3
3.7.3 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 All 113 releases
age-gate / src / Admin / Controller / MessageController.php

MessageController.php in Age Gate 3.7.3, at src/Admin/Controller/MessageController.php

90 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AgeGate\Admin\Controller;
4
5 use Asylum\Utility\Arr;
6 use AgeGate\Admin\Settings\Message;
7 use League\HTMLToMarkdown\HtmlConverter;
8 use AgeGate\Common\Admin\AbstractController;
9 use AgeGate\Common\Immutable\Constants as Immutable;
10
11 class MessageController extends AbstractController
12 {
13 use Message;
14 // const PERMISSION = Constants::RESTRICTIONS;
15 public const PERMISSION = Immutable::MESSAGES;
16 public const OPTION = Immutable::OPTION_MESSAGE;
17
18 protected function required(): bool
19 {
20 return current_user_can(self::PERMISSION);
21 }
22
23 public function register(): void
24 {
25 $this->menu(__('Messages', 'age-gate'), self::PERMISSION);
26 }
27
28 protected function data(): array
29 {
30 return Arr::dot(get_option(self::OPTION, []) ?: []);
31 }
32
33 protected function fields(): array
34 {
35 return $this->getMessageFields();
36 }
37
38 public function enqueue(): void
39 {
40 }
41
42 protected function store()
43 {
44 $_POST['ag_settings'] = wp_unslash($this->sanitizeHtml($_POST['ag_settings']));
45
46 parent::store();
47 }
48
49 protected function sanitizeHtml($array)
50 {
51 $converter = new HtmlConverter();
52 foreach ($array ?? [] as $key => $setting) {
53
54 if (is_array($setting)) {
55 $array[$key] = $this->sanitizeHtml($setting);
56 } else {
57
58 $array[$key] = $converter->convert(html_entity_decode($setting));
59 }
60
61 }
62
63 return $array;
64 }
65
66 protected function rules() : array
67 {
68 return [
69 // 'headline' => 'ag_message',
70 // 'subheadline' => 'ag_message',
71 // 'label_remember' => 'alpha_numeric_space',
72 // 'label_aria' => 'ag_message',
73 // 'label_buttons' => 'ag_message',
74 // 'label_yes' => 'alpha_numeric_space',
75 // 'label_no' => 'alpha_numeric_space',
76 // 'label_day' => 'alpha_numeric_space',
77 // 'label_month' => 'alpha_numeric_space',
78 // 'label_year' => 'alpha_numeric_space',
79 // 'placeholder_day' => 'alpha_numeric_space',
80 // 'placeholder_month' => 'alpha_numeric_space',
81 // 'placeholder_year' => 'alpha_numeric_space',
82 // 'label_submit' => 'alpha_numeric_space',
83 // 'label_no_cookies' => 'ag_message',
84 // 'error_invalid' => 'ag_message_md',
85 // 'error_failed' => 'ag_message_md',
86 // 'error_generic' => 'ag_message_md',
87 ];
88 }
89 }
90