PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 3.0.3
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v3.0.3
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 / UIDatabase.class.php

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

130 lines 4.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 UIDatabase
10 *
11 * @package forge12\contactform7\CF7DoubleOptIn
12 */
13 class UIDatabase extends UIPageForm {
14 /**
15 * Constructor method for the class.
16 *
17 * @param TemplateHandler $templateHandler The template handler object to be used.
18 * @param string $domain The domain parameter for the constructor.
19 *
20 * @return void
21 */
22 public function __construct( TemplateHandler $templateHandler, string $domain ) {
23 parent::__construct( $templateHandler, $domain, 'database', __( 'Database', 'double-opt-in' ), 50 );
24 $this->hideSubmitButton( true );
25 }
26
27 /**
28 * Save on form submit
29 */
30 private function maybeCleanDatabase() {
31 // Check if the form is posted and the nonce is valid
32 if ( ( isset( $_POST['doi-clean-submit'] ) || isset( $_POST['doi-clean-confirmed-submit'] ) || isset( $_POST['doi-clean-unconfirmed-submit'] ) ) ) {
33 $CleanUp = new CleanUp();
34 if ( isset( $_POST['doi-clean-submit'] ) || isset( $_POST['doi-clean-confirmed-submit'] ) ) {
35 $CleanUp->removeConfirmedOptins( true );
36 }
37 if ( isset( $_POST['doi-clean-submit'] ) || isset( $_POST['doi-clean-unconfirmed-submit'] ) ) {
38 $CleanUp->removeUnconfirmedOptins( true );
39 }
40
41 Messages::getInstance()->add( __( 'Database cleaned.', 'double-opt-in' ), 'success' );
42 }
43 }
44
45 /**
46 * Reset the database deleting all entries.
47 */
48 private function maybeResetDatabase() {
49 // Check if the form is posted and the nonce is valid
50 if ( isset( $_POST['doi-reset-submit'] ) ) {
51 $CleanUp = new CleanUp();
52 $CleanUp->reset();
53
54 Messages::getInstance()->add( __( 'Database reset finished.', 'double-opt-in' ), 'success' );
55 }
56 }
57
58 /**
59 * Render the license subpage content
60 */
61 protected function theContent( $slug, $page, $settings ) {
62 ?>
63 <h2>
64 <?php _e( 'Database', 'double-opt-in' ); ?>
65 </h2>
66 <?php
67 wp_nonce_field( 'doi_settings_action', 'doi_settings_nonce' );
68 ?>
69
70 <div class="option">
71 <div class="label">
72 <label for="delete"><?php _e( 'Clean Database', 'double-opt-in' ); ?></label>
73 </div>
74 <div class="input">
75 <input type="submit" name="doi-clean-submit" class="button"
76 value="<?php _e( 'Clean All', 'double-opt-in' ); ?>"/>
77 <input type="submit" name="doi-clean-confirmed-submit" class="button"
78 value="<?php _e( 'Clean Confirmed', 'double-opt-in' ); ?>"/>
79 <input type="submit" name="doi-clean-unconfirmed-submit" class="button"
80 value="<?php _e( 'Clean Unconfirmed', 'double-opt-in' ); ?>"/>
81 <p>
82 <?php _e( 'Make sure you backup your database before clicking one of these buttons.', 'double-opt-in' ); ?>
83 </p>
84 </div>
85 </div>
86 <div class="option">
87 <div class="label">
88 <label for="delete"><?php _e( 'Reset Database', 'double-opt-in' ); ?></label>
89 </div>
90 <div class="input">
91 <input type="submit" name="doi-reset-submit" class="button button-delete"
92 value="<?php _e( 'Reset', 'double-opt-in' ); ?>"/>
93 <p>
94 <?php _e( 'Make sure you backup your database before clicking one of these buttons. If you click this button, all Opt-Ins will be deleted.', 'double-opt-in' ); ?>
95 </p>
96 </div>
97 </div>
98 <?php
99 }
100
101 protected function theSidebar( $slug, $page ) {
102 if ( $page != 'settings' ) {
103 return;
104 }
105 ?>
106 <div class="box">
107 <h2>
108 <?php _e( 'Hint:', 'double-opt-in' ); ?>
109 </h2>
110 <p>
111 <?php _e( "In the table on the left side, you'll find an list containing all Opt-Ins and the required information from your customers. Click on the hash to open aditional informations about the form and the user data. All unconfirmed opt-ins will be deleted after 7 days.", 'double-opt-in' ); ?>
112 </p>
113 </div>
114 <?php
115 }
116
117 public function getSettings( $settings ) {
118 return $settings;
119 }
120
121 protected function onSave( $settings ) {
122 // Check if the user wants to clean the database manually
123 $this->maybeCleanDatabase();
124 // Check if the user wants to reset the database manually
125 $this->maybeResetDatabase();
126
127 return $settings;
128 }
129 }
130 }