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 / Components / PrivacyPolicy / AdminTabPrivacyPolicy.php

AdminTabPrivacyPolicy.php in The GDPR Framework By Data443 2.1.0, at src/Components/PrivacyPolicy/AdminTabPrivacyPolicy.php

439 lines 15.0 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\Components\PrivacyPolicy;
4
5 use Codelight\GDPR\Admin\AdminTab;
6
7 class AdminTabPrivacyPolicy extends AdminTab
8 {
9 /* @var string */
10 protected $slug = 'privacy-policy';
11
12 /* @var PolicyGenerator */
13 protected $policyGenerator;
14
15 public function __construct(PolicyGenerator $policyGenerator)
16 {
17 $this->policyGenerator = $policyGenerator;
18
19 $this->title = _x('Privacy Policy', '(Admin)', 'gdpr-framework');
20
21 $this->registerSetting('gdpr_company_name');
22 $this->registerSetting('gdpr_contact_email');
23 $this->registerSetting('gdpr_company_location');
24
25 $this->registerSetting('gdpr_representative_contact_name');
26 $this->registerSetting('gdpr_representative_contact_email');
27 $this->registerSetting('gdpr_representative_contact_phone');
28
29 $this->registerSetting('gdpr_dpa_website');
30 $this->registerSetting('gdpr_dpa_email');
31 $this->registerSetting('gdpr_dpa_phone');
32
33 $this->registerSetting('gdpr_has_dpo');
34 $this->registerSetting('gdpr_dpo_name');
35 $this->registerSetting('gdpr_dpo_email');
36 $this->registerSetting('gdpr_delete_text');
37
38 /*
39 $this->registerSetting('gdpr_pp_data_gathered_1');
40 $this->registerSetting('gdpr_pp_data_gathered_2');
41 $this->registerSetting('gdpr_pp_data_gathered_3');
42 $this->registerSetting('gdpr_pp_data_gathered_4');
43
44 $this->registerSetting('gdpr_pp_data_usage_1');
45 $this->registerSetting('gdpr_pp_data_usage_2');
46 $this->registerSetting('gdpr_pp_data_usage_3');
47 $this->registerSetting('gdpr_pp_data_usage_4');
48
49 $this->registerSetting('gdpr_pp_data_partners');
50 */
51
52 add_action('gdpr/admin/action/privacy-policy/generate', [$this, 'generatePolicy']);
53 }
54
55 public function init()
56 {
57 /**
58 * General settings
59 */
60 $this->registerSettingSection(
61 'gdpr_section_privacy_policy',
62 _x('Privacy Policy', '(Admin)', 'gdpr-framework'),
63 [$this, 'renderHeader']
64 );
65
66 /**
67 * Company info
68 */
69 $this->registerSettingSection(
70 'gdpr_section_privacy_policy_company',
71 _x('Company information', '(Admin)', 'gdpr-framework')
72 );
73
74 $this->registerSettingField(
75 'gdpr_company_name',
76 _x('Company Name', '(Admin)', 'gdpr-framework'),
77 [$this, 'renderCompanyNameHtml'],
78 'gdpr_section_privacy_policy_company'
79 );
80
81
82 $this->registerSettingField(
83 'gdpr_company_email',
84 _x('Company Email', '(Admin)', 'gdpr-framework'),
85 [$this, 'renderCompanyEmailHtml'],
86 'gdpr_section_privacy_policy_company'
87 );
88
89 $this->registerSettingField(
90 'gdpr_company_location',
91 _x('Company Location', '(Admin)', 'gdpr-framework'),
92 [$this, 'renderCompanyLocationHtml'],
93 'gdpr_section_privacy_policy_company'
94 );
95
96 /**
97 * Representative
98 */
99 $this->registerSettingSection(
100 'gdpr_section_privacy_policy_representative',
101 false,
102 [$this, 'renderRepresentativeOpen']
103 );
104
105 $this->registerSettingField(
106 'gdpr_representative_contact_name',
107 _x('Representative Contact Name', '(Admin)', 'gdpr-framework'),
108 [$this, 'renderRepresentativeContactName'],
109 'gdpr_section_privacy_policy_representative'
110 );
111
112 $this->registerSettingField(
113 'gdpr_representative_contact_email',
114 _x('Representative Contact Email', '(Admin)', 'gdpr-framework'),
115 [$this, 'renderRepresentativeContactEmail'],
116 'gdpr_section_privacy_policy_representative'
117 );
118
119 $this->registerSettingField(
120 'gdpr_representative_contact_phone',
121 _x('Representative Contact Phone', '(Admin)', 'gdpr-framework'),
122 [$this, 'renderRepresentativeContactPhone'],
123 'gdpr_section_privacy_policy_representative'
124 );
125
126 $this->registerSettingSection(
127 'gdpr_section_privacy_policy_representative_close',
128 false,
129 [$this, 'renderRepresentativeClose']
130 );
131
132 /**
133 * DPA
134 */
135 $this->registerSettingSection(
136 'gdpr_section_privacy_policy_dpa',
137 _x('Data Protection Authority', '(Admin)', 'gdpr-framework'),
138 [$this, 'renderDpaJS']
139 );
140
141 $this->registerSettingField(
142 'gdpr_dpa_website',
143 _x('Data Protection Authority Website', '(Admin)', 'gdpr-framework'),
144 [$this, 'renderDpaWebsite'],
145 'gdpr_section_privacy_policy_dpa'
146 );
147
148 $this->registerSettingField(
149 'gdpr_dpa_email',
150 _x('Data Protection Authority Email', '(Admin)', 'gdpr-framework'),
151 [$this, 'renderDpaEmail'],
152 'gdpr_section_privacy_policy_dpa'
153 );
154
155 $this->registerSettingField(
156 'gdpr_dpa_phone',
157 _x('Data Protection Authority Phone', '(Admin)', 'gdpr-framework'),
158 [$this, 'renderDpaPhone'],
159 'gdpr_section_privacy_policy_dpa'
160 );
161
162 /**
163 * DPO
164 */
165 $this->registerSettingSection(
166 'gdpr_section_privacy_policy_dpo',
167 _x('Data Protection Officer', '(Admin)', 'gdpr-framework'),
168 function() {
169 echo "<a href='https://data443.atlassian.net/servicedesk/customer/portal/2/article/28213359' target='_blank'>";
170 echo _x('Knowledge base: Do I need to appoint a Data Protection Officer?', '(Admin)', 'gdpr-framework');
171 echo "</a>";
172 }
173 );
174
175 $this->registerSettingField(
176 'gdpr_has_dpo',
177 _x('Data Protection Officer', '(Admin)', 'gdpr-framework'),
178 [$this, 'renderHasDPOHtml'],
179 'gdpr_section_privacy_policy_dpo'
180 );
181
182 $this->registerSettingField(
183 'gdpr_dpo_name',
184 _x('Data Protection Officer Name', '(Admin)', 'gdpr-framework'),
185 [$this, 'renderDPONameHtml'],
186 'gdpr_section_privacy_policy_dpo',
187 ['class' => 'gdpr-dpo hidden']
188 );
189
190 $this->registerSettingField(
191 'gdpr_dpo_email',
192 _x('Data Protection Officer Email', '(Admin)', 'gdpr-framework'),
193 [$this, 'renderDPOEmailHtml'],
194 'gdpr_section_privacy_policy_dpo',
195 ['class' => 'gdpr-dpo hidden']
196 );
197
198 /**
199 * Change Delete Text
200 */
201
202 $this->registerSettingField(
203 'gdpr_delete_text',
204 _x('Delete Text', '(Admin)', 'gdpr-framework'),
205 [$this, 'renderDeleteTextHtml'],
206 'gdpr_section_privacy_policy_company'
207 );
208
209 }
210
211 public function renderHeader()
212 {
213 echo gdpr('view')->render('admin/privacy-policy/header');
214 }
215
216 /**
217 * Company info
218 */
219
220 public function renderCompanyNameHtml()
221 {
222 global $gdpr;
223 $value = $gdpr->Options->get('company_name') ? esc_attr($gdpr->Options->get('company_name')) : '';
224 $placeholder = _x('Company Name', '(Admin)', 'gdpr-framework');
225 echo "<input name='gdpr_company_name' placeholder='{$placeholder}' value='{$value}'>";
226 }
227
228 public function renderCompanyEmailHtml()
229 {
230 global $gdpr;
231 $value = $gdpr->Options->get('contact_email') ? esc_attr($gdpr->Options->get('contact_email')) : '';
232 $placeholder = _x('Contact Email', '(Admin)', 'gdpr-framework');
233 echo "<input type='email' name='gdpr_contact_email' placeholder='{$placeholder}' value='{$value}'>";
234 }
235
236 public function renderCompanyLocationHtml()
237 {
238 global $gdpr;
239 $country = $gdpr->Options->get('company_location') ? $gdpr->Options->get('company_location') : '';
240 $countrySelectOptions = gdpr('helpers')->getCountrySelectOptions($country);
241 echo gdpr('view')->render('admin/privacy-policy/company-location', compact('countrySelectOptions'));
242 }
243
244 /**
245 * Representative contact
246 */
247
248 public function renderRepresentativeOpen()
249 {
250 echo "<span class='gdpr-representative hidden'>";
251 echo "<h3>";
252 echo _x('Representative Contact', '(Admin)', 'gdpr-framework');
253 echo "</h3>";
254 echo "<a href='https://data443.atlassian.net/servicedesk/customer/portal/2/article/28082218' target='_blank'>";
255 echo _x('Knowledge base: Do I need to appoint an EU-based representative?', '(Admin)', 'gdpr-framework');
256 echo "</a>";
257 }
258
259 public function renderRepresentativeContactName()
260 {
261 global $gdpr;
262 $value = $gdpr->Options->get('representative_contact_name') ? esc_attr($gdpr->Options->get('representative_contact_name')) : '';
263 $placeholder = _x('Representative Contact Name', '(Admin)', 'gdpr-framework');
264 echo "<input name='gdpr_representative_contact_name' placeholder='{$placeholder}' value='{$value}'>";
265 }
266
267 public function renderRepresentativeContactEmail()
268 {
269 global $gdpr;
270 $value = $gdpr->Options->get('representative_contact_email') ? esc_attr($gdpr->Options->get('representative_contact_email')) : '';
271 $placeholder = _x('Representative Contact Email', '(Admin)', 'gdpr-framework');
272 echo "<input type='email' name='gdpr_representative_contact_email' placeholder='{$placeholder}' value='{$value}'>";
273 }
274
275 public function renderRepresentativeContactPhone()
276 {
277 global $gdpr;
278 $value = $gdpr->Options->get('representative_contact_phone') ? esc_attr($gdpr->Options->get('representative_contact_phone')) : '';
279 $placeholder = _x('Representative Contact Phone', '(Admin)', 'gdpr-framework');
280 echo "<input name='gdpr_representative_contact_phone' placeholder='{$placeholder}' value='{$value}'>";
281 }
282
283 public function renderRepresentativeClose()
284 {
285 echo "</span>";
286 }
287
288 /**
289 * Data Protection Authority
290 */
291 public function renderDpaJS()
292 {
293 //echo "<a href='https://data443.com/wordpress-gdpr-framework/knowledge-base/do-i-need-to-appoint-an-eu-based-representative/' target='_blank'>";
294 echo sprintf(
295 _x('See the %slist of contacts here%s.', '(Admin)', 'gdpr-framework'),
296 '<a href="http://ec.europa.eu/justice/data-protection/article-29/structure/data-protection-authorities/index_en.htm" target="_blank">',
297 '</a>'
298 );
299 //echo "</a>";
300
301 $dpaData = json_encode(gdpr('helpers')->getDataProtectionAuthorities());
302 echo gdpr('view')->render('admin/privacy-policy/dpa', compact('dpaData'));
303 }
304
305 public function renderDpaWebsite()
306 {
307 global $gdpr;
308 $value = $gdpr->Options->get('dpa_website') ? esc_attr($gdpr->Options->get('dpa_website')) : '';
309 $placeholder = _x('Data Protection Authority Website', '(Admin)', 'gdpr-framework');
310 echo "<input name='gdpr_dpa_website' id='gdpr_dpa_website' placeholder='{$placeholder}' value='{$value}' data-set='{$value}'>";
311 }
312
313 public function renderDpaEmail()
314 {
315 global $gdpr;
316 $value = $gdpr->Options->get('dpa_email') ? esc_attr($gdpr->Options->get('dpa_email')) : '';
317 $placeholder = _x('Data Protection Authority Email', '(Admin)', 'gdpr-framework');
318 echo "<input type='email' name='gdpr_dpa_email' id='gdpr_dpa_email' placeholder='{$placeholder}' value='{$value}' data-set='{$value}'>";
319 }
320
321 public function renderDpaPhone()
322 {
323 global $gdpr;
324 $value = $gdpr->Options->get('dpa_phone') ? esc_attr($gdpr->Options->get('dpa_phone')) : '';
325 $placeholder = _x('Data Protection Authority Phone', '(Admin)', 'gdpr-framework');
326 echo "<input name='gdpr_dpa_phone' id='gdpr_dpa_phone' placeholder='{$placeholder}' value='{$value}' data-set='{$value}'>";
327 }
328
329 /**
330 * Data Protection Officer
331 */
332
333 public function renderHasDPOHtml()
334 {
335 global $gdpr;
336 $hasDPO = $gdpr->Options->get('has_dpo');
337 echo gdpr('view')->render('admin/privacy-policy/has-dpo', compact('hasDPO'));
338 }
339
340 public function renderDPONameHtml()
341 {
342 global $gdpr;
343 $value = $gdpr->Options->get('dpo_name') ? esc_attr($gdpr->Options->get('dpo_name')) : '';
344 $placeholder = _x('DPO Name', '(Admin)', 'gdpr-framework');
345 echo "<input name='gdpr_dpo_name' placeholder='{$placeholder}' value='{$value}'>";
346 }
347
348 public function renderDPOEmailHtml()
349 {
350 global $gdpr;
351 $value = $gdpr->Options->get('dpo_email') ? esc_attr($gdpr->Options->get('dpo_email')) : '';
352 $placeholder = _x('DPO Email', '(Admin)', 'gdpr-framework');
353 echo "<input type='email' name='gdpr_dpo_email' placeholder='{$placeholder}' value='{$value}'>";
354 }
355
356 public function renderDeleteTextHtml()
357 {
358 global $gdpr;
359 $value = $gdpr->Options->get('delete_text') ? esc_attr($gdpr->Options->get('delete_text')) : '';
360 $placeholder = _x('Delete Text', '(Admin)', 'gdpr-framework');
361 echo "<input name='gdpr_delete_text' placeholder='{$placeholder}' value='{$value}'>";
362 }
363
364 public function generatePolicy()
365 {
366 global $gdpr;
367 $policyPage = $gdpr->Options->get('policy_page');
368
369 if ( ! $policyPage) {
370 return;
371 }
372
373 $policy = gdpr('view')->render(
374 'policy/policy'
375 );
376
377 wp_update_post([
378 'ID' => $policyPage,
379 'post_content' => $policy,
380 ]);
381
382 wp_safe_redirect(gdpr('helpers')->getAdminUrl('&gdpr-tab=privacy-policy&gdpr_notice=policy_generated'));
383 }
384
385 /**
386 * Render either the settings or the generated policy
387 */
388 public function renderContents()
389 {
390 if (isset($_GET['settings-updated']) && 'true' == $_GET['settings-updated']) {
391 return $this->renderPolicy();
392 } else {
393 return parent::renderContents();
394 }
395 }
396
397 public function renderPolicy()
398 {
399 global $gdpr;
400 $policyPageId = $gdpr->Options->get('policy_page');
401 if ($policyPageId) {
402 $policyUrl = get_edit_post_link($policyPageId);
403 } else {
404 $policyUrl = false;
405 }
406
407 $editor = $this->getPolicyEditor();
408 $backUrl = gdpr('helpers')->getAdminUrl('&gdpr-tab=privacy-policy');
409
410 return gdpr('view')->render('admin/privacy-policy/generated', compact('editor', 'policyUrl', 'backUrl'));
411 }
412
413 protected function getPolicyEditor()
414 {
415 ob_start();
416
417 wp_editor(
418 wp_kses_post($this->policyGenerator->generate()),
419 'gdpr_policy',
420 [
421 'media_buttons' => false,
422 'editor_height' => 600,
423 'teeny' => true,
424 'editor_css' => '<style>#mceu_16 { display: none; }</style>'
425 ]
426 );
427
428 return ob_get_clean();
429 }
430
431 /**
432 * Render WP's default submit button
433 */
434 public function renderSubmitButton()
435 {
436 submit_button(_x('Save & Generate Policy', '(Admin)', 'gdpr-framework'));
437 }
438 }
439