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 / compatibility / cf7 / ConditionalFields.class.php

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

69 lines 2.3 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 /**
10 * Class ConditionalFields Support
11 * Add support for conditional fields if available.
12 *
13 * @package forge12\contactform7\CF7DoubleOptIn
14 */
15 class ConditionalFields
16 {
17 private $conditionalFieldsParameter = array(
18 '_wpcf7cf_hidden_group_fields' => '',
19 '_wpcf7cf_hidden_groups' => '',
20 '_wpcf7cf_visible_groups' => '',
21 '_wpcf7cf_repeaters' => '',
22 '_wpcf7cf_steps' => '',
23 '_wpcf7cf_options' => ''
24 );
25
26 /**
27 * Admin constructor.
28 */
29 public function __construct()
30 {
31 add_filter('f12_cf7_doubleoptin_add_request_parameter', array($this,'_initConditionalFieldParameter'), 10, 1);
32 add_filter('f12_cf7_doubleoptin_body', array($this, '_getOptinBody'), 10, 1);
33 }
34
35 /**
36 * Add the option to add conditional fields also to the optin mail.
37 * @return string
38 */
39 public function _getOptinBody($body)
40 {
41 if(!defined('WPCF7CF_PLUGIN') || !class_exists('\Wpcf7cfMailParser')){
42 return $body;
43 }
44
45 $CFMP = new \Wpcf7cfMailParser($body, $this->conditionalFieldsParameter['_wpcf7cf_visible_groups'], $this->conditionalFieldsParameter['_wpcf7cf_hidden_groups'], $this->conditionalFieldsParameter['_wpcf7cf_repeaters'], array());
46 return $CFMP->getParsedMail();
47 }
48
49 /**
50 * Check if conditional field plugin is available and if yes, check for the parameter
51 * which has to be stored within the content.
52 * @param $parameter
53 */
54 public function _initConditionalFieldParameter($parameter)
55 {
56 if (!defined('WPCF7CF_PLUGIN')) {
57 return $parameter;
58 }
59
60 foreach ($this->conditionalFieldsParameter as $key => $value) {
61 if (isset($_POST[$key])) {
62 $parameter[$key] = sanitize_text_field($_POST[$key]);
63 $this->conditionalFieldsParameter[$key] = sanitize_text_field(json_decode(stripslashes($_POST[$key])));
64 }
65 }
66 return $parameter;
67 }
68 }
69 }