← All changes
|
includes/Core/Integration/FluentCrm/FluentCrmHandler.php
+25
-12
2.0
→
V3.3.2
View file →
| @@ -6,8 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\FluentCrm; |
| 9 | 9 | |
| 10 | +if (!defined('ABSPATH')) { | |
| 11 | + exit; | |
| 12 | +} | |
| 13 | + | |
| 10 | 14 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 11 | 15 | use FluentCrm\App\Models\CustomContactField; |
| 12 | 16 | use FluentCrm\App\Models\Lists; |
| 13 | 17 | use FluentCrm\App\Models\Subscriber; |
| @@ -16,13 +20,15 @@ | ||
| 16 | 20 | |
| 17 | 21 | /** |
| 18 | 22 | * Provide functionality for ZohoCrm integration |
| 19 | 23 | */ |
| 20 | -class FluentCrmHandler { | |
| 24 | +class FluentCrmHandler | |
| 25 | +{ | |
| 21 | 26 | private $_formID; |
| 22 | 27 | private $_integrationID; |
| 23 | 28 | |
| 24 | - public function __construct($integrationID, $fromID) { | |
| 29 | + public function __construct($integrationID, $fromID) | |
| 30 | + { | |
| 25 | 31 | $this->_formID = $fromID; |
| 26 | 32 | $this->_integrationID = $integrationID; |
| 27 | 33 | } |
| 28 | 34 | |
| @@ -30,9 +36,10 @@ | ||
| 30 | 36 | * Helps to register ajax function's with wp |
| 31 | 37 | * |
| 32 | 38 | * @return null |
| 33 | 39 | */ |
| 34 | - public static function registerAjax() { | |
| 40 | + public static function registerAjax() | |
| 41 | + { | |
| 35 | 42 | add_action('wp_ajax_bitforms_fluent_crm_authorize', [__CLASS__, 'fluentCrmAuthorize']); |
| 36 | 43 | add_action('wp_ajax_bitforms_refresh_fluent_crm_lists', [__CLASS__, 'fluentCrmLists']); |
| 37 | 44 | add_action('wp_ajax_bitforms_fluent_crm_headers', [__CLASS__, 'fluentCrmFields']); |
| 38 | 45 | } |
| @@ -39,9 +46,10 @@ | ||
| 39 | 46 | |
| 40 | 47 | /** |
| 41 | 48 | * for chen fluent crm plugins are exists |
| 42 | 49 | */ |
| 43 | - public static function checkedExistsFluentCRM() { | |
| 50 | + public static function checkedExistsFluentCRM() | |
| 51 | + { | |
| 44 | 52 | return is_plugin_active('fluent-crm/fluent-crm.php') ? true : false; |
| 45 | 53 | } |
| 46 | 54 | |
| 47 | 55 | /** |
| @@ -46,10 +54,11 @@ | ||
| 46 | 54 | |
| 47 | 55 | /** |
| 48 | 56 | * @return Fluent CRM lists |
| 49 | 57 | */ |
| 50 | - public static function fluentCrmLists() { | |
| 51 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 58 | + public static function fluentCrmLists() | |
| 59 | + { | |
| 60 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 52 | 61 | $response = null; |
| 53 | 62 | if (self::checkedExistsFluentCRM()) { |
| 54 | 63 | $lists = Lists::get(); |
| 55 | 64 | $fluentCrmList = []; |
| @@ -89,10 +98,11 @@ | ||
| 89 | 98 | ); |
| 90 | 99 | } |
| 91 | 100 | } |
| 92 | 101 | |
| 93 | - public static function fluentCrmFields() { | |
| 94 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 102 | + public static function fluentCrmFields() | |
| 103 | + { | |
| 104 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 95 | 105 | $response = null; |
| 96 | 106 | if (self::checkedExistsFluentCRM()) { |
| 97 | 107 | $fieldOptions = []; |
| 98 | 108 | $primaryField = ['first_name', 'last_name', 'full_name', 'email']; |
| @@ -152,10 +162,11 @@ | ||
| 152 | 162 | |
| 153 | 163 | /** |
| 154 | 164 | * @return True Fluent crm are exists |
| 155 | 165 | */ |
| 156 | - public static function fluentCrmAuthorize() { | |
| 157 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 166 | + public static function fluentCrmAuthorize() | |
| 167 | + { | |
| 168 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 158 | 169 | if (self::checkedExistsFluentCRM()) { |
| 159 | 170 | wp_send_json_success(true); |
| 160 | 171 | } else { |
| 161 | 172 | wp_send_json_error( |
| @@ -176,9 +187,10 @@ | ||
| 176 | 187 | ); |
| 177 | 188 | } |
| 178 | 189 | } |
| 179 | 190 | |
| 180 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 191 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 192 | + { | |
| 181 | 193 | $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details; |
| 182 | 194 | |
| 183 | 195 | // wp_send_json_success($integrationDetails); |
| 184 | 196 | |
| @@ -198,9 +210,10 @@ | ||
| 198 | 210 | $fieldValues, |
| 199 | 211 | $fieldMap, |
| 200 | 212 | $actions, |
| 201 | 213 | $list_id, |
| 202 | - $tags | |
| 214 | + $tags, | |
| 215 | + $this->_formID | |
| 203 | 216 | ); |
| 204 | 217 | |
| 205 | 218 | if (is_wp_error($fluentCrmApiResponse)) { |
| 206 | 219 | return $fluentCrmApiResponse; |