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

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

97 lines 3.2 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 /**
6 * Handles putting together and rendering the privacy policy page
7 *
8 * Class PrivacyPolicy
9 *
10 * @package Codelight\GDPR\Components\PrivacyPolicy
11 */
12 class PrivacyPolicy
13 {
14 public function __construct()
15 {
16 add_filter('gdpr/admin/tabs', [$this, 'registerAdminTab'], 35);
17
18 add_shortcode('gdpr_privacy', [$this, 'doShortcode']);
19 add_shortcode('gdpr_privacy_policy_url', [$this, 'renderUrlShortcode']);
20 add_shortcode('gdpr_privacy_policy_link', [$this, 'renderLinkShortcode']);
21 }
22
23 public function registerAdminTab($tabs)
24 {
25
26 $tabs['privacy-policy'] = new AdminTabPrivacyPolicy(new PolicyGenerator());
27
28 return $tabs;
29 }
30
31 public function doShortcode($attributes)
32 {
33 global $gdpr;
34 $attributes = shortcode_atts([
35 'item' => null,
36 ], $attributes);
37
38 switch ($attributes['item']) {
39 case 'company_name':
40 return esc_html($gdpr->Options->get('company_name'));
41 case 'company_email':
42 return esc_html($gdpr->Options->get('contact_email'));
43 case 'company_email_link':
44 $email = antispambot($gdpr->Options->get('contact_email'));
45 return "<a href='mailto:{$email}'>{$email}</a>";
46 case 'dpo_name':
47 return esc_html($gdpr->Options->get('dpo_name'));
48 case 'dpo_email':
49 return esc_html($gdpr->Options->get('dpo_email'));
50 case 'dpo_email_link':
51 $email = antispambot($gdpr->Options->get('dpo_email'));
52 return "<a href='mailto:{$email}'>{$email}</a>";
53 case 'rep_name':
54 return esc_html($gdpr->Options->get('representative_contact_name'));
55 case 'rep_email':
56 return esc_html($gdpr->Options->get('representative_contact_email'));
57 case 'rep_email_link':
58 $email = antispambot($gdpr->Options->get('representative_contact_email'));
59 return "<a href='mailto:{$email}'>{$email}</a>";
60 case 'authority_website':
61 return esc_html($gdpr->Options->get('dpa_website'));
62 case 'authority_email':
63 return esc_html($gdpr->Options->get('dpa_email'));
64 case 'authority_email_link':
65 $email = antispambot($gdpr->Options->get('dpa_email'));
66 return "<a href='mailto:{$email}'>{$email}</a>";
67 case 'authority_phone':
68 return esc_html($gdpr->Options->get('dpa_phone'));
69 case null:
70 return '';
71 }
72
73 return '';
74 }
75
76 public function renderUrlShortcode()
77 {
78 global $gdpr;
79 return gdpr('helpers')->getPrivacyPolicyPageUrl();
80 }
81
82 public function renderLinkShortcode($attributes)
83 {
84 global $gdpr;
85 $attributes = shortcode_atts([
86 'title' => __('Privacy Policy', 'gdpr-framework'),
87 ], $attributes);
88
89 $url = gdpr('helpers')->getPrivacyPolicyPageUrl();
90
91 return
92 "<a href='{$url}'>" .
93 esc_html($attributes['title']) .
94 "</a>";
95 }
96 }
97