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 / Installer / Steps / ConfigurationPages.php

ConfigurationPages.php in The GDPR Framework By Data443 2.1.0, at src/Installer/Steps/ConfigurationPages.php

74 lines 2.4 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\Installer\Steps;
4
5 use Codelight\GDPR\Installer\InstallerStep;
6 use Codelight\GDPR\Installer\InstallerStepInterface;
7
8 class ConfigurationPages extends InstallerStep implements InstallerStepInterface
9 {
10 protected $slug = 'configuration-pages';
11
12 protected $type = 'wizard';
13
14 protected $template = 'installer/steps/configuration-pages';
15
16 protected $activeSteps = 1;
17
18 protected function renderContent()
19 {
20 global $gdpr;
21 $policyPage = $gdpr->Options->get('policy_page');
22 $policyPageSelector = wp_dropdown_pages([
23 'name' => 'gdpr_policy_page',
24 'show_option_none' => _x('&mdash; Create a new page &mdash;', '(Admin)', 'gdpr-framework'),
25 'option_none_value' => 'new',
26 'selected' => $policyPage ? $policyPage : 'new',
27 'echo' => false,
28 'class' => 'gdpr-select js-gdpr-select2',
29 ]);
30
31 $privacyToolsPage = $gdpr->Options->get('tools_page');
32 $privacyToolsPageSelector = wp_dropdown_pages([
33 'name' => 'gdpr_tools_page',
34 'show_option_none' => _x('&mdash; Create a new page &mdash;', '(Admin)', 'gdpr-framework'),
35 'option_none_value' => 'new',
36 'selected' => $privacyToolsPage ? $privacyToolsPage : 'new',
37 'echo' => false,
38 'class' => 'gdpr-select js-gdpr-select2',
39 ]);
40
41 echo gdpr('view')->render(
42 $this->template,
43 compact(
44 'policyPage',
45 'policyPageSelector',
46 'privacyToolsPage',
47 'privacyToolsPageSelector'
48 )
49 );
50 }
51
52 public function submit()
53 {
54 global $gdpr;
55 if (isset($_POST['gdpr_create_tools_page']) && 'yes' === $_POST['gdpr_create_tools_page']) {
56 $id = $this->createPrivacyToolsPage();
57 $gdpr->Options->set('tools_page', $id);
58 } else {
59 $gdpr->Options->set('tools_page', $_POST['gdpr_tools_page']);
60 }
61 }
62
63 protected function createPrivacyToolsPage()
64 {
65 $id = wp_insert_post([
66 'post_content' => '<!-- wp:shortcode -->[gdpr_privacy_tools]<!-- /wp:shortcode -->',
67 'post_title' => __('Privacy Tools', 'gdpr-framework'),
68 'post_type' => 'page',
69 ]);
70
71 return $id;
72 }
73 }
74