PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 2.15
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v2.15
5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 All 35 releases
double-opt-in / ui / UIOptinView.class.php

UIOptinView.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 2.15, at ui/UIOptinView.class.php

179 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace forge12\contactform7\CF7DoubleOptIn {
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 /**
9 * Class UIOptinView
10 * Show a specific OptIn
11 *
12 * @package forge12\contactform7\CF7DoubleOptIn
13 */
14 class UIOptinView extends UIPage
15 {
16 public function __construct($domain)
17 {
18 parent::__construct($domain, 'optin_view', 'OptIn View');
19
20 if (isset($_GET['status'])) {
21 $status = sanitize_text_field($_GET['status']);
22
23 switch ($status) {
24 case 'deleted':
25 Messages::getInstance()->add(__('Opt-In deleted', 'double-opt-in'), 'success');
26 break;
27 case 'not-deleted':
28 Messages::getInstance()->add(__('Opt-In not-deleted', 'double-opt-in'), 'error');
29 break;
30 default:
31 break;
32 }
33 }
34 }
35
36 /**
37 * Hide this page in the menu.
38 *
39 * @return bool
40 */
41 public function hideInMenu()
42 {
43 return true;
44 }
45
46 /**
47 * Render the license subpage content
48 */
49 protected function theContent($slug, $page, $settings)
50 {
51 /*
52 * Ensure that the hash is given
53 */
54 if (!isset($_GET['hash'])) {
55 wp_redirect(admin_url('admin.php') . '?page=f12-cf7-doubleoptin');
56 }
57
58 $this->maybeSave();
59
60
61 $hash = sanitize_text_field($_GET['hash']);
62
63 /*
64 * Load the assigned Category
65 */
66 $Optin = Optin::get_by_hash($hash);
67
68 if (null === $Optin) {
69 wp_redirect(admin_url('admin.php') . '?page=f12-cf7-doubleoptin');
70 }
71
72 /*
73 * Render the Template
74 */
75 ?>
76 <h2><?php _e('Opt-In: ', 'double-opt-in') . esc_attr_e($Optin->get_hash()); ?></h2>
77 <?php
78 CF7DoubleOptIn::getInstance()->renderTemplate('view-optin', array(
79 'domain' => $this->domain,
80 'optin' => $Optin
81 ));
82 }
83
84 /**
85 * Update the Optin if the category has been submitted.
86 * @return void
87 */
88 private function maybeSave(){
89 if(!isset($_POST['hash']) || !wp_verify_nonce($_POST['doi_settings_nonce'], 'doi_settings_action')){
90 return;
91 }
92
93 $category = (int)$_POST['category'];
94 $hash = sanitize_text_field($_POST['hash']);
95
96
97 if(!$category){
98 return;
99 }
100
101 $Optin = OptIn::get_by_hash($hash);
102 $Optin->set_category($category);
103 $Optin->save();
104 }
105
106 protected function theSidebar($slug, $page)
107 {
108 /*
109 * Ensure that the ID for the Categorie is set
110 */
111 if (!isset($_GET['hash'])) {
112 wp_redirect(admin_url('admin.php') . '?page=f12-cf7-doubleoptin');
113 }
114
115 $hash = sanitize_text_field($_GET['hash']);
116
117 /*
118 * Load the OptIn
119 */
120 $Optin = OptIn::get_by_hash($hash);
121
122 if (!$Optin) {
123 wp_redirect(admin_url('admin.php') . '?page=f12-cf7-doubleoptin');
124 }
125 ?>
126 <div class="box">
127 <h2>
128 <?php _e('Edit Opt-In:', 'double-opt-in'); ?>
129 </h2>
130
131 <form action="" method="post">
132 <div class="option">
133 <div class="label">
134 <label for="category"><?php _e('Category:', 'double-opt-in'); ?></label>
135 </div>
136 <input type="hidden" value="<?php esc_attr_e($Optin->get_hash()); ?>" name="hash"/>
137 <div class="input">
138 <?php
139 echo wp_kses(CategoryOptions::getInstance()->select_category($Optin->get_category()), array('select' => array('name' => array()), 'option' => array('value' => array(), 'selected' => array())));
140 ?>
141 <p>
142 <?php _e('Select the category to assign the Opt-In.', 'double-opt-in'); ?>
143 </p>
144 </div>
145 </div>
146 <?php
147 wp_nonce_field('doi_settings_action', 'doi_settings_nonce');
148 ?>
149
150 <input type="submit" name="doubleoptin-settings-edit-submit" class="button"
151 value=" <?php _e('Update', 'double-opt-in'); ?>"/>
152 </form>
153 </div>
154
155 <div class="box">
156 <h2>
157 <?php _e('Links:', 'double-opt-in'); ?>
158 </h2>
159
160 <div class="option">
161 <div class="label">
162 <label for="category"><?php _e('Opt-In:', 'double-opt-in'); ?></label>
163 </div>
164 <div class="input copy-to-clipboard">
165 <?php
166 echo esc_url_raw($Optin->get_link_optin());
167 ?>
168 </div>
169 </div>
170 </div>
171 <?php
172 }
173
174 public function getSettings($settings)
175 {
176 return $settings;
177 }
178 }
179 }