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

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

125 lines 3.9 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\Themes;
4
5 class Themes
6 {
7 protected $theme;
8
9 public $supportedThemes = [
10 'twentynineteen',
11 'twentyseventeen',
12 'twentysixteen',
13 'storefront'
14 ];
15
16 public function __construct()
17 {
18 global $gdpr;
19 $this->theme = get_option('stylesheet');
20
21 if (!$this->isCurrentThemeSupported() || !$gdpr->Options->get('enable_theme_compatibility')) {
22 return;
23 }
24
25 // If both pages aren't defined, bail
26 $privacyPolicy = $gdpr->Options->get('policy_page');
27 $privacyToolsPage = $gdpr->Options->get('tools_page');
28
29 if (!$privacyPolicy || !$privacyToolsPage) {
30 return;
31 }
32
33 $theme = $this->theme;
34 $this->$theme();
35 }
36
37 public function isCurrentThemeSupported()
38 {
39 return in_array($this->theme, $this->supportedThemes);
40 }
41
42 public function getCurrentThemeName()
43 {
44 return $this->theme;
45 }
46 public function twentynineteen()
47 {
48 add_action("the_privacy_policy_link", [$this, 'rendertwentynineteenFooterLinks'], 10, 2);
49 }
50 public function twentyseventeen()
51 {
52 add_action("get_template_part_template-parts/footer/site", [$this, 'renderTwentyseventeenFooterLinks'], 10, 2);
53 }
54
55 public function twentysixteen()
56 {
57 add_action("twentysixteen_credits", [$this, 'renderTwentysixteenFooterLinks']);
58 }
59
60 public function storefront()
61 {
62 // I feel slightly dirty, but also clever
63 add_filter("storefront_credit_link", [$this, 'renderStorefrontFooterLinks']);
64 }
65 public function rendertwentynineteenFooterLinks()
66 {
67 global $gdpr;
68 $privacyPolicyUrl = get_permalink($gdpr->Options->get('policy_page'));
69 add_filter( 'gdpr_custom_policy_link', 'gdprfPrivacyPolicyurl' );
70 $privacyPolicyUrl = apply_filters( 'gdpr_custom_policy_link',$privacyPolicyUrl);
71 $privacyToolsPageUrl = get_permalink($gdpr->Options->get('tools_page'));
72
73 echo gdpr('view')->render(
74 'themes/twentyseventeen/footer',
75 compact('privacyPolicyUrl', 'privacyToolsPageUrl')
76 );
77 }
78 public function renderTwentyseventeenFooterLinks($slug, $name)
79 {
80 global $gdpr;
81 if ('info' !== $name) {
82 return;
83 }
84
85 $privacyPolicyUrl = get_permalink($gdpr->Options->get('policy_page'));
86 add_filter( 'gdpr_custom_policy_link', 'gdprfPrivacyPolicyurl' );
87 $privacyPolicyUrl = apply_filters( 'gdpr_custom_policy_link',$privacyPolicyUrl);
88 $privacyToolsPageUrl = get_permalink($gdpr->Options->get('tools_page'));
89
90 echo gdpr('view')->render(
91 'themes/twentyseventeen/footer',
92 compact('privacyPolicyUrl', 'privacyToolsPageUrl')
93 );
94 }
95
96 public function renderTwentysixteenFooterLinks()
97 {
98 global $gdpr;
99 $privacyPolicyUrl = get_permalink($gdpr->Options->get('policy_page'));
100 add_filter( 'gdpr_custom_policy_link', 'gdprfPrivacyPolicyurl' );
101 $privacyPolicyUrl = apply_filters( 'gdpr_custom_policy_link',$privacyPolicyUrl);
102 $privacyToolsPageUrl = get_permalink($gdpr->Options->get('tools_page'));
103
104 echo gdpr('view')->render(
105 'themes/twentysixteen/footer',
106 compact('privacyPolicyUrl', 'privacyToolsPageUrl')
107 );
108 }
109
110 public function renderStorefrontFooterLinks($value)
111 {
112 global $gdpr;
113 $privacyPolicyUrl = get_permalink($gdpr->Options->get('policy_page'));
114 add_filter( 'gdpr_custom_policy_link', 'gdprfPrivacyPolicyurl' );
115 $privacyPolicyUrl = apply_filters( 'gdpr_custom_policy_link',$privacyPolicyUrl);
116 $privacyToolsPageUrl = get_permalink($gdpr->Options->get('tools_page'));
117
118 echo gdpr('view')->render(
119 'themes/storefront/footer',
120 compact('privacyPolicyUrl', 'privacyToolsPageUrl')
121 );
122
123 return $value;
124 }
125 }