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 / Installer / InstallerStep.php

InstallerStep.php in The GDPR Framework By Data443 2.1.0, at src/Installer/InstallerStep.php

203 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Codelight\GDPR\Installer;
4
5 /**
6 * Handle the plumbing of an installer step
7 *
8 * Class InstallerStep
9 *
10 * @package Codelight\GDPR\Installer
11 */
12 abstract class InstallerStep
13 {
14 /* @var string */
15 protected $stepType;
16
17 /* @var string */
18 protected $slug;
19
20 /* @var string */
21 protected $type;
22
23 /* @var string */
24 protected $template;
25
26 /* @var int */
27 protected $activeSteps;
28
29 /**
30 * Render a step for viewing
31 */
32 public function run()
33 {
34 $this->enqueue();
35 $this->renderHeader();
36 $this->renderContent();
37 $this->renderNonce();
38 $this->renderFooter();
39 }
40
41 /**
42 * Validate the form submission
43 *
44 * @return bool
45 */
46 public function validate()
47 {
48 return true;
49 }
50
51 /**
52 * Validate the nonce
53 *
54 * @return bool
55 */
56 public function validateNonce()
57 {
58 return isset($_POST['gdpr_nonce']) && wp_verify_nonce($_POST['gdpr_nonce'], $this->slug);
59 }
60
61 /**
62 * Process the form submission
63 */
64 public function submit()
65 {
66
67 }
68
69
70 /**
71 * Display error notice or something
72 */
73 public function getErrors()
74 {
75 return $this->errors;
76 }
77
78 /**
79 * Register WP's default assets and plugin installer assets
80 */
81 protected function enqueue()
82 {
83 global $gdpr;
84 wp_enqueue_style('common');
85 wp_enqueue_style('buttons');
86
87 /**
88 * GDPR installer custom styles
89 */
90 wp_enqueue_style(
91 'gdpr-installer',
92 $gdpr->PluginUrl . 'assets/gdpr-installer.css'
93 );
94
95 wp_enqueue_style(
96 'select2css',
97 $gdpr->PluginUrl . 'assets/select2-4.0.5.css'
98 );
99
100 wp_enqueue_script('jquery');
101 wp_enqueue_script('jquery-ui-core');
102 wp_enqueue_script('jquery-ui-widget');
103 wp_enqueue_script('jquery-ui-mouse');
104 wp_enqueue_script('jquery-ui-sortable');
105 wp_enqueue_script('jquery-ui-tabs');
106 wp_enqueue_script(
107 'select2',
108 $gdpr->PluginUrl . 'assets/select2-4.0.3.js',
109 ['jquery']
110 );
111 wp_enqueue_script(
112 'conditional-show',
113 $gdpr->PluginUrl . 'assets/conditional-show.js',
114 ['jquery']
115 );
116
117 //global $wp_scripts;
118 //$ui = $wp_scripts->query('jquery-ui-core');
119 //wp_enqueue_style('jquery-ui-smoothness', "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.min.css", false, null);
120
121 wp_enqueue_script(
122 'jquery-repeater',
123 $gdpr->PluginUrl . 'assets/jquery.repeater.min.js',
124 ['jquery']
125 );
126
127 /**
128 * Installer javascript
129 */
130 wp_enqueue_script(
131 'gdpr-installer',
132 $gdpr->PluginUrl . 'assets/gdpr-installer.js',
133 ['jquery', 'select2']
134 );
135 }
136
137 /**
138 * Render the installer page header - html head, form, logo
139 */
140 protected function renderHeader()
141 {
142 echo gdpr('view')->render('installer/header', ['activeSteps' => $this->activeSteps]);
143 }
144
145 /**
146 * Render the installer page content - should be overridden by child class
147 */
148 protected function renderContent()
149 {
150 echo gdpr('view')->render($this->template);
151 }
152
153 /**
154 * Create and render the nonce based on the name of the current step
155 */
156 protected function renderNonce()
157 {
158 $nonce = wp_create_nonce($this->slug);
159 echo gdpr('view')->render('installer/nonce', compact('nonce'));
160 }
161
162 /**
163 * Render the footer - nav buttons and closing tags
164 */
165 protected function renderFooter()
166 {
167 echo gdpr('view')->render('installer/footer');
168 }
169
170 /**
171 * @return string
172 */
173 public function getUrl()
174 {
175 global $gdpr;
176 return $gdpr->InstallerWizardUrl . $this->slug;
177 }
178
179 /**
180 * @return string
181 */
182 public function getSlug()
183 {
184 if (is_null($this->slug)) {
185 trigger_error("GDPR: Slug not defined for step!", E_USER_ERROR);
186 }
187
188 return $this->slug;
189 }
190
191 /**
192 * @return string
193 */
194 public function getType()
195 {
196 if (is_null($this->type)) {
197 trigger_error("GDPR: Type not defined for step {$this->slug}", E_USER_ERROR);
198 }
199
200 return $this->type;
201 }
202 }
203