← All changes
|
includes/Core/Integration/ActiveCampaign/ActiveCampaignHandler.php
+40
-15
2.10.0
→
3.3.1
View file →
| @@ -6,10 +6,15 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ActiveCampaign; |
| 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\HttpHelper; |
| 16 | +use BitCode\BitForm\GlobalHelper; | |
| 12 | 17 | use WP_Error; |
| 13 | 18 | |
| 14 | 19 | /** |
| 15 | 20 | * Provide functionality for ZohoCrm integration |
| @@ -49,11 +54,17 @@ | ||
| 49 | 54 | * @return string Active Campaign api response and status |
| 50 | 55 | */ |
| 51 | 56 | public static function activeCampaignAuthorize() |
| 52 | 57 | { |
| 53 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 54 | - $inputJSON = file_get_contents('php://input'); | |
| 55 | - $requestsParams = json_decode($inputJSON); | |
| 58 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 59 | + GlobalHelper::requirePostMethod(); | |
| 60 | + | |
| 61 | + try { | |
| 62 | + $requestsParams = GlobalHelper::formatRequestData(); | |
| 63 | + } catch (\InvalidArgumentException $e) { | |
| 64 | + wp_send_json_error($e->getMessage(), 400); | |
| 65 | + } | |
| 66 | + | |
| 56 | 67 | if ( |
| 57 | 68 | empty($requestsParams->api_key) |
| 58 | 69 | || empty($requestsParams->api_url) |
| 59 | 70 | ) { |
| @@ -96,12 +107,15 @@ | ||
| 96 | 107 | * @return JSON active campaign list data |
| 97 | 108 | */ |
| 98 | 109 | public static function activeCampaignLists() |
| 99 | 110 | { |
| 100 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 101 | - $inputJSON = file_get_contents('php://input'); | |
| 102 | - $queryParams = json_decode($inputJSON); | |
| 103 | - | |
| 111 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 112 | + GlobalHelper::requirePostMethod(); | |
| 113 | + try { | |
| 114 | + $queryParams = GlobalHelper::formatRequestData(); | |
| 115 | + } catch (\InvalidArgumentException $e) { | |
| 116 | + wp_send_json_error($e->getMessage(), 400); | |
| 117 | + } | |
| 104 | 118 | if ( |
| 105 | 119 | empty($queryParams->api_key) |
| 106 | 120 | || empty($queryParams->api_url) |
| 107 | 121 | ) { |
| @@ -150,12 +164,17 @@ | ||
| 150 | 164 | * @return JSON active campaign tags data |
| 151 | 165 | */ |
| 152 | 166 | public static function activeCampaignTags() |
| 153 | 167 | { |
| 154 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 155 | - $inputJSON = file_get_contents('php://input'); | |
| 156 | - $queryParams = json_decode($inputJSON); | |
| 168 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 169 | + GlobalHelper::requirePostMethod(); | |
| 157 | 170 | |
| 171 | + try { | |
| 172 | + $queryParams = GlobalHelper::formatRequestData(); | |
| 173 | + } catch (\InvalidArgumentException $e) { | |
| 174 | + wp_send_json_error($e->getMessage(), 400); | |
| 175 | + } | |
| 176 | + | |
| 158 | 177 | if ( |
| 159 | 178 | empty($queryParams->api_key) |
| 160 | 179 | || empty($queryParams->api_url) |
| 161 | 180 | ) { |
| @@ -205,12 +224,17 @@ | ||
| 205 | 224 | */ |
| 206 | 225 | public static function activeCampaignHeaders() |
| 207 | 226 | { |
| 208 | 227 | $authorizationHeader = null; |
| 209 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 210 | - $inputJSON = file_get_contents('php://input'); | |
| 211 | - $queryParams = json_decode($inputJSON); | |
| 228 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 229 | + GlobalHelper::requirePostMethod(); | |
| 212 | 230 | |
| 231 | + try { | |
| 232 | + $queryParams = GlobalHelper::formatRequestData(); | |
| 233 | + } catch (\InvalidArgumentException $e) { | |
| 234 | + wp_send_json_error($e->getMessage(), 400); | |
| 235 | + } | |
| 236 | + | |
| 213 | 237 | if ( |
| 214 | 238 | empty($queryParams->api_key) |
| 215 | 239 | || empty($queryParams->api_url) |
| 216 | 240 | ) { |
| @@ -280,9 +304,10 @@ | ||
| 280 | 304 | $fieldValues, |
| 281 | 305 | $fieldMap, |
| 282 | 306 | $actions, |
| 283 | 307 | $listId, |
| 284 | - $tags | |
| 308 | + $tags, | |
| 309 | + $this->_formID | |
| 285 | 310 | ); |
| 286 | 311 | |
| 287 | 312 | if (is_wp_error($activeCampaignApiResponse)) { |
| 288 | 313 | return $activeCampaignApiResponse; |
| @@ -288,5 +313,5 @@ | ||
| 288 | 313 | return $activeCampaignApiResponse; |
| 289 | 314 | } |
| 290 | 315 | return $activeCampaignApiResponse; |
| 291 | 316 | } |
| 292 | -} | |
| 317 | +} | |