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/SendFox/SendFoxHandler.php +38 -13 2.03.3.1 View file →
@@ -5,32 +5,49 @@
5 5 */
6 6
7 7 namespace BitCode\BitForm\Core\Integration\SendFox;
8 8
9 +if (!defined('ABSPATH')) {
10 + exit;
11 +}
12 +
9 13 use BitCode\BitForm\Core\Integration\IntegrationHandler;
10 14 use BitCode\BitForm\Core\Util\HttpHelper;
15 +use BitCode\BitForm\GlobalHelper;
11 16 use WP_Error;
12 17
13 -class SendFoxHandler {
18 +class SendFoxHandler
19 +{
14 20 private $integrationID;
15 21 public static $baseUrl = 'https://api.sendfox.com/';
16 22
17 - public function __construct($integrationID, $fromID) {
23 + private $formId;
24 +
25 + public function __construct($integrationID, $fromID)
26 + {
18 27 $this->integrationID = $integrationID;
28 + $this->formId = $fromID;
19 29 }
20 30
21 - public static function registerAjax() {
31 + public static function registerAjax()
32 + {
22 33 add_action('wp_ajax_bitforms_sendFox_authorize', [__CLASS__, 'sendFoxAuthorize']);
23 34 add_action('wp_ajax_bitforms_sendfox_fetch_all_list', [__CLASS__, 'fetchContactLists']);
24 35 }
25 36
26 - public static function sendFoxAuthorize($requestParams) {
27 - if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
37 + public static function sendFoxAuthorize($requestParams)
38 + {
39 + if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
28 40 wp_send_json_error(__('Token expired', 'bit-form'), 401);
29 41 }
30 42
31 - $inputJSON = file_get_contents('php://input');
32 - $requestParams = json_decode($inputJSON);
43 + GlobalHelper::requirePostMethod();
44 +
45 + try {
46 + $requestParams = GlobalHelper::formatRequestData();
47 + } catch (\InvalidArgumentException $e) {
48 + wp_send_json_error($e->getMessage(), 400);
49 + }
33 50 if (empty($requestParams->access_token)) {
34 51 wp_send_json_error(
35 52 __(
36 53 'Requested parameter is empty',
@@ -55,16 +72,22 @@
55 72 );
56 73 }
57 74 }
58 75
59 - public static function fetchContactLists($requestParams) {
60 - if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
76 + public static function fetchContactLists($requestParams)
77 + {
78 + if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
61 79 wp_send_json_error(__('Token expired', 'bit-form'), 401);
62 80 }
63 81
64 - $inputJSON = file_get_contents('php://input');
65 - $requestParams = json_decode($inputJSON);
82 + GlobalHelper::requirePostMethod();
66 83
84 + try {
85 + $requestParams = GlobalHelper::formatRequestData();
86 + } catch (\InvalidArgumentException $e) {
87 + wp_send_json_error($e->getMessage(), 400);
88 + }
89 +
67 90 if (empty($requestParams->access_token)) {
68 91 wp_send_json_error(
69 92 __(
70 93 'Requested parameter is empty',
@@ -91,9 +114,10 @@
91 114 );
92 115 }
93 116 }
94 117
95 - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) {
118 + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID)
119 + {
96 120 $integrationDetails = json_decode($integrationData->integration_details);
97 121 $access_token = $integrationDetails->access_token;
98 122 $listId = $integrationDetails->listId;
99 123 $mainAction = $integrationDetails->mainAction;
@@ -111,9 +135,10 @@
111 135 $mainAction,
112 136 $fieldValues,
113 137 $fieldMap,
114 138 $access_token,
115 - $integrationDetails
139 + $integrationDetails,
140 + $this->formId
116 141 );
117 142
118 143 if (is_wp_error($sendFoxApiResponse)) {
119 144 return $sendFoxApiResponse;