← All changes
|
includes/Core/Integration/MailChimp/MailChimpHandler.php
+14
-45
3.2.2
→
2.15.3
View file →
| @@ -6,15 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\MailChimp; |
| 9 | 9 | |
| 10 | -if (!defined('ABSPATH')) { | |
| 11 | - exit; | |
| 12 | -} | |
| 13 | - | |
| 14 | 10 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 15 | 11 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 16 | -use BitCode\BitForm\GlobalHelper; | |
| 17 | 12 | use WP_Error; |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * Provide functionality for MailChimp integration |
| @@ -22,15 +17,11 @@ | ||
| 22 | 17 | class MailChimpHandler |
| 23 | 18 | { |
| 24 | 19 | private $_integrationID; |
| 25 | 20 | |
| 26 | - private $formId; | |
| 27 | - | |
| 28 | 21 | public function __construct($integrationID, $fromID) |
| 29 | 22 | { |
| 30 | 23 | $this->_integrationID = $integrationID; |
| 31 | - | |
| 32 | - $this->formId = $fromID; | |
| 33 | 24 | } |
| 34 | 25 | |
| 35 | 26 | /** |
| 36 | 27 | * MailChimp API Endpoint |
| @@ -59,18 +50,12 @@ | ||
| 59 | 50 | * @return JSON zoho crm api response and status |
| 60 | 51 | */ |
| 61 | 52 | public static function generateTokens() |
| 62 | 53 | { |
| 63 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 54 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 64 | 55 | $authorizationHeader = null; |
| 65 | - | |
| 66 | - GlobalHelper::requirePostMethod(); | |
| 67 | - | |
| 68 | - try { | |
| 69 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 70 | - } catch (\InvalidArgumentException $e) { | |
| 71 | - wp_send_json_error($e->getMessage(), 400); | |
| 72 | - } | |
| 56 | + $inputJSON = file_get_contents('php://input'); | |
| 57 | + $requestsParams = json_decode($inputJSON); | |
| 73 | 58 | if ( |
| 74 | 59 | empty($requestsParams->clientId) |
| 75 | 60 | || empty($requestsParams->clientSecret) |
| 76 | 61 | || empty($requestsParams->redirectURI) |
| @@ -128,18 +113,13 @@ | ||
| 128 | 113 | * @return JSON MailChimp data |
| 129 | 114 | */ |
| 130 | 115 | public static function refreshAudienceAjaxHelper() |
| 131 | 116 | { |
| 132 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 117 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 133 | 118 | $authorizationHeader = null; |
| 119 | + $inputJSON = file_get_contents('php://input'); | |
| 120 | + $queryParams = json_decode($inputJSON); | |
| 134 | 121 | |
| 135 | - GlobalHelper::requirePostMethod(); | |
| 136 | - | |
| 137 | - try { | |
| 138 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 139 | - } catch (\InvalidArgumentException $e) { | |
| 140 | - wp_send_json_error($e->getMessage(), 400); | |
| 141 | - } | |
| 142 | 122 | if ( |
| 143 | 123 | empty($queryParams->tokenDetails) |
| 144 | 124 | || empty($queryParams->clientId) |
| 145 | 125 | || empty($queryParams->clientSecret) |
| @@ -198,17 +178,12 @@ | ||
| 198 | 178 | public static function refreshAudienceFields() |
| 199 | 179 | { |
| 200 | 180 | $authorizationHeader = null; |
| 201 | 181 | $response = null; |
| 202 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 182 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 183 | + $inputJSON = file_get_contents('php://input'); | |
| 184 | + $queryParams = json_decode($inputJSON); | |
| 203 | 185 | // wp_send_json_success($queryParams); |
| 204 | - GlobalHelper::requirePostMethod(); | |
| 205 | - | |
| 206 | - try { | |
| 207 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 208 | - } catch (\InvalidArgumentException $e) { | |
| 209 | - wp_send_json_error($e->getMessage(), 400); | |
| 210 | - } | |
| 211 | 186 | if ( |
| 212 | 187 | empty($queryParams->tokenDetails) |
| 213 | 188 | || empty($queryParams->listId) |
| 214 | 189 | || empty($queryParams->tokenDetails->dc) |
| @@ -259,17 +234,12 @@ | ||
| 259 | 234 | public static function refreshTagsAjaxHelper() |
| 260 | 235 | { |
| 261 | 236 | $authorizationHeader = null; |
| 262 | 237 | $response = null; |
| 263 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 264 | - GlobalHelper::requirePostMethod(); | |
| 265 | - | |
| 266 | - try { | |
| 267 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 268 | - } catch (\InvalidArgumentException $e) { | |
| 269 | - wp_send_json_error($e->getMessage(), 400); | |
| 270 | - } | |
| 271 | - | |
| 238 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 239 | + $inputJSON = file_get_contents('php://input'); | |
| 240 | + $queryParams = json_decode($inputJSON); | |
| 241 | + // wp_send_json_success($queryParams); | |
| 272 | 242 | if ( |
| 273 | 243 | empty($queryParams->tokenDetails) |
| 274 | 244 | || empty($queryParams->listId) |
| 275 | 245 | || empty($queryParams->tokenDetails->dc) |
| @@ -343,10 +313,9 @@ | ||
| 343 | 313 | $defaultDataConf, |
| 344 | 314 | $fieldValues, |
| 345 | 315 | $fieldMap, |
| 346 | 316 | $actions, |
| 347 | - $addressFields, | |
| 348 | - $this->formId | |
| 317 | + $addressFields | |
| 349 | 318 | ); |
| 350 | 319 | |
| 351 | 320 | if (is_wp_error($mChimpApiResponse)) { |
| 352 | 321 | return $mChimpApiResponse; |