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 / AppearanceController.php

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

82 lines 2.2 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 AgeGate\Common\Immutable\Constants as Immutable;
6 use AgeGate\Admin\Settings\Appearance;
7 use AgeGate\Common\Admin\AbstractController;
8
9 class AppearanceController extends AbstractController
10 {
11 use Appearance;
12
13 // const PERMISSION = Constants::RESTRICTIONS;
14 public const PERMISSION = Immutable::APPEARANCE;
15 public const OPTION = Immutable::OPTION_APPEARANCE;
16
17 public function register(): void
18 {
19 $this->menu(__('Appearance', 'age-gate'), self::PERMISSION);
20 }
21
22 protected function required(): bool
23 {
24 return current_user_can(self::PERMISSION);
25 }
26
27 protected function data(): array
28 {
29 return get_option(self::OPTION, []) ?: [];
30 }
31
32 protected function fields(): array
33 {
34 return $this->getAppearanceFields();
35 }
36
37 public function store()
38 {
39 $fields = $this->getAppearanceFields();
40
41 $f = [
42 'heading_element',
43 'headline_element',
44 'sub_headline_element',
45 'exit_transition',
46 ];
47
48 foreach ($f as $field) {
49 if (!array_key_exists($_POST['ag_settings'][$field], $fields[0]['fields'][$field]['options'])) {
50 $_POST['ag_settings'][$field] = $fields[0]['fields'][$field]['default'];
51 }
52 }
53
54
55 parent::store();
56 }
57
58 protected function rules() : array
59 {
60 return [
61 'logo' => 'numeric',
62 'background_color' => 'ag_hex',
63 'background_opacity' => 'float',
64 'blur' => 'numeric',
65 'background_image' => 'numeric',
66 'background_position.y' => 'alpha',
67 'background_position.x' => 'alpha',
68 'background_image_opacity' => 'float',
69 'foreground_color' => 'ag_hex',
70 'foreground_opacity' => 'float',
71 'text_color' => 'ag_hex',
72 'enqueue_css' => 'boolean',
73 'exit_transition' => 'alpha_dash',
74 'viewport' => 'boolean',
75 'input_auto_tab' => 'boolean',
76 'switch_title' => 'boolean',
77 'simplebar' => 'boolean',
78 // 'custom_title' => 'ag_message',
79 ];
80 }
81 }
82