PluginProbe
The GDPR Framework By Data443 / trunk
The GDPR Framework By Data443 vtrunk
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 trunk, at src/Components/PrivacyPolicy/PrivacyPolicy.php

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