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 / Admin / AdminTab.php

AdminTab.php in The GDPR Framework By Data443 trunk, at src/Admin/AdminTab.php

253 lines 7.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\Admin;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 /**
8 * Base class for admin tabs. Extend this.
9 *
10 * Class AdminTab
11 *
12 * @package Codelight\GDPR\Admin
13 */
14 abstract class AdminTab implements AdminTabInterface
15 {
16 /* @var string */
17 protected $slug;
18
19 /* @var string */
20 protected $title;
21
22 /**
23 * @return string
24 */
25 public function getSlug()
26 {
27 return $this->slug;
28 }
29
30 /**
31 * @return string
32 */
33 public function getTitle()
34 {
35 return $this->title;
36 }
37
38 /**
39 * @return string
40 */
41 public function getOptionsGroupName()
42 {
43 return 'gdpr_' . $this->getSlug();
44 }
45
46 /**
47 * Register a setting on the admin page
48 *
49 * @param $optionName
50 * @param string $args
51 */
52 public function registerSetting($optionName, $args = [])
53 {
54 register_setting($this->getOptionsGroupName(), $optionName, $args);
55 }
56
57 /**
58 * Register a section on the admin page
59 *
60 * @param $name
61 * @param $callback
62 */
63 public function registerSettingSection($id, $title, $callback = null)
64 {
65 add_settings_section(
66 $id,
67 $title,
68 $callback,
69 $this->getOptionsGroupName()
70 );
71 }
72
73 /**
74 * Register a setting field on the admin page
75 *
76 * @param $id
77 * @param $title
78 * @param $callback
79 */
80 public function registerSettingField($id, $title, $callback = null, $section = '', $args = [])
81 {
82 add_settings_field(
83 $id,
84 $title,
85 $callback,
86 $this->getOptionsGroupName(),
87 $section,
88 $args
89 );
90 }
91
92 /**
93 * Render the contents including settings fields, sections and submit button.
94 * Trigger hooks for rendering content before and after the settings fields.
95 *
96 * @return string
97 */
98 public function renderContents()
99 {
100 global $gdpr;
101 $tabs = array("general", "cookie-popup", "consent", "privacy-policy", "do-not-sell", "support");
102 ob_start();
103
104 if (in_array($this->slug, $tabs)) {
105 ?>
106 <style>
107 .column {
108 float: left;
109 }
110 .left {
111 width: 75%;
112 }
113
114 .right {
115 width: 25%;
116 }
117
118 /* Clear floats after the columns */
119 .row:after {
120 content: "";
121 display: table;
122 clear: both;
123 }
124 @media screen and (max-width: 600px) {
125 .column {
126 width: 100%;
127 }
128 }
129 </style>
130 <div class="row">
131 <div class="column left">
132 <?php
133 }
134
135 do_action("gdpr/tabs/{$this->getSlug()}/before", $this);
136 settings_fields($this->getOptionsGroupName());
137 do_settings_sections($this->getOptionsGroupName());
138 do_action("gdpr/tabs/{$this->getSlug()}/after", $this);
139
140 $this->renderSubmitButton();
141
142 if (in_array($this->slug, $tabs)) {
143 ?>
144 </div>
145 <div class="column right">
146 <div style="float:left;max-width:250px;margin:9px;margin-left:20px;margin-top:50px;">
147 <b>How to contact us?</b>
148 <ul style="list-style:circle;margin-left:20px;">
149 <li>
150 <a href="<?=gdpr('helpers')->data443()?>" target="_blank">Data443 (homepage)</a>
151 </li>
152 <li>
153 <a href="<?=gdpr('helpers')->supportRequest()?>" target="_blank">Contact Support</a>
154 </li>
155 <li>
156 <a href="https://www.facebook.com/data443/" target="_blank">Like us on Facebook</a>
157 </li>
158 <li>
159 <a href="https://twitter.com/data443risk" target="_blank">Follow us on Twitter</a>
160 </li>
161 <li>
162 <a href="<?=gdpr('helpers')->wordpressReview()?>" target="_blank">Rate us on WordPress</a>
163 </li>
164 </ul>
165 <div style="border: solid 1px black;border-radius: 5px;background: #f2efe6;padding:10px;padding-bottom:30px;">
166 <p style="margin-top:0px;">Do you like this plugin?</p>
167 <p>With the <b>PREMIUM</b> version you can have other awesome features:</p>
168
169 <div style="clear:both; margin-top: 2px;"></div>
170 <div>
171 <div style="float:left; vertical-align:middle; height:24px; margin-right:5px; margin-top:-3px;">
172 <img src="<?=$gdpr->PluginUrl?>/assets/images/tick.png" />
173 </div>
174 <p style="margin-top:0px;">Custom Consent Text</p>
175 </div>
176
177 <div style="clear:both; margin-top: 2px;"></div>
178 <div>
179 <div style="float:left; vertical-align:middle; height:24px; margin-right:5px; margin-top:-3px;">
180 <img src="<?=$gdpr->PluginUrl?>/assets/images/tick.png" />
181 </div>
182 <p style="margin-top:0px;">Data Rectification</p>
183 </div>
184
185 <div style="clear:both; margin-top: 2px;"></div>
186 <div>
187 <div style="float:left; vertical-align:middle; height:24px; margin-right:5px; margin-top:-3px;">
188 <img src="<?=$gdpr->PluginUrl?>/assets/images/tick.png" />
189 </div>
190 <p style="margin-top:0px;">Custom relative URLs for the Privacy Policy and other files</p>
191 </div>
192
193 <div style="clear:both;"></div>
194 <div style="height:10px;"></div>
195 <div style="float:right;"><a href="<?=gdpr('helpers')->premiumStore()?>" target="_blank">Get PREMIUM now >></a></div>
196 </div>
197 </div>
198 </div>
199 </div>
200 <?php
201 }
202 return ob_get_clean();
203 }
204
205 /**
206 * Render WP's default submit button
207 */
208 public function renderSubmitButton()
209 {
210 submit_button(_x('Save', '(Admin)', 'gdpr-framework'));
211 }
212
213 /**
214 * Enqueue scripts, run the child class init function, trigger action for adding custom stuff
215 */
216 public function setup()
217 {
218 // Automatically run the 'enqueue' method if it exists
219 if (method_exists($this, 'enqueue')) {
220 add_action('admin_enqueue_scripts', [$this, 'enqueue']);
221 }
222
223 $this->init();
224
225 // This hook can be used for registering custom settings
226 do_action("gdpr/tabs/{$this->getSlug()}/init", $this);
227
228 // Render the admin notices
229 add_action('admin_notices', [$this, 'renderAdminNotices']);
230 }
231
232 /**
233 * Render success notices via admin_notice action
234 */
235 public function renderAdminNotices()
236 {
237 if ('tools_page_privacy' !== get_current_screen()->base) {
238 return;
239 }
240
241 if (!isset($_REQUEST['gdpr_notice'])) {
242 return;
243 }
244
245 if ('policy_generated' === $_REQUEST['gdpr_notice']) {
246 $message = _x('Policy generated!', '(Admin)', 'gdpr-framework');
247 $class = 'notice notice-success';
248 }
249
250 echo gdpr('view')->render('admin/notice', compact('message', 'class'));
251 }
252 }
253