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