PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 3.0.71
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v3.0.71
5.6.1 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 All 36 releases
double-opt-in / CF7DoubleOptIn.class.php

CF7DoubleOptIn.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 3.0.71, at CF7DoubleOptIn.class.php

262 lines 7.7 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 * Plugin Name: Double Opt-In (Contact Form 7, Avada) - GDPR Ready
10 * Plugin URI: https://www.forge12.com/blog/so-verwendest-du-das-double-opt-in-fuer-contact-form-7/
11 * Description: This plugin allows you to add a double OptIn System to your Contact Form 7 & Avada Forms.
12 * Text Domain: double-opt-in
13 * Domain Path: /languages
14 * Version: 3.0.71
15 * Author: Forge12 Interactive GmbH
16 * Author URI: https://www.forge12.com
17 */
18 define( 'FORGE12_OPTIN_VERSION', '3.0.71' );
19 define( 'FORGE12_OPTIN_SLUG', 'f12-cf7-doubleoptin' );
20 define( 'FORGE12_OPTIN_BASENAME', plugin_basename( __FILE__ ) );
21
22
23 /**
24 * Dependencies
25 */
26 require_once('core/Debug.php');
27 require_once( 'core/BaseController.class.php' );
28
29 require_once( 'OnActivation.php' );
30 require_once( 'OnDeactivation.php' );
31 require_once( 'OnUpdate.php' );
32 require_once( 'compatibility/OptInFrontend.class.php' );
33
34 require_once( 'core/Messages.class.php' );
35 require_once( 'core/TemplateHandler.class.php' );
36 require_once( 'core/IPHelper.class.php' );
37 require_once( 'core/SanitizeHelper.class.php' );
38 require_once( 'core/Ajax.class.php' );
39 require_once( 'core/Compatibility.class.php' );
40 require_once( 'core/CleanUp.class.php' );
41 require_once( 'core/HTMLSelect.class.php' );
42 require_once( 'core/UI.class.php' );
43 require_once( 'core/UIPage.class.php' );
44 require_once( 'core/UIPageForm.class.php' );
45 require_once( 'core/OptIn.class.php' );
46 require_once( 'core/OptInLimitFilter.class.php' );
47 require_once( 'core/OptInSearchFilter.class.php' );
48 require_once( 'core/Category.class.php' );
49 require_once( 'core/CategoryOptions.class.php' );
50 require_once( 'core/Pagination.class.php' );
51 require_once( 'core/Support.class.php' );
52
53 /**
54 * Class CF7DoubleOptIn
55 * Controller for the Custom Links.
56 *
57 * @package forge12\contactform7
58 */
59 class CF7DoubleOptIn {
60 /**
61 * @var CF7DoubleOptIn|Null
62 */
63 private static $_instance = null;
64
65 /**
66 * @var TemplateHandler|null
67 */
68 private $TemplateHandler = null;
69
70 /**
71 * Get the singleton instance of CF7DoubleOptIn.
72 *
73 * @return CF7DoubleOptIn The singleton instance.
74 */
75 public static function getInstance() {
76 if ( self::$_instance == null ) {
77 self::$_instance = new self();
78 }
79
80 return self::$_instance;
81 }
82
83 /**
84 * Return a list containing the array with all data stored within the form
85 *
86 * @param int $postID
87 *
88 * @formatter:off
89 *
90 * @return {
91 * @type int $enable The Status of the OptIn, either 1 for enabled or 0 for disabled. Default: 0
92 * @type string $sender The E-Mail of the sender of the optIn mail
93 * @type string $subject The Subject of the OptIn Mail
94 * @type string $body The Content of the OptIn Mail
95 * @type string $recipient The Field that contains the E-Mail of the Recipient.
96 * @type int $page The Post ID of the confirmation page. Default: -1
97 * @type string $conditions Additional condition to dynamically enable / disable the optin.
98 * Default: disabled
99 * @type string $template The Template used for the OptIn Mail
100 * @type int $category The Category the OptIns will be assigned to.
101 * }
102 * @formatter:on
103 */
104 public function getParameter( $postID ) {
105
106 $data = [
107 'enable' => 0,
108 'sender' => get_bloginfo( 'admin_email' ),
109 'sender_name' => '',
110 'subject' => '',
111 'body' => '',
112 'recipient' => '',
113 'page' => - 1,
114 'conditions' => 'disabled',
115 'template' => '',
116 'category' => 0,
117 ];
118
119 /**
120 * DOI Parameter
121 *
122 * Filters the parameter for the DOI. This hook allows developers
123 * to alter DOI fields.
124 *
125 * @param array $data Additional Fields
126 *
127 * @since 1.0.0
128 */
129 $data = apply_filters( 'f12_cf7_doubleoptin_get_parameter', $data );
130
131 if ( ! $postID ) {
132 return $data;
133 }
134
135 $options = get_post_meta( $postID, 'f12-cf7-doubleoptin', true );
136
137 if ( ! $options ) {
138 return $data;
139 }
140
141 return array_merge( $data, $options );
142 }
143
144 /**
145 * Private constructor to prevent direct instantiation.
146 */
147 private function __construct() {
148 load_plugin_textdomain( 'double-opt-in', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
149 /**
150 * DOI INIT
151 *
152 * Run custom actions after the DOI has been initialized
153 *
154 * @param CF7DoubleOptIn $this
155 *
156 * @since 3.0.0
157 */
158 do_action( 'f12_cf7_doubleoptin_init', $this );
159
160
161 $this->TemplateHandler = TemplateHandler::getInstance();
162
163 $UI = new UI( $this->TemplateHandler, FORGE12_OPTIN_SLUG, 'Forge12 Double Opt-In', 'manage_options' );
164
165 add_action( 'after_setup_theme', array( $this, 'init' ) );
166
167 $Compatibility = new Compatibility( $this );
168 $CleanUp = new CleanUp();
169
170 // Pagination
171 Pagination::getInstance();
172
173 // initialize filter
174 CategoryOptions::getInstance();
175 OptInLimitFilter::getInstance();
176 OptInSearchFilter::getInstance();
177
178 // Support
179 Support::getInstance();
180 }
181
182 /**
183 * Retrieve the template handler instance.
184 *
185 * @return TemplateHandler The template handler instance.
186 */
187 public function get_template_handler() {
188 return $this->TemplateHandler;
189 }
190
191 /**
192 * @private WordPress Hook
193 */
194 public function init() {
195 do_action( 'f12_cf7_doubleoptin_register_implementations' );
196 }
197
198 /**
199 * Return the settings for the optin.
200 *
201 * @param string $single The Key of the setting to return only the required setting
202 *
203 * @formatter:off
204 * @return {
205 * // Returns the Settings for the DOI
206 *
207 * @type string $optout_subject The Subject for the OptOut Mail
208 * @type string $optout_body The Content for the OptOut Mail
209 * @type int $optout_page The Post ID for the OptOut Page
210 * @type int $support Defines if the Support link will be added to the footer
211 * @type int $delete An integer from 1 to 30
212 * @type int $delete_unconfirmed An integer from 1 to 30
213 * @type string $delete_period The time period, either months, days, years
214 * @type string $delete_unconfirmed_period The time period, either months, days, years
215 * }
216 * @formatter:on
217 */
218 public function getSettings( $single = '', $container = null ) {
219 $default = array();
220
221 $default = apply_filters( 'f12_cf7_doubleoptin_settings', $default );
222
223 $settings = get_option( 'f12-doi-settings' );
224
225 if ( ! is_array( $settings ) ) {
226 $settings = array();
227 }
228
229 foreach ( $default as $key => $data ) {
230 if ( isset( $settings[ $key ] ) ) {
231 if ( is_array( $default[ $key ] ) ) {
232 $default[ $key ] = array_merge( $default[ $key ], $settings[ $key ] );
233 } else {
234 $default[ $key ] = $settings[ $key ];
235 }
236 }
237 }
238
239 $settings = $default;
240
241 if ( ! empty( $single ) ) {
242 if ( $container != null ) {
243 if ( isset( $settings[ $container ] ) && isset( $settings[ $container ][ $single ] ) ) {
244 $settings = $settings[ $container ][ $single ];
245 }
246 }
247 } else {
248 if ( isset( $settings[ $single ] ) ) {
249 $settings = $settings[ $single ];
250 }
251 }
252
253 return $settings;
254 }
255 }
256
257
258 add_action('plugins_loaded', function(){
259 CF7DoubleOptIn::getInstance();
260 });
261
262 }