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 / Presentation / Template.php

Template.php in Age Gate 3.7.3, at src/Presentation/Template.php

128 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AgeGate\Presentation;
4
5 use AgeGate\Utility\Facades\View;
6
7 class Template
8 {
9 public function __construct()
10 {
11 add_action('age_gate/form', [$this, 'form'], 10);
12 add_action('age_gate/form/open', [$this, 'open'], 0);
13 add_action('age_gate/form/close', [$this, 'close'], PHP_INT_MAX);
14 add_action('age_gate/fields', [$this, 'hidden'], 11);
15
16 if (has_action('age_gate/custom/after')) {
17 add_action('age_gate/custom/after', [$this, 'extraWrapperOpen'], 0);
18 add_action('age_gate/custom/after', [$this, 'extraWrapperClose'], PHP_INT_MAX);
19 }
20
21 if (has_action('age_gate/custom/before')) {
22 add_action('age_gate/custom/before', [$this, 'extraWrapperOpen'], 0);
23 add_action('age_gate/custom/before', [$this, 'extraWrapperClose'], PHP_INT_MAX);
24 }
25
26 // template functions
27 add_action('age_gate/logo', 'age_gate_template_logo');
28 add_action('age_gate/headline', 'age_gate_template_headline');
29 add_action('age_gate/subheadline', 'age_gate_template_subheadline');
30 add_action('age_gate/fields', 'age_gate_template_fields');
31 add_action('age_gate/errors', 'age_gate_template_errors', 20);
32 add_action('age_gate/submit', 'age_gate_template_submit');
33 add_action('age_gate/additional', 'age_gate_template_additional');
34
35 add_action('age_gate/remember', 'age_gate_template_remember', 15);
36 add_action('age_gate/fields/age_field', 'age_gate_template_age_field');
37 add_action('age_gate/form/background', [$this, 'renderVideo']);
38 }
39
40 public function open()
41 {
42 View::render('partials/form/open');
43 }
44
45 public function close()
46 {
47 View::render('partials/form/close');
48 }
49
50 public function form()
51 {
52 View::render('theme::partials/age-gate-form');
53 }
54
55 public function hidden()
56 {
57 View::render('partials/form/fields/hidden');
58 }
59
60 public static function logo()
61 {
62 View::render('theme::partials/decoration/logo');
63 }
64
65 public static function headline()
66 {
67 View::render('theme::partials/decoration/headline');
68 }
69
70 public static function subheadline()
71 {
72 View::render('theme::partials/decoration/subheadline');
73 }
74
75 public static function submit()
76 {
77 View::render('theme::partials/form/submit');
78 }
79
80 public static function additional()
81 {
82 View::render('theme::partials/decoration/content');
83 }
84
85 public static function fields($fields)
86 {
87 View::render('theme::partials/form/sections/' . $fields);
88 }
89
90 public static function remember()
91 {
92 View::render('theme::partials/form/sections/remember');
93 }
94
95 public static function age()
96 {
97 View::render('theme::partials/form/fields/age');
98 }
99
100 public function rta()
101 {
102 View::render('partials/meta/rta');
103 }
104
105 public static function errors()
106 {
107 View::render('partials/form/errors');
108 }
109
110 public function extraWrapperOpen()
111 {
112 View::render('partials/form/open-extra');
113 }
114
115 public function extraWrapperClose()
116 {
117 echo '</div>';
118 }
119
120 public function renderVideo($file)
121 {
122 $type = wp_check_filetype($file);
123 if (strpos(($type['type'] ?? ''), 'video') !== false) {
124 echo sprintf('<video src="%s" loop muted playsinline autoplay></video>', esc_attr($file));
125 }
126 }
127 }
128