← All changes
|
includes/Core/Integration/Encharge/EnchargeHandler.php
+7
-29
3.3.1
→
2.15.3
View file →
| @@ -6,15 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\Encharge; |
| 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 Encharge integration |
| @@ -21,17 +16,13 @@ | ||
| 21 | 16 | */ |
| 22 | 17 | class EnchargeHandler |
| 23 | 18 | { |
| 24 | 19 | private $_integrationID; |
| 25 | - | |
| 26 | - private $formId; | |
| 27 | 20 | public static $api_endpoint = 'https://api.encharge.io/v1/'; |
| 28 | 21 | |
| 29 | 22 | public function __construct($integrationID, $fromID) |
| 30 | 23 | { |
| 31 | 24 | $this->_integrationID = $integrationID; |
| 32 | - | |
| 33 | - $this->formId = $fromID; | |
| 34 | 25 | } |
| 35 | 26 | |
| 36 | 27 | /** |
| 37 | 28 | * Helps to register ajax function's with wp |
| @@ -51,17 +42,11 @@ | ||
| 51 | 42 | */ |
| 52 | 43 | public static function enChargeAuthorize() |
| 53 | 44 | { |
| 54 | 45 | $authorizationHeader = null; |
| 55 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 56 | - GlobalHelper::requirePostMethod(); | |
| 57 | - | |
| 58 | - try { | |
| 59 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 60 | - } catch (\InvalidArgumentException $e) { | |
| 61 | - wp_send_json_error($e->getMessage(), 400); | |
| 62 | - } | |
| 63 | - | |
| 46 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 47 | + $inputJSON = file_get_contents('php://input'); | |
| 48 | + $requestsParams = json_decode($inputJSON); | |
| 64 | 49 | if ( |
| 65 | 50 | empty($requestsParams->api_key) |
| 66 | 51 | ) { |
| 67 | 52 | wp_send_json_error( |
| @@ -105,17 +90,11 @@ | ||
| 105 | 90 | public static function enchargeHeaders() |
| 106 | 91 | { |
| 107 | 92 | $authorizationHeader = null; |
| 108 | 93 | $response = null; |
| 109 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 110 | - GlobalHelper::requirePostMethod(); | |
| 111 | - | |
| 112 | - try { | |
| 113 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 114 | - } catch (\InvalidArgumentException $e) { | |
| 115 | - wp_send_json_error($e->getMessage(), 400); | |
| 116 | - } | |
| 117 | - | |
| 94 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 95 | + $inputJSON = file_get_contents('php://input'); | |
| 96 | + $queryParams = json_decode($inputJSON); | |
| 118 | 97 | if ( |
| 119 | 98 | empty($queryParams->api_key) |
| 120 | 99 | ) { |
| 121 | 100 | wp_send_json_error( |
| @@ -173,10 +152,9 @@ | ||
| 173 | 152 | $recordApiHelper = new RecordApiHelper($api_key, $this->_integrationID, $logID, $entryID); |
| 174 | 153 | $enchagreApiResponse = $recordApiHelper->executeRecordApi( |
| 175 | 154 | $fieldValues, |
| 176 | 155 | $fieldMap, |
| 177 | - $tags, | |
| 178 | - $this->formId | |
| 156 | + $tags | |
| 179 | 157 | ); |
| 180 | 158 | |
| 181 | 159 | if (is_wp_error($enchagreApiResponse)) { |
| 182 | 160 | return $enchagreApiResponse; |