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

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

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