← All changes
|
includes/Core/Integration/ElasticEmail/ElasticEmailHandler.php
+9
-35
3.2.2
→
2.15.3
View file →
| @@ -5,15 +5,10 @@ | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | namespace BitCode\BitForm\Core\Integration\ElasticEmail; |
| 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 | /** |
| 19 | 14 | * Provide functionality for ZohoCrm integration |
| @@ -19,18 +14,8 @@ | ||
| 19 | 14 | * Provide functionality for ZohoCrm integration |
| 20 | 15 | */ |
| 21 | 16 | class ElasticEmailHandler |
| 22 | 17 | { |
| 23 | - private $formID; | |
| 24 | - | |
| 25 | - private $integrationID; | |
| 26 | - | |
| 27 | - public function __construct($integrationID, $fromID) | |
| 28 | - { | |
| 29 | - $this->formID = $fromID; | |
| 30 | - $this->integrationID = $integrationID; | |
| 31 | - } | |
| 32 | - | |
| 33 | 18 | public static function registerAjax() |
| 34 | 19 | { |
| 35 | 20 | add_action('wp_ajax_bitforms_elasticemail_authorize', [__CLASS__, 'elasticEmailAuthorize']); |
| 36 | 21 | add_action('wp_ajax_bitforms_get_all_lists', [__CLASS__, 'getAllLists']); |
| @@ -37,17 +22,12 @@ | ||
| 37 | 22 | } |
| 38 | 23 | |
| 39 | 24 | public static function elasticEmailAuthorize() |
| 40 | 25 | { |
| 41 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 42 | - GlobalHelper::requirePostMethod(); | |
| 26 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 27 | + $inputJSON = file_get_contents('php://input'); | |
| 28 | + $requestsParams = json_decode($inputJSON); | |
| 43 | 29 | |
| 44 | - try { | |
| 45 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 46 | - } catch (\InvalidArgumentException $e) { | |
| 47 | - wp_send_json_error($e->getMessage(), 400); | |
| 48 | - } | |
| 49 | - | |
| 50 | 30 | if (empty($requestsParams->api_key)) { |
| 51 | 31 | wp_send_json_error( |
| 52 | 32 | __( |
| 53 | 33 | 'Requested parameter is empty', |
| @@ -76,19 +56,13 @@ | ||
| 76 | 56 | } |
| 77 | 57 | |
| 78 | 58 | public static function getAllLists() |
| 79 | 59 | { |
| 80 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 60 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 81 | 61 | $response = null; |
| 62 | + $inputJSON = file_get_contents('php://input'); | |
| 63 | + $requestsParams = json_decode($inputJSON); | |
| 82 | 64 | |
| 83 | - GlobalHelper::requirePostMethod(); | |
| 84 | - | |
| 85 | - try { | |
| 86 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 87 | - } catch (\InvalidArgumentException $e) { | |
| 88 | - wp_send_json_error($e->getMessage(), 400); | |
| 89 | - } | |
| 90 | - | |
| 91 | 65 | if (empty($requestsParams->apiKey)) { |
| 92 | 66 | wp_send_json_error( |
| 93 | 67 | __( |
| 94 | 68 | 'Requested parameter is empty', |
| @@ -135,15 +109,15 @@ | ||
| 135 | 109 | || empty($fieldMap) |
| 136 | 110 | ) { |
| 137 | 111 | return new WP_Error('REQ_FIELD_EMPTY', __('module, fields are required for Elastic Email api', 'bit-form')); |
| 138 | 112 | } |
| 139 | - $recordApiHelper = new RecordApiHelper($api_key, $integId, $logID, $integrationDetails, $entryID); | |
| 113 | + $recordApiHelper = new RecordApiHelper($api_key, $integId, $logID, $integrationDetails); | |
| 140 | 114 | $elasticEmailApiResponse = $recordApiHelper->execute( |
| 141 | 115 | $integId, |
| 142 | 116 | $fieldValues, |
| 143 | 117 | $fieldMap, |
| 144 | - $integrationDetails, | |
| 145 | - $this->formID, | |
| 118 | + $integrationDetails | |
| 119 | + // $actions | |
| 146 | 120 | ); |
| 147 | 121 | |
| 148 | 122 | if (is_wp_error($elasticEmailApiResponse)) { |
| 149 | 123 | return $elasticEmailApiResponse; |