PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.3.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.3.2
V3.3.3 V3.3.2 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 All 140 releases
← All changes | includes/Core/Integration/Autonami/AutonamiHandler.php +30 -13 2.0 → V3.3.2 View file →
@@ -6,8 +6,12 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\Autonami;
9 9
10 +if (!defined('ABSPATH')) {
11 + exit;
12 +}
13 +
10 14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
11 15 use BitCode\BitForm\Core\Util\ApiResponse as UtilApiResponse;
12 16 use BWFCRM_Fields;
13 17 use BWFCRM_Lists;
@@ -13,13 +17,15 @@
13 17 use BWFCRM_Lists;
14 18 use BWFCRM_Tag;
15 19 use WP_Error;
16 20
17 -class AutonamiHandler {
21 +class AutonamiHandler
22 +{
18 23 private $_formID;
19 24 private $_integrationID;
20 25
21 - public function __construct($integrationID, $fromID) {
26 + public function __construct($integrationID, $fromID)
27 + {
22 28 $this->_formID = $fromID;
23 29 $this->_integrationID = $integrationID;
24 30 }
25 31
@@ -27,9 +33,10 @@
27 33 * Helps to register ajax function's with wp
28 34 *
29 35 * @return null
30 36 */
31 - public static function registerAjax() {
37 + public static function registerAjax()
38 + {
32 39 add_action('wp_ajax_bitforms_autonami_authorize', [__CLASS__, 'autonamiAuthorize']);
33 40 add_action('wp_ajax_bitforms_autonami_lists_and_tags', [__CLASS__, 'autonamiListsAndTags']);
34 41 add_action('wp_ajax_bitforms_autonami_fields', [__CLASS__, 'autonamiFields']);
35 42 }
@@ -36,9 +43,10 @@
36 43
37 44 /**
38 45 * for chen autonami pro plugins are exists
39 46 */
40 - public static function checkedExistsAutonami() {
47 + public static function checkedExistsAutonami()
48 + {
41 49 if (!class_exists('BWFCRM_Contact')) {
42 50 wp_send_json_error(__('Autonami Pro Plugins not found', 'bit-form'), 400);
43 51 } else {
44 52 return true;
@@ -47,10 +55,11 @@
47 55
48 56 /**
49 57 * @return Autonami lists
50 58 */
51 - public static function autonamiListsAndTags() {
52 - if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
59 + public static function autonamiListsAndTags()
60 + {
61 + if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
53 62 wp_send_json_error(__('Token expired', 'bit-form'), 401);
54 63 }
55 64
56 65 self::checkedExistsAutonami();
@@ -77,10 +86,11 @@
77 86 $response['autonamiTags'] = $autonamiTags;
78 87 wp_send_json_success($response, 200);
79 88 }
80 89
81 - public static function autonamiFields() {
82 - if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
90 + public static function autonamiFields()
91 + {
92 + if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
83 93 wp_send_json_error(__('Token expired', 'bit-form'), 401);
84 94 }
85 95
86 96 self::checkedExistsAutonami();
@@ -112,10 +122,11 @@
112 122
113 123 /**
114 124 * @return True Autonami are exists
115 125 */
116 - public static function autonamiAuthorize() {
117 - if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
126 + public static function autonamiAuthorize()
127 + {
128 + if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
118 129 wp_send_json_error(__('Token expired', 'bit-form'), 401);
119 130 }
120 131
121 132 if (self::checkedExistsAutonami()) {
@@ -124,11 +135,17 @@
124 135 wp_send_json_error(__('Autonami Pro Plugins not found', 'bit-form'), 400);
125 136 }
126 137 }
127 138
128 - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) {
139 + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID)
140 + {
141 + $entryDetails = [
142 + 'formId' => $this->_formID,
143 + 'entryId' => $entryID,
144 + 'fieldValues' => $fieldValues
145 + ];
129 146 if (!class_exists('BWFCRM_Contact')) {
130 - (new UtilApiResponse())->apiResponse($logID, $this->_integrationID, ['type' => 'record', 'type_name' => 'insert'], 'error', 'Autonami Pro Plugins not found');
147 + (new UtilApiResponse())->apiResponse($logID, $this->_integrationID, ['type' => 'record', 'type_name' => 'insert'], 'error', 'Autonami Pro Plugins not found', $entryDetails);
131 148 return;
132 149 }
133 150
134 151 $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details;
@@ -142,9 +159,9 @@
142 159 return new WP_Error('REQ_FIELD_EMPTY', __('module, fields are required for Autonami api', 'bit-form'));
143 160 }
144 161
145 162 $recordApiHelper = new RecordApiHelper($this->_integrationID, $logID, $entryID);
146 - $autonamiApiResponse = $recordApiHelper->executeRecordApi($fieldValues, $fieldMap, $actions, $lists, $tags);
163 + $autonamiApiResponse = $recordApiHelper->executeRecordApi($fieldValues, $fieldMap, $actions, $lists, $tags, $this->_formID);
147 164
148 165 if (is_wp_error($autonamiApiResponse)) {
149 166 return $autonamiApiResponse;
150 167 }