PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/MailPoet/MailPoetHandler.php +31 -19 2.03.3.1 View file →
@@ -6,8 +6,12 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\MailPoet;
9 9
10 +if (!defined('ABSPATH')) {
11 + exit;
12 +}
13 +
10 14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
11 15 use WP_Error;
12 16
13 17 /**
@@ -12,21 +16,28 @@
12 16
13 17 /**
14 18 * Provide functionality for ZohoCrm integration
15 19 */
16 -class MailpoetHandler {
20 +class MailPoetHandler
21 +{
17 22 private $_integrationID;
18 23
19 - public function __construct($integrationID, $fromID) {
24 + private $formId;
25 +
26 + public function __construct($integrationID, $fromID)
27 + {
20 28 $this->_integrationID = $integrationID;
29 +
30 + $this->formId = $fromID;
21 31 }
22 32
23 - /**bitforms_zsheet_refresh_worksheet_headers
33 + /**
24 34 * Helps to register ajax function's with wp
25 35 *
26 36 * @return null
27 37 */
28 - public static function registerAjax() {
38 + public static function registerAjax()
39 + {
29 40 add_action('wp_ajax_bitforms_mail_poet_authorize', [__CLASS__, 'mailPoetAuthorize']);
30 41 add_action('wp_ajax_bitforms_refresh_news_letter', [__CLASS__, 'refreshNeswLetter']);
31 42 add_action('wp_ajax_bitforms_mail_poet_list_headers', [__CLASS__, 'mailPoetListHeaders']);
32 43 }
@@ -33,12 +44,13 @@
33 44
34 45 /**
35 46 * Process ajax request for generate_token
36 47 *
37 - * @return JSON zoho crm api response and status
48 + * @return string zoho crm api response and status
38 49 */
39 - public static function mailPoetAuthorize() {
40 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
50 + public static function mailPoetAuthorize()
51 + {
52 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
41 53 if (class_exists(\MailPoet\API\API::class)) {
42 54 wp_send_json_success(true);
43 55 } else {
44 56 wp_send_json_error(
@@ -62,13 +74,14 @@
62 74
63 75 /**
64 76 * Process ajax request for refresh crm modules
65 77 *
66 - * @return JSON crm module data
78 + * @return string JSON crm module data
67 79 */
68 - public static function refreshNeswLetter() {
80 + public static function refreshNeswLetter()
81 + {
69 82 $response = null;
70 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
83 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
71 84 if (class_exists(\MailPoet\API\API::class)) {
72 85 $mailpoet_api = \MailPoet\API\API::MP('v1');
73 86 $newsletterList = $mailpoet_api->getLists();
74 87
@@ -84,9 +97,9 @@
84 97 wp_send_json_success($response, 200);
85 98 } else {
86 99 wp_send_json_error(
87 100 __(
88 - 'Please! Insatall MailPoet',
101 + 'Please! Install MailPoet',
89 102 'bit-form'
90 103 ),
91 104 400
92 105 );
@@ -101,11 +114,12 @@
101 114 );
102 115 }
103 116 }
104 117
105 - public static function mailPoetListHeaders() {
118 + public static function mailPoetListHeaders()
119 + {
106 120 $response = null;
107 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
121 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
108 122 if (class_exists(\MailPoet\API\API::class)) {
109 123 $mailpoet_api = \MailPoet\API\API::MP('v1');
110 124 $subscriber_form_fields = $mailpoet_api->getSubscriberFields();
111 125
@@ -139,28 +153,26 @@
139 153 );
140 154 }
141 155 }
142 156
143 - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) {
157 + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID)
158 + {
144 159 $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details;
145 - // var_dump($integrationData, $fieldValues, $entryID, $logID);
146 - // wp_send_json_success($integrationDetails);
147 160
148 161 $fieldMap = $integrationDetails->field_map;
149 162 $defaultDataConf = $integrationDetails->default;
150 163 $lists = $integrationDetails->lists;
151 - // wp_send_json_success($fieldMap);
152 164 if (empty($fieldMap)) {
153 165 return new WP_Error('REQ_FIELD_EMPTY', __('module, fields are required for Mail Poet api', 'bit-form'));
154 166 }
155 167
156 - // $actions = $integrationDetails->actions;
157 168 $recordApiHelper = new RecordApiHelper($this->_integrationID, $logID, $entryID);
158 169
159 170 $maiPoetApiResponse = $recordApiHelper->executeRecordApi(
160 171 $fieldValues,
161 172 $fieldMap,
162 - $lists
173 + $lists,
174 + $this->formId,
163 175 );
164 176
165 177 if (is_wp_error($maiPoetApiResponse)) {
166 178 return $maiPoetApiResponse;