Creative Mail – Easier WordPress & WooCommerce Email Marketing - Version 1.3.4

Version Description

Download this release

Release Info

Developer constantcontact
Plugin Icon 128x128 Creative Mail – Easier WordPress & WooCommerce Email Marketing
Version 1.3.4
Comparing to
See all releases

Code changes from version 1.3.3 to 1.3.4

Files changed (33) hide show
  1. CHANGELOG.md +3 -0
  2. README.md +4 -3
  3. creative-mail-plugin.php +4 -4
  4. readme.txt +2 -2
  5. src/CreativeMail.php +8 -0
  6. src/helpers/ValidationHelper.php +12 -0
  7. src/managers/AdminManager.php +8 -2
  8. src/managers/ApiManager.php +1 -1
  9. src/managers/IntegrationManager.php +6 -5
  10. src/modules/DashboardWidgetModule.php +14 -10
  11. src/modules/contacts/Exceptions/InvalidContactSyncBackgroundRequestException.php +13 -0
  12. src/modules/contacts/Exceptions/InvalidHandlerContactSyncRequestException.php +13 -0
  13. src/modules/contacts/Handlers/BaseContactFormPluginHandler.php +7 -1
  14. src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php +116 -0
  15. src/modules/contacts/Handlers/CalderaPluginHandler.php +47 -25
  16. src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php +21 -15
  17. src/modules/contacts/Handlers/ElementorPluginHandler.php +24 -17
  18. src/modules/contacts/Handlers/GravityFormsPluginHandler.php +39 -23
  19. src/modules/contacts/Handlers/JetpackPluginHandler.php +24 -14
  20. src/modules/contacts/Handlers/NewsLetterContactFormPluginHandler.php +4 -14
  21. src/modules/contacts/Handlers/NinjaFormsPluginHandler.php +44 -29
  22. src/modules/contacts/Handlers/WooCommercePluginHandler.php +8 -9
  23. src/modules/contacts/Handlers/WpFormsPluginHandler.php +20 -13
  24. src/modules/contacts/Managers/ContactsSyncManager.php +30 -0
  25. src/modules/contacts/Processes/ContactsSyncBackgroundProcessor.php +79 -0
  26. src/modules/contacts/Services/ContactsSyncService.php +211 -16
  27. src/modules/contacts/models/ContactModel.php +16 -0
  28. src/views/contact-sync.php +22 -0
  29. src/views/settings.php +5 -18
  30. vendor/autoload.php +1 -1
  31. vendor/composer/autoload_classmap.php +6 -0
  32. vendor/composer/autoload_real.php +4 -4
  33. vendor/composer/autoload_static.php +11 -5
CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
  Changelog
2
  =========
3
 
 
 
 
4
  #### 1.3.3 - March 3 2021
5
  - UI Improvements on the settings screen.
6
  - Direct access to Creative Mail features from the left side nav in WP Admin.
1
  Changelog
2
  =========
3
 
4
+ #### 1.3.4 - March 16 2021
5
+ - Improved initial contact sync: we can now import all your contacts without any limits!
6
+
7
  #### 1.3.3 - March 3 2021
8
  - UI Improvements on the settings screen.
9
  - Direct access to Creative Mail features from the left side nav in WP Admin.
README.md CHANGED
@@ -2,14 +2,14 @@
2
  Contributors: Constant Contact
3
  Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
4
  Requires at least: 4.6
5
- Tested up to: 5.6
6
- Stable tag: 1.3.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.6
10
  Website: https://www.creativemail.com
11
  WC requires at least: 3.0.0
12
- WC tested up to: 5.0.0
13
 
14
  == Description ==
15
  Creative Mail was designed specifically for WordPress and WooCommerce.
@@ -90,6 +90,7 @@ Creative Mail by Constant Contact [Privacy Notice](https://www.endurance.com/pri
90
  6. Enhance your brand with logomaker
91
 
92
  == Changelog ==
 
93
  * 1.3.3 - Direct access to Creative Mail features from the left side nav in WP Admin.
94
  * 1.3.2 - Fixes an issue where the contact sync might cause a critical error.
95
  * 1.3.1 - Add the ability to show the amount of recovered revenue via abandoned carts.
2
  Contributors: Constant Contact
3
  Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
4
  Requires at least: 4.6
5
+ Tested up to: 5.7
6
+ Stable tag: 1.3.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.6
10
  Website: https://www.creativemail.com
11
  WC requires at least: 3.0.0
12
+ WC tested up to: 5.1.0
13
 
14
  == Description ==
15
  Creative Mail was designed specifically for WordPress and WooCommerce.
90
  6. Enhance your brand with logomaker
91
 
92
  == Changelog ==
93
+ * 1.3.4 - Improved initial contact sync: we can now import all your contacts without any limits!
94
  * 1.3.3 - Direct access to Creative Mail features from the left side nav in WP Admin.
95
  * 1.3.2 - Fixes an issue where the contact sync might cause a critical error.
96
  * 1.3.1 - Add the ability to show the amount of recovered revenue via abandoned carts.
creative-mail-plugin.php CHANGED
@@ -9,10 +9,10 @@
9
  * Plugin URI: https://wordpress.org/plugins/creative-mail-by-constant-contact/
10
  * Description: Free email marketing designed specifically for WordPress, Jetpack and WooCommerce. Send newsletters, promotions, updates and transactional e-commerce emails. Simple and easy, powered by Constant Contact’s rock solid reliability.
11
  * Author: Constant Contact
12
- * Version: 1.3.3
13
  * Author URI: https://www.constantcontact.com
14
  * WC requires at least: 3.0.0
15
- * WC tested up to: 5.0.0
16
  */
17
  use CreativeMail\CreativeMail;
18
  function _load_ce4wp_plugin()
@@ -26,7 +26,7 @@ function _load_ce4wp_plugin()
26
  define('CE4WP_PLUGIN_DIR', __DIR__ . '/');
27
  define('CE4WP_PLUGIN_URL', plugin_dir_url(__FILE__) . '/');
28
  define('CE4WP_PLUGIN_FILE', __FILE__);
29
- define('CE4WP_PLUGIN_VERSION', '1.3.3');
30
  define('CE4WP_INSTANCE_UUID_KEY', 'ce4wp_instance_uuid');
31
  define('CE4WP_INSTANCE_HANDSHAKE_TOKEN', 'ce4wp_handshake_token');
32
  define('CE4WP_INSTANCE_HANDSHAKE_EXPIRATION', 'ce4wp_handshake_expiration');
@@ -43,7 +43,7 @@ function _load_ce4wp_plugin()
43
  define('CE4WP_APP_GATEWAY_URL', 'https://app-gateway.creativemail.com/');
44
  define('CE4WP_APP_URL', 'https://app.creativemail.com/');
45
  define('CE4WP_ENVIRONMENT', 'PRODUCTION');
46
- define('CE4WP_BUILD_NUMBER', '1044');
47
  define('CE4WP_RAYGUN_PHP_KEY', 'Z85xL3mkgnW13Ri9DajGUg');
48
  define('CE4WP_BATCH_SIZE', 500);
49
  define('CE4WP_WC_API_KEY_ID', 'ce4wp_woocommerce_api_key_id');
9
  * Plugin URI: https://wordpress.org/plugins/creative-mail-by-constant-contact/
10
  * Description: Free email marketing designed specifically for WordPress, Jetpack and WooCommerce. Send newsletters, promotions, updates and transactional e-commerce emails. Simple and easy, powered by Constant Contact’s rock solid reliability.
11
  * Author: Constant Contact
12
+ * Version: 1.3.4
13
  * Author URI: https://www.constantcontact.com
14
  * WC requires at least: 3.0.0
15
+ * WC tested up to: 5.1.0
16
  */
17
  use CreativeMail\CreativeMail;
18
  function _load_ce4wp_plugin()
26
  define('CE4WP_PLUGIN_DIR', __DIR__ . '/');
27
  define('CE4WP_PLUGIN_URL', plugin_dir_url(__FILE__) . '/');
28
  define('CE4WP_PLUGIN_FILE', __FILE__);
29
+ define('CE4WP_PLUGIN_VERSION', '1.3.4');
30
  define('CE4WP_INSTANCE_UUID_KEY', 'ce4wp_instance_uuid');
31
  define('CE4WP_INSTANCE_HANDSHAKE_TOKEN', 'ce4wp_handshake_token');
32
  define('CE4WP_INSTANCE_HANDSHAKE_EXPIRATION', 'ce4wp_handshake_expiration');
43
  define('CE4WP_APP_GATEWAY_URL', 'https://app-gateway.creativemail.com/');
44
  define('CE4WP_APP_URL', 'https://app.creativemail.com/');
45
  define('CE4WP_ENVIRONMENT', 'PRODUCTION');
46
+ define('CE4WP_BUILD_NUMBER', '1059');
47
  define('CE4WP_RAYGUN_PHP_KEY', 'Z85xL3mkgnW13Ri9DajGUg');
48
  define('CE4WP_BATCH_SIZE', 500);
49
  define('CE4WP_WC_API_KEY_ID', 'ce4wp_woocommerce_api_key_id');
readme.txt CHANGED
@@ -3,13 +3,13 @@ Contributors: Constant Contact
3
  Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
4
  Requires at least: 4.6
5
  Tested up to: 5.6
6
- Stable tag: 1.3.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.6
10
  Website: https://www.creativemail.com
11
  WC requires at least: 3.0.0
12
- WC tested up to: 5.0.0
13
 
14
  Creative Mail was designed specifically for WordPress and WooCommerce.
15
  Our intelligent (and super fun) email editor simplifies email marketing campaign creation and pulls your WordPress blog posts, website images and WooCommerce products right into your email content.
3
  Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
4
  Requires at least: 4.6
5
  Tested up to: 5.6
6
+ Stable tag: 1.3.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.6
10
  Website: https://www.creativemail.com
11
  WC requires at least: 3.0.0
12
+ WC tested up to: 5.1.0
13
 
14
  Creative Mail was designed specifically for WordPress and WooCommerce.
15
  Our intelligent (and super fun) email editor simplifies email marketing campaign creation and pulls your WordPress blog posts, website images and WooCommerce products right into your email content.
src/CreativeMail.php CHANGED
@@ -10,6 +10,7 @@ use CreativeMail\Managers\DatabaseManager;
10
  use CreativeMail\Managers\EmailManager;
11
  use CreativeMail\Managers\InstanceManager;
12
  use CreativeMail\Managers\IntegrationManager;
 
13
 
14
  class CreativeMail
15
  {
@@ -22,6 +23,7 @@ class CreativeMail
22
  private $email_manager;
23
  private $database_manager;
24
  private $checkout_manager;
 
25
 
26
  public function __construct()
27
  {
@@ -35,6 +37,7 @@ class CreativeMail
35
  $this->integration_manager = new IntegrationManager();
36
  $this->email_manager = new EmailManager();
37
  $this->checkout_manager = new CheckoutManager();
 
38
  }
39
 
40
  public function add_hooks()
@@ -93,6 +96,11 @@ class CreativeMail
93
  return $this->admin_manager;
94
  }
95
 
 
 
 
 
 
96
  public function is_active()
97
  {
98
  return in_array(plugin_basename(CE4WP_PLUGIN_FILE), apply_filters('active_plugins', get_option('active_plugins')));
10
  use CreativeMail\Managers\EmailManager;
11
  use CreativeMail\Managers\InstanceManager;
12
  use CreativeMail\Managers\IntegrationManager;
13
+ use CreativeMail\Modules\Contacts\Managers\ContactsSyncManager;
14
 
15
  class CreativeMail
16
  {
23
  private $email_manager;
24
  private $database_manager;
25
  private $checkout_manager;
26
+ private $contacts_sync_manager;
27
 
28
  public function __construct()
29
  {
37
  $this->integration_manager = new IntegrationManager();
38
  $this->email_manager = new EmailManager();
39
  $this->checkout_manager = new CheckoutManager();
40
+ $this->contacts_sync_manager = new ContactsSyncManager();
41
  }
42
 
43
  public function add_hooks()
96
  return $this->admin_manager;
97
  }
98
 
99
+ public function get_contacts_sync_manager()
100
+ {
101
+ return $this->contacts_sync_manager;
102
+ }
103
+
104
  public function is_active()
105
  {
106
  return in_array(plugin_basename(CE4WP_PLUGIN_FILE), apply_filters('active_plugins', get_option('active_plugins')));
src/helpers/ValidationHelper.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Helpers;
4
+
5
+
6
+ class ValidationHelper
7
+ {
8
+ public static function is_null_or_empty($value)
9
+ {
10
+ return !isset($value) || empty($value);
11
+ }
12
+ }
src/managers/AdminManager.php CHANGED
@@ -149,6 +149,12 @@ class AdminManager
149
 
150
  parse_str($_POST['data'], $post_data);
151
 
 
 
 
 
 
 
152
  $arguments = array(
153
  'method' => 'POST',
154
  'headers' => array(
@@ -160,7 +166,7 @@ class AdminManager
160
  array(
161
  'instance_id' => $instance_id,
162
  'survey_id' => 1,
163
- 'value' => $post_data['ce4wp_deactivation_option'],
164
  'message' => $post_data['other']
165
  )
166
  )
@@ -168,7 +174,7 @@ class AdminManager
168
 
169
  wp_remote_post(EnvironmentHelper::get_app_gateway_url() . 'wordpress/v1.0/survey', $arguments);
170
 
171
- return true;
172
  }
173
 
174
  private function should_show_deactivation_modal() {
149
 
150
  parse_str($_POST['data'], $post_data);
151
 
152
+ $survey_value = $post_data['ce4wp_deactivation_option'];
153
+ if (is_null($survey_value))
154
+ {
155
+ wp_send_json_success();
156
+ }
157
+
158
  $arguments = array(
159
  'method' => 'POST',
160
  'headers' => array(
166
  array(
167
  'instance_id' => $instance_id,
168
  'survey_id' => 1,
169
+ 'value' => $survey_value,
170
  'message' => $post_data['other']
171
  )
172
  )
174
 
175
  wp_remote_post(EnvironmentHelper::get_app_gateway_url() . 'wordpress/v1.0/survey', $arguments);
176
 
177
+ wp_send_json_success();
178
  }
179
 
180
  private function should_show_deactivation_modal() {
src/managers/ApiManager.php CHANGED
@@ -174,7 +174,7 @@ class ApiManager
174
  self::ROUTE_PATH => '/synchronize',
175
  self::ROUTE_METHODS => 'POST',
176
  self::ROUTE_CALLBACK => function () {
177
- do_action(CE4WP_SYNCHRONIZE_ACTION, 250);
178
  return $this->modify_response(new WP_REST_Response(null, 200));
179
  }
180
  ),
174
  self::ROUTE_PATH => '/synchronize',
175
  self::ROUTE_METHODS => 'POST',
176
  self::ROUTE_CALLBACK => function () {
177
+ do_action(CE4WP_SYNCHRONIZE_ACTION);
178
  return $this->modify_response(new WP_REST_Response(null, 200));
179
  }
180
  ),
src/managers/IntegrationManager.php CHANGED
@@ -5,6 +5,7 @@ namespace CreativeMail\Managers;
5
 
6
  use CreativeMail\Helpers\OptionsHelper;
7
  use CreativeMail\Integrations\Integration;
 
8
  use CreativeMail\Modules\Contacts\Handlers\ContactFormSevenPluginHandler;
9
  use CreativeMail\Modules\Contacts\Handlers\ElementorPluginHandler;
10
  use CreativeMail\Modules\Contacts\Handlers\GravityFormsPluginHandler;
@@ -14,7 +15,6 @@ use CreativeMail\Modules\Contacts\Handlers\WpFormsPluginHandler;
14
  use CreativeMail\Modules\Contacts\Handlers\JetpackPluginHandler;
15
  use CreativeMail\Modules\Contacts\Handlers\NinjaFormsPluginHandler;
16
  use CreativeMail\Modules\Contacts\Handlers\CalderaPluginHandler;
17
- use CreativeMail\Modules\Contacts\Processes\ContactUploadProcess;
18
  use ReflectionClass;
19
 
20
  /**
@@ -42,10 +42,11 @@ class IntegrationManager
42
  new Integration('newsletter', 'Newsletter', 'newsletter/plugin.php', NewsLetterContactFormPluginHandler::class, false),
43
  new Integration('wpforms', 'WPForms', 'wpforms/wpforms.php', WpFormsPluginHandler::class, false, 'https://wpforms.com/'),
44
  new Integration('wpformslite', 'WPForms Lite', 'wpforms-lite/wpforms.php', WpFormsPluginHandler::class, true, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=wpforms-lite&TB_iframe=true&width=772&height=1144'),
45
- new Integration('gravityforms', 'GravityForms', 'gravityforms/gravityforms.php', GravityFormsPluginHandler::class, false, 'https://www.gravityforms.com/'),
46
  new Integration('elementor', 'Elementor', 'elementor/elementor.php', ElementorPluginHandler::class, false),
47
- new Integration('ninjaforms', 'Ninja forms', 'ninja-forms/ninja-forms.php', NinjaFormsPluginHandler::class, false, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=ninja-forms&TB_iframe=true&width=772&height=1144'),
48
- new Integration('caldera', 'Caldera Forms', 'caldera-forms/caldera-core.php', CalderaPluginHandler::class, false, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=caldera-forms&TB_iframe=true&width=772&height=1144')
 
49
  );
50
  }
51
 
@@ -128,7 +129,7 @@ class IntegrationManager
128
  $this->remove_hooks();
129
  $this->add_hooks();
130
 
131
- do_action(CE4WP_SYNCHRONIZE_ACTION, 250);
132
  }
133
 
134
  /**
5
 
6
  use CreativeMail\Helpers\OptionsHelper;
7
  use CreativeMail\Integrations\Integration;
8
+ use CreativeMail\Modules\Contacts\Handlers\BlueHostBuilderPluginHandler;
9
  use CreativeMail\Modules\Contacts\Handlers\ContactFormSevenPluginHandler;
10
  use CreativeMail\Modules\Contacts\Handlers\ElementorPluginHandler;
11
  use CreativeMail\Modules\Contacts\Handlers\GravityFormsPluginHandler;
15
  use CreativeMail\Modules\Contacts\Handlers\JetpackPluginHandler;
16
  use CreativeMail\Modules\Contacts\Handlers\NinjaFormsPluginHandler;
17
  use CreativeMail\Modules\Contacts\Handlers\CalderaPluginHandler;
 
18
  use ReflectionClass;
19
 
20
  /**
42
  new Integration('newsletter', 'Newsletter', 'newsletter/plugin.php', NewsLetterContactFormPluginHandler::class, false),
43
  new Integration('wpforms', 'WPForms', 'wpforms/wpforms.php', WpFormsPluginHandler::class, false, 'https://wpforms.com/'),
44
  new Integration('wpformslite', 'WPForms Lite', 'wpforms-lite/wpforms.php', WpFormsPluginHandler::class, true, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=wpforms-lite&TB_iframe=true&width=772&height=1144'),
45
+ new Integration('gravityforms', 'Gravity Forms', 'gravityforms/gravityforms.php', GravityFormsPluginHandler::class, false, 'https://www.gravityforms.com/'),
46
  new Integration('elementor', 'Elementor', 'elementor/elementor.php', ElementorPluginHandler::class, false),
47
+ new Integration('ninjaforms', 'Ninja Forms', 'ninja-forms/ninja-forms.php', NinjaFormsPluginHandler::class, false, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=ninja-forms&TB_iframe=true&width=772&height=1144'),
48
+ new Integration('caldera', 'Caldera Forms', 'caldera-forms/caldera-core.php', CalderaPluginHandler::class, false, '/wordpress/wp-admin/plugin-install.php?tab=plugin-information&plugin=caldera-forms&TB_iframe=true&width=772&height=1144'),
49
+ new Integration('bluehost', 'Bluehost Builder', 'wb4wp-wordpress-plugin-bluehost/wb4wp-plugin.php', BlueHostBuilderPluginHandler::class, false)
50
  );
51
  }
52
 
129
  $this->remove_hooks();
130
  $this->add_hooks();
131
 
132
+ do_action(CE4WP_SYNCHRONIZE_ACTION);
133
  }
134
 
135
  /**
src/modules/DashboardWidgetModule.php CHANGED
@@ -6,6 +6,7 @@ use CreativeMail\Clients\CreativeMailClient;
6
  use CreativeMail\CreativeMail;
7
  use CreativeMail\Exceptions\CreativeMailException;
8
  use CreativeMail\Helpers\OptionsHelper;
 
9
  use CreativeMail\Managers\RaygunManager;
10
 
11
  class DashboardWidgetModule
@@ -41,17 +42,20 @@ class DashboardWidgetModule
41
  try {
42
  $ce_account_status = $this->creative_mail_client->get_account_status();
43
 
44
- $ce_has_finished_onboarding = $ce_account_status['has_finished_onboarding'];
45
- if ( !$ce_has_finished_onboarding ) {
46
- $this->show_no_account();
47
- return;
48
- }
49
-
50
- $ce_has_campaign = $ce_account_status['has_campaigns'];
51
- if ( !$ce_has_campaign ) {
52
- $this->show_no_campaigns();
 
 
 
53
  } else {
54
- $this->show_campaigns();
55
  }
56
 
57
  if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
6
  use CreativeMail\CreativeMail;
7
  use CreativeMail\Exceptions\CreativeMailException;
8
  use CreativeMail\Helpers\OptionsHelper;
9
+ use CreativeMail\Helpers\ValidationHelper;
10
  use CreativeMail\Managers\RaygunManager;
11
 
12
  class DashboardWidgetModule
42
  try {
43
  $ce_account_status = $this->creative_mail_client->get_account_status();
44
 
45
+ if (!ValidationHelper::is_null_or_empty($ce_account_status)) {
46
+ $ce_has_finished_onboarding = $ce_account_status['has_finished_onboarding'];
47
+ if (!$ce_has_finished_onboarding) {
48
+ $this->show_no_account();
49
+ return;
50
+ }
51
+ $ce_has_campaign = $ce_account_status['has_campaigns'];
52
+ if (!$ce_has_campaign) {
53
+ $this->show_no_campaigns();
54
+ } else {
55
+ $this->show_campaigns();
56
+ }
57
  } else {
58
+ $this->show_no_campaigns();
59
  }
60
 
61
  if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
src/modules/contacts/Exceptions/InvalidContactSyncBackgroundRequestException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Modules\contacts\Exceptions;
4
+
5
+ use Exception;
6
+
7
+ class InvalidContactSyncBackgroundRequestException extends Exception
8
+ {
9
+ public function __construct ($message)
10
+ {
11
+ parent::__construct('[CreativeMail - Contact sync] ' . $message);
12
+ }
13
+ }
src/modules/contacts/Exceptions/InvalidHandlerContactSyncRequestException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Modules\contacts\Exceptions;
4
+
5
+ use Exception;
6
+
7
+ class InvalidHandlerContactSyncRequestException extends Exception
8
+ {
9
+ public function __construct($message)
10
+ {
11
+ parent::__construct('[CreativeMail - Contact sync request] ' . $message);
12
+ }
13
+ }
src/modules/contacts/Handlers/BaseContactFormPluginHandler.php CHANGED
@@ -12,7 +12,13 @@ abstract class BaseContactFormPluginHandler
12
  public abstract function convertToContactModel($contactForm);
13
  public abstract function registerHooks();
14
  public abstract function unregisterHooks();
15
- public abstract function syncAction($limit = null);
 
 
 
 
 
 
16
 
17
  public function upsertContact($model)
18
  {
12
  public abstract function convertToContactModel($contactForm);
13
  public abstract function registerHooks();
14
  public abstract function unregisterHooks();
15
+ public abstract function get_contacts($limit = null);
16
+
17
+ protected $birthdayFields = array('birthday', 'date-of-birth', 'date_of_birth', 'birth_date', 'birth-date');
18
+ protected $phoneFields = array('phone', 'phone_number', 'telephone', 'tel', 'tel-number', 'tel_number', 'mobile_number');
19
+ protected $emailFields = array('your-email', 'email', 'e-mail', 'emailaddress', 'email_address', 'email address', 'email-address', 'e-mail address');
20
+
21
+
22
 
23
  public function upsertContact($model)
24
  {
src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Modules\Contacts\Handlers;
4
+
5
+ define('CE4WP_WB4WP_EVENTTYPE', 'WordPress - BlueHost Builder');
6
+
7
+ use CreativeMail\Managers\RaygunManager;
8
+ use CreativeMail\Modules\Contacts\Models\ContactModel;
9
+ use CreativeMail\Modules\Contacts\Models\OptActionBy;
10
+
11
+ class BlueHostBuilderPluginHandler extends BaseContactFormPluginHandler
12
+ {
13
+ public function convertToContactModel($contact)
14
+ {
15
+ $contactModel = new ContactModel();
16
+
17
+ $email = $contact->email_address;
18
+ if ($this->isNullOrEmpty($email)) {
19
+ return null;
20
+ }
21
+ $contactModel->setEmail($email);
22
+ $contactModel->setEventType(CE4WP_WB4WP_EVENTTYPE);
23
+
24
+ if ($contact->opt_in && !$contact->opt_out) {
25
+
26
+ $contactModel->setOptIn($contact->opt_in);
27
+ $contactModel->setOptActionBy(OptActionBy::Owner);
28
+ }
29
+
30
+ if ($contact->opt_out) {
31
+ $contactModel->setOptOut($contact->opt_out);
32
+ $contactModel->setOptActionBy(OptActionBy::User);
33
+ }
34
+
35
+ if (!empty($contact->first_name)) {
36
+ $contactModel->setFirstName($contact->first_name);
37
+ }
38
+ if (!empty($contact->last_name)) {
39
+ $contactModel->setLastName($contact->last_name);
40
+ }
41
+ if (!empty($contact->phone)) {
42
+ $contactModel->setPhone($contact->phone);
43
+ }
44
+ if (!empty($contact->birthday)) {
45
+ $contactModel->set_birthday($contact->birthday);
46
+ }
47
+
48
+ return $contactModel;
49
+ }
50
+
51
+ public function ceHandleBHWBFormSubmission($contact_id)
52
+ {
53
+ try {
54
+ global $wpdb;
55
+ $contact = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_wb4wp_contacts WHERE contact_id = {$contact_id}"));
56
+ if (empty($contact->email_address)) {
57
+ return;
58
+ }
59
+ $this->upsertContact($this->convertToContactModel($contact));
60
+ } catch (\Exception $exception) {
61
+ RaygunManager::get_instance()->exception_handler($exception);
62
+ }
63
+ }
64
+
65
+ public function registerHooks()
66
+ {
67
+ add_action('wb4wp_contacts_updated', array($this, 'ceHandleBHWBFormSubmission'), 10, 1);
68
+ }
69
+
70
+ public function unregisterHooks()
71
+ {
72
+ remove_action('wb4wp_contacts_updated', array($this, 'ceHandleBHWBFormSubmission'));
73
+ }
74
+
75
+ public function get_contacts($limit = null)
76
+ {
77
+ if (!is_int($limit) || $limit <= 0) {
78
+ $limit = null;
79
+ }
80
+
81
+ if (in_array('wb4wp-wordpress-plugin-bluehost/wb4wp-plugin.php', apply_filters('active_plugins', get_option('active_plugins'))) && defined('CFCORE_VER')) {
82
+ global $wpdb;
83
+
84
+ $contactsArray = array();
85
+ $contacts = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_wb4wp_contacts"));
86
+
87
+ //loop through the entries and extract necessary data
88
+ foreach ($contacts as $contact) {
89
+ //Convert to contactModel
90
+ $contactModel = null;
91
+ try {
92
+ $contactModel = $this->convertToContactModel($contact);
93
+ } catch (\Exception $exception) {
94
+ RaygunManager::get_instance()->exception_handler($exception);
95
+ continue;
96
+ }
97
+ if (!empty($contactModel)) {
98
+ array_push($contactsArray, $contactModel);
99
+ }
100
+ if (isset($limit) && count($contactsArray) >= $limit) {
101
+ break;
102
+ }
103
+ }
104
+
105
+ if (!empty($contactsArray)) {
106
+ return $contactsArray;
107
+ }
108
+ }
109
+ return null;
110
+ }
111
+
112
+ function __construct()
113
+ {
114
+ parent::__construct();
115
+ }
116
+ }
src/modules/contacts/Handlers/CalderaPluginHandler.php CHANGED
@@ -10,6 +10,10 @@ use CreativeMail\Modules\Contacts\Models\OptActionBy;
10
 
11
  class CalderaPluginHandler extends BaseContactFormPluginHandler
12
  {
 
 
 
 
13
 
14
  private function GetNameFromForm($entry)
15
  {
@@ -31,17 +35,24 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
31
  return $name;
32
  }
33
 
34
- private function GetEmailFromForm($entry)
35
  {
36
  if ($this->isNullOrEmpty($entry)) {
37
  return null;
38
  }
 
39
  foreach ($entry as $field) {
40
- if ($field->slug === "email_address") {
41
- return $field->value;
 
 
 
 
 
 
 
42
  }
43
  }
44
- return null;
45
  }
46
 
47
  public function convertToContactModel($contact)
@@ -54,10 +65,16 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
54
  $contactModel = new ContactModel();
55
 
56
  $contactModel->setEventType(CE4WP_CAL_EVENTTYPE);
57
- //optin true on sync, false on form submission
58
- $contactModel->setOptIn($contact->opt_in);
59
  $contactModel->setOptOut(false);
60
- $contactModel->setOptActionBy(OptActionBy::Owner);
 
 
 
 
 
 
 
 
61
 
62
  $contactModel->setEmail($email);
63
 
@@ -67,6 +84,12 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
67
  if (!empty($contact->lastname)) {
68
  $contactModel->setLastName($contact->lastname);
69
  }
 
 
 
 
 
 
70
 
71
  return $contactModel;
72
  }
@@ -76,13 +99,16 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
76
  try {
77
  global $wpdb;
78
  $calderaContact = new \stdClass();
 
 
79
  $entryData = $wpdb->get_results($wpdb->prepare("SELECT slug, `value` FROM wp_cf_form_entry_values WHERE entry_id = {$entryid}"));
80
  $nameValues = $this->GetNameFromForm($entryData);
81
  $calderaContact->firstname = array_key_exists("firstname", $nameValues) ? $nameValues["firstname"] : null;
82
  $calderaContact->lastname = array_key_exists("lastname", $nameValues) ? $nameValues["lastname"] : null;
83
- $calderaContact->email = $this->GetEmailFromForm($entryData);
84
- //set opt in to false for form submissions
85
- $calderaContact->opt_in = false;
 
86
  if (empty($calderaContact->email)) {
87
  return;
88
  }
@@ -95,18 +121,14 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
95
  public function registerHooks()
96
  {
97
  add_action('caldera_forms_submit_complete', array($this, 'ceHandleCalderaFormSubmission'), 60, 4); //make sure the prio is set as to run after caldera itself otherwise data is not present in db
98
- // add hook function to synchronize
99
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
100
  }
101
 
102
  public function unregisterHooks()
103
  {
104
  remove_action('caldera_forms_submit_complete', array($this, 'ceHandleCalderaFormSubmission'));
105
- // remove hook function to synchronize
106
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
107
  }
108
 
109
- public function syncAction($limit = null)
110
  {
111
  if (!is_int($limit) || $limit <= 0) {
112
  $limit = null;
@@ -122,8 +144,12 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
122
  //loop through the entries and extract necessary data
123
  foreach ($entryIds as $entry) {
124
  $contact = new \stdClass();
 
125
  $entryData = $wpdb->get_results($wpdb->prepare("SELECT slug, `value` FROM wp_cf_form_entry_values WHERE entry_id = {$entry->id}"));
126
- $contact->email = $this->GetEmailFromForm($entryData);
 
 
 
127
  if (empty($contact->email)) {
128
  continue;
129
  }
@@ -133,7 +159,7 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
133
  $contact->lastname = array_key_exists("lastname", $nameValues) ? $nameValues["lastname"] : null;
134
 
135
  //contact opt in is true on sync
136
- $contact->opt_in = true;
137
 
138
  //Convert to contactModel
139
  $contactModel = null;
@@ -154,15 +180,11 @@ class CalderaPluginHandler extends BaseContactFormPluginHandler
154
  }
155
 
156
  if (!empty($contactsArray)) {
157
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
158
- foreach ($batches as $batch) {
159
- try {
160
- $this->batchUpsertContacts($batch);
161
- } catch (\Exception $exception) {
162
- RaygunManager::get_instance()->exception_handler($exception);
163
- }
164
- }
165
  }
 
166
  }
 
 
167
  }
168
  }
10
 
11
  class CalderaPluginHandler extends BaseContactFormPluginHandler
12
  {
13
+ private function GetCalderaPhoneFields()
14
+ {
15
+ return array_merge($this->phoneFields, ['phone_better']);
16
+ }
17
 
18
  private function GetNameFromForm($entry)
19
  {
35
  return $name;
36
  }
37
 
38
+ private function FindFormValues($entry, $calderaContact)
39
  {
40
  if ($this->isNullOrEmpty($entry)) {
41
  return null;
42
  }
43
+ $calderaPhoneFields = $this->GetCalderaPhoneFields();
44
  foreach ($entry as $field) {
45
+ $slug = strtolower($field->slug);
46
+ if (in_array($slug, $calderaPhoneFields)) {
47
+ $calderaContact->phone = $field->value;
48
+ } elseif (in_array($slug, $this->birthdayFields)) {
49
+ $calderaContact->birthday = $field->value;
50
+ } elseif ($slug == "email_address") {
51
+ $calderaContact->email = $field->value;
52
+ } elseif ($slug == "consent") {
53
+ $calderaContact->consent = $field->value;
54
  }
55
  }
 
56
  }
57
 
58
  public function convertToContactModel($contact)
65
  $contactModel = new ContactModel();
66
 
67
  $contactModel->setEventType(CE4WP_CAL_EVENTTYPE);
 
 
68
  $contactModel->setOptOut(false);
69
+
70
+ //if its a form submission we take the opt_in value and set action to visitor
71
+ if ($contact->isFormSubmission) {
72
+ $contactModel->setOptIn(boolval($contact->consent));
73
+ $contactModel->setOptActionBy(OptActionBy::Visitor);
74
+ } else {
75
+ $contactModel->setOptIn(true);
76
+ $contactModel->setOptActionBy(OptActionBy::Owner);
77
+ }
78
 
79
  $contactModel->setEmail($email);
80
 
84
  if (!empty($contact->lastname)) {
85
  $contactModel->setLastName($contact->lastname);
86
  }
87
+ if (!empty($contact->phone)) {
88
+ $contactModel->setPhone($contact->phone);
89
+ }
90
+ if (!empty($contact->birthday)) {
91
+ $contactModel->set_birthday($contact->birthday);
92
+ }
93
 
94
  return $contactModel;
95
  }
99
  try {
100
  global $wpdb;
101
  $calderaContact = new \stdClass();
102
+ $calderaContact->isFormSubmission = true;
103
+
104
  $entryData = $wpdb->get_results($wpdb->prepare("SELECT slug, `value` FROM wp_cf_form_entry_values WHERE entry_id = {$entryid}"));
105
  $nameValues = $this->GetNameFromForm($entryData);
106
  $calderaContact->firstname = array_key_exists("firstname", $nameValues) ? $nameValues["firstname"] : null;
107
  $calderaContact->lastname = array_key_exists("lastname", $nameValues) ? $nameValues["lastname"] : null;
108
+
109
+ //get additional form values and add to the contact
110
+ $this->FindFormValues($entryData, $calderaContact);
111
+
112
  if (empty($calderaContact->email)) {
113
  return;
114
  }
121
  public function registerHooks()
122
  {
123
  add_action('caldera_forms_submit_complete', array($this, 'ceHandleCalderaFormSubmission'), 60, 4); //make sure the prio is set as to run after caldera itself otherwise data is not present in db
 
 
124
  }
125
 
126
  public function unregisterHooks()
127
  {
128
  remove_action('caldera_forms_submit_complete', array($this, 'ceHandleCalderaFormSubmission'));
 
 
129
  }
130
 
131
+ public function get_contacts($limit = null)
132
  {
133
  if (!is_int($limit) || $limit <= 0) {
134
  $limit = null;
144
  //loop through the entries and extract necessary data
145
  foreach ($entryIds as $entry) {
146
  $contact = new \stdClass();
147
+ $contact->isFormSubmission = false;
148
  $entryData = $wpdb->get_results($wpdb->prepare("SELECT slug, `value` FROM wp_cf_form_entry_values WHERE entry_id = {$entry->id}"));
149
+
150
+ //get form values
151
+ $this->FindFormValues($entryData, $contact);
152
+
153
  if (empty($contact->email)) {
154
  continue;
155
  }
159
  $contact->lastname = array_key_exists("lastname", $nameValues) ? $nameValues["lastname"] : null;
160
 
161
  //contact opt in is true on sync
162
+ $contact->consent = true;
163
 
164
  //Convert to contactModel
165
  $contactModel = null;
180
  }
181
 
182
  if (!empty($contactsArray)) {
183
+ return $contactsArray;
 
 
 
 
 
 
 
184
  }
185
+
186
  }
187
+
188
+ return null;
189
  }
190
  }
src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php CHANGED
@@ -11,8 +11,6 @@ use CreativeMail\Modules\Contacts\Models\OptActionBy;
11
 
12
  class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
13
  {
14
-
15
- private $emailFields = array('your-email', 'email', 'emailaddress', 'email_address');
16
  private $firstnameFields = array('firstname', 'first_name', 'name', 'your-name');
17
  private $lastnameFields = array('lastname', 'last_name');
18
 
@@ -56,11 +54,18 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
56
  if (!empty($firstName)) {
57
  $contactModel->setFirstName($firstName);
58
  }
59
-
60
  $lastName = $this->findValue($contactForm, $this->lastnameFields);
61
  if (!empty($lastName)) {
62
  $contactModel->setLastName($lastName);
63
  }
 
 
 
 
 
 
 
 
64
 
65
  $contactModel->setOptIn(false);
66
  $contactModel->setEventType(CE4WP_CF7_EVENTTYPE);
@@ -71,18 +76,14 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
71
  public function registerHooks()
72
  {
73
  add_action('wpcf7_mail_sent', array($this, 'ceHandleContactFormSevenSubmit'));
74
- // add hook function to synchronize
75
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
76
  }
77
 
78
  public function unregisterHooks()
79
  {
80
  remove_action('wpcf7_mail_sent', array($this, 'ceHandleContactFormSevenSubmit'));
81
- // add hook function to synchronize
82
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
83
  }
84
 
85
- public function syncAction($limit = null)
86
  {
87
  if (!is_int($limit) || $limit <= 0) {
88
  $limit = null;
@@ -105,7 +106,6 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
105
  }
106
 
107
  $results = $cfdb->get_results($cfdbQuery, OBJECT);
108
-
109
  $contactsArray = array();
110
 
111
  foreach ($results as $formSubmission) {
@@ -113,8 +113,8 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
113
  $contactModel = new ContactModel();
114
  $contactModel->setOptIn(true);
115
  $contactModel->setOptOut(false);
 
116
 
117
- $contactModel->setOptActionBy(OptActionBy::Visitor);
118
  try {
119
  $email = $this->findValueFromDb($form_data, $this->emailFields);
120
  if (!empty($email)) {
@@ -128,6 +128,14 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
128
  if (!empty($lastname)) {
129
  $contactModel->setLastName($lastname);
130
  }
 
 
 
 
 
 
 
 
131
  } catch (\Exception $exception) {
132
  RaygunManager::get_instance()->exception_handler($exception);
133
  continue;
@@ -140,13 +148,11 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
140
  }
141
 
142
  if (!empty($contactsArray)) {
143
-
144
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
145
- foreach ($batches as $batch) {
146
- $this->batchUpsertContacts($batch);
147
- }
148
  }
149
  }
 
 
150
  }
151
 
152
  function ceHandleContactFormSevenSubmit($contact_form)
11
 
12
  class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
13
  {
 
 
14
  private $firstnameFields = array('firstname', 'first_name', 'name', 'your-name');
15
  private $lastnameFields = array('lastname', 'last_name');
16
 
54
  if (!empty($firstName)) {
55
  $contactModel->setFirstName($firstName);
56
  }
 
57
  $lastName = $this->findValue($contactForm, $this->lastnameFields);
58
  if (!empty($lastName)) {
59
  $contactModel->setLastName($lastName);
60
  }
61
+ $phone = $this->findValue($contactForm, $this->phoneFields);
62
+ if (!empty($phone)) {
63
+ $contactModel->setPhone($phone);
64
+ }
65
+ $birthday = $this->findValue($contactForm, $this->birthdayFields);
66
+ if (!empty($birthday)) {
67
+ $contactModel->set_birthday($birthday);
68
+ }
69
 
70
  $contactModel->setOptIn(false);
71
  $contactModel->setEventType(CE4WP_CF7_EVENTTYPE);
76
  public function registerHooks()
77
  {
78
  add_action('wpcf7_mail_sent', array($this, 'ceHandleContactFormSevenSubmit'));
 
 
79
  }
80
 
81
  public function unregisterHooks()
82
  {
83
  remove_action('wpcf7_mail_sent', array($this, 'ceHandleContactFormSevenSubmit'));
 
 
84
  }
85
 
86
+ public function get_contacts($limit = null)
87
  {
88
  if (!is_int($limit) || $limit <= 0) {
89
  $limit = null;
106
  }
107
 
108
  $results = $cfdb->get_results($cfdbQuery, OBJECT);
 
109
  $contactsArray = array();
110
 
111
  foreach ($results as $formSubmission) {
113
  $contactModel = new ContactModel();
114
  $contactModel->setOptIn(true);
115
  $contactModel->setOptOut(false);
116
+ $contactModel->setOptActionBy(OptActionBy::Owner);
117
 
 
118
  try {
119
  $email = $this->findValueFromDb($form_data, $this->emailFields);
120
  if (!empty($email)) {
128
  if (!empty($lastname)) {
129
  $contactModel->setLastName($lastname);
130
  }
131
+ $phone = $this->findValueFromDb($form_data, $this->phoneFields);
132
+ if (!empty($phone)) {
133
+ $contactModel->setPhone($phone);
134
+ }
135
+ $birthday = $this->findValueFromDb($form_data, $this->birthdayFields);
136
+ if (!empty($birthday)) {
137
+ $contactModel->set_birthday($birthday);
138
+ }
139
  } catch (\Exception $exception) {
140
  RaygunManager::get_instance()->exception_handler($exception);
141
  continue;
148
  }
149
 
150
  if (!empty($contactsArray)) {
151
+ return $contactsArray;
 
 
 
 
152
  }
153
  }
154
+
155
+ return null;
156
  }
157
 
158
  function ceHandleContactFormSevenSubmit($contact_form)
src/modules/contacts/Handlers/ElementorPluginHandler.php CHANGED
@@ -19,21 +19,24 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
19
  {
20
  foreach ($fields as $field) {
21
  //Try to find a name value based on the default Elementor form with name field
22
- if(array_key_exists('type', $field) && ($field['type'] === "text" && $field['id'] === "name")) {
23
  return $field["value"];
24
  }
25
  }
26
  return null;
27
  }
28
 
29
- private function GetEmailFromForm($fields)
30
  {
31
  foreach ($fields as $field) {
32
- if(array_key_exists('type', $field) && $field['type'] === "email") {
33
- return $field["value"];
 
 
 
 
34
  }
35
  }
36
- return null;
37
  }
38
 
39
  public function convertToContactModel($contact)
@@ -44,11 +47,10 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
44
 
45
  $contactModel->setOptIn(false);
46
  $contactModel->setOptOut(false);
47
- $contactModel->setOptActionBy(OptActionBy::Owner);
48
 
49
- $email = $contact->email;
50
- if (!empty($email)) {
51
- $contactModel->setEmail($email);
52
  }
53
 
54
  $values = explode(' ', $contact->name);
@@ -61,7 +63,12 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
61
  if (!empty($lastName)) {
62
  $contactModel->setLastName($lastName);
63
  }
64
-
 
 
 
 
 
65
  return $contactModel;
66
  }
67
 
@@ -71,10 +78,13 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
71
  $fields = $record->get("fields");
72
  $elemContact = new \stdClass();
73
  $elemContact->name = $this->GetNameFromForm($fields);
74
- $elemContact->email = $this->GetEmailFromForm($fields);
 
 
75
  if (empty($elemContact->email)) {
76
  return;
77
- };
 
78
  $this->upsertContact($this->convertToContactModel($elemContact));
79
  } catch (\Exception $exception) {
80
  RaygunManager::get_instance()->exception_handler($exception);
@@ -84,19 +94,16 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
84
  public function registerHooks()
85
  {
86
  add_action('elementor_pro/forms/mail_sent', array($this, 'ceHandleElementorFormSubmission'), 10, 2);
87
- // add hook function to synchronize
88
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
89
  }
90
 
91
  public function unregisterHooks()
92
  {
93
  remove_action('elementor_pro/forms/mail_sent', array($this, 'ceHandleElementorFormSubmission'));
94
- // remove hook function to synchronize
95
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
96
  }
97
 
98
- public function syncAction($limit = null)
99
  {
100
  //Elementor seems to not store form submissions locally
 
101
  }
102
  }
19
  {
20
  foreach ($fields as $field) {
21
  //Try to find a name value based on the default Elementor form with name field
22
+ if (array_key_exists('type', $field) && ($field['type'] === "text" && $field['id'] === "name")) {
23
  return $field["value"];
24
  }
25
  }
26
  return null;
27
  }
28
 
29
+ private function FindFormData($elemContact, $fields)
30
  {
31
  foreach ($fields as $field) {
32
+ if (array_key_exists('type', $field) && in_array($field['type'], $this->emailFields)) {
33
+ $elemContact->email = $field["value"];
34
+ } elseif (array_key_exists('type', $field) && in_array($field['type'], $this->phoneFields)) {
35
+ $elemContact->phone = $field["value"];
36
+ } elseif (array_key_exists('type', $field) && $field['type'] === 'date' && in_array(strtolower($field['title']), $this->birthdayFields)) {
37
+ $elemContact->birthday = $field["value"];
38
  }
39
  }
 
40
  }
41
 
42
  public function convertToContactModel($contact)
47
 
48
  $contactModel->setOptIn(false);
49
  $contactModel->setOptOut(false);
50
+ $contactModel->setOptActionBy(OptActionBy::Visitor);
51
 
52
+ if (!empty($contact->email)) {
53
+ $contactModel->setEmail($contact->email);
 
54
  }
55
 
56
  $values = explode(' ', $contact->name);
63
  if (!empty($lastName)) {
64
  $contactModel->setLastName($lastName);
65
  }
66
+ if (!empty($contact->phone)) {
67
+ $contactModel->setPhone($contact->phone);
68
+ }
69
+ if (!empty($contact->birthday)) {
70
+ $contactModel->set_birthday($contact->birthday);
71
+ }
72
  return $contactModel;
73
  }
74
 
78
  $fields = $record->get("fields");
79
  $elemContact = new \stdClass();
80
  $elemContact->name = $this->GetNameFromForm($fields);
81
+
82
+ //attempt to get additional data
83
+ $this->FindFormData($elemContact, $fields);
84
  if (empty($elemContact->email)) {
85
  return;
86
+ }
87
+
88
  $this->upsertContact($this->convertToContactModel($elemContact));
89
  } catch (\Exception $exception) {
90
  RaygunManager::get_instance()->exception_handler($exception);
94
  public function registerHooks()
95
  {
96
  add_action('elementor_pro/forms/mail_sent', array($this, 'ceHandleElementorFormSubmission'), 10, 2);
 
 
97
  }
98
 
99
  public function unregisterHooks()
100
  {
101
  remove_action('elementor_pro/forms/mail_sent', array($this, 'ceHandleElementorFormSubmission'));
 
 
102
  }
103
 
104
+ public function get_contacts($limit = null)
105
  {
106
  //Elementor seems to not store form submissions locally
107
+ return null;
108
  }
109
  }
src/modules/contacts/Handlers/GravityFormsPluginHandler.php CHANGED
@@ -11,17 +11,22 @@ use CreativeMail\Modules\Contacts\Models\OptActionBy;
11
  class GravityFormsPluginHandler extends BaseContactFormPluginHandler
12
  {
13
  private $textFormFields = array('text', 'textarea');
14
- private $emailNames = array('e-mail', 'email', 'emailaddress', 'email address', 'e-mail address', 'email-address');
15
 
16
  public function convertToContactModel($user)
17
  {
18
  $contactModel = new ContactModel();
19
 
20
  $contactModel->setEventType(CE4WP_GF_EVENTTYPE);
21
- //optin true on sync, false on form submission
22
- $contactModel->setOptIn($user->opt_in);
23
- $contactModel->setOptOut(false);
24
- $contactModel->setOptActionBy(OptActionBy::Owner);
 
 
 
 
 
 
25
 
26
  $email = $user->email;
27
  if (!empty($email)) {
@@ -42,6 +47,12 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
42
  }
43
  $contactModel->setLastName($lastName);
44
  }
 
 
 
 
 
 
45
 
46
  return $contactModel;
47
  }
@@ -93,7 +104,7 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
93
  }
94
  //Else check if we can find an email value in text fields
95
  foreach ($form['fields'] as $field) {
96
- if (in_array(strtolower($field["type"]), $this->textFormFields) && in_array(strtolower($field["label"]), $this->emailNames)) {
97
  $possibleEmail = rgar($entry, $field["id"]);
98
  if (filter_var($possibleEmail, FILTER_VALIDATE_EMAIL)) {
99
  return $possibleEmail;
@@ -103,17 +114,31 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
103
  return $email;
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  public function ceHandleGravityFormSubmission($entry, $form)
107
  {
108
  try {
109
  $contact = new \stdClass();
110
  $contact->name = $this->GetNameValuesFromForm($entry, $form);
111
  $contact->email = $this->GetEmailFromForm($entry, $form);
 
112
  if (empty($contact->email)) {
113
  return;
114
- };
115
 
116
- $contact->opt_in = false;
117
  $this->upsertContact($this->convertToContactModel($contact));
118
  } catch (\Exception $exception) {
119
  RaygunManager::get_instance()->exception_handler($exception);
@@ -123,18 +148,14 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
123
  public function registerHooks()
124
  {
125
  add_action('gform_after_submission', array($this, 'ceHandleGravityFormSubmission'), 10, 2);
126
- // add hook function to synchronize
127
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
128
  }
129
 
130
  public function unregisterHooks()
131
  {
132
  remove_action('gform_after_submission', array($this, 'ceHandleGravityFormSubmission'));
133
- // remove hook function to synchronize
134
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
135
  }
136
 
137
- public function syncAction($limit = null)
138
  {
139
  if (!is_int($limit) || $limit <= 0) {
140
  $limit = null;
@@ -178,10 +199,10 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
178
  continue;
179
  }
180
  $contact->name = $this->GetNameValuesFromForm($entry, $formArray);
181
- $contact->opt_in = true;
 
182
 
183
  //Convert to contactModel
184
-
185
  $contactModel = null;
186
  try {
187
  $contactModel = $this->convertToContactModel($contact);
@@ -204,15 +225,10 @@ class GravityFormsPluginHandler extends BaseContactFormPluginHandler
204
  }
205
 
206
  if (!empty($contactsArray)) {
207
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
208
- foreach ($batches as $batch) {
209
- try {
210
- $this->batchUpsertContacts($batch);
211
- } catch (\Exception $exception) {
212
- RaygunManager::get_instance()->exception_handler($exception);
213
- }
214
- }
215
  }
 
 
216
  }
217
 
218
  function __construct()
11
  class GravityFormsPluginHandler extends BaseContactFormPluginHandler
12
  {
13
  private $textFormFields = array('text', 'textarea');
 
14
 
15
  public function convertToContactModel($user)
16
  {
17
  $contactModel = new ContactModel();
18
 
19
  $contactModel->setEventType(CE4WP_GF_EVENTTYPE);
20
+
21
+ if ($user->isSync) { //If its a DB sync we set optin on true, action by owner
22
+ $contactModel->setOptIn(true);
23
+ $contactModel->setOptOut(false);
24
+ $contactModel->setOptActionBy(OptActionBy::Owner);
25
+ } else {
26
+ //Get contact data from submission
27
+ $contactModel->setOptIn(boolval($user->consent));
28
+ $contactModel->setOptActionBy(OptActionBy::Visitor);
29
+ }
30
 
31
  $email = $user->email;
32
  if (!empty($email)) {
47
  }
48
  $contactModel->setLastName($lastName);
49
  }
50
+ if (!empty($user->phone)) {
51
+ $contactModel->setPhone($user->phone);
52
+ }
53
+ if (!empty($user->birthday)) {
54
+ $contactModel->set_birthday($user->birthday);
55
+ }
56
 
57
  return $contactModel;
58
  }
104
  }
105
  //Else check if we can find an email value in text fields
106
  foreach ($form['fields'] as $field) {
107
+ if (in_array(strtolower($field["type"]), $this->textFormFields) && in_array(strtolower($field["label"]), $this->emailFields)) {
108
  $possibleEmail = rgar($entry, $field["id"]);
109
  if (filter_var($possibleEmail, FILTER_VALIDATE_EMAIL)) {
110
  return $possibleEmail;
114
  return $email;
115
  }
116
 
117
+ private function FindFormData($contact, $entry, $form)
118
+ {
119
+ foreach ($form['fields'] as $field) {
120
+ if (strtolower($field["type"]) === 'phone' && in_array(strtolower($field["label"]), $this->phoneFields)) {
121
+ $contact->phone = rgar($entry, $field["id"]);
122
+ } elseif (strtolower($field["type"]) === 'date' && in_array(strtolower($field["label"]), $this->birthdayFields)) {
123
+ $contact->birthday = rgar($entry, $field["id"]);
124
+ } elseif (strtolower($field["type"]) === 'consent' && strtolower($field["label"]) === 'consent') {
125
+ $contact->consent = rgar($entry, (string)($field["id"] + .1)); //consent values in the entry are weird
126
+ }
127
+ }
128
+ }
129
+
130
  public function ceHandleGravityFormSubmission($entry, $form)
131
  {
132
  try {
133
  $contact = new \stdClass();
134
  $contact->name = $this->GetNameValuesFromForm($entry, $form);
135
  $contact->email = $this->GetEmailFromForm($entry, $form);
136
+ $this->FindFormData($contact, $entry, $form);
137
  if (empty($contact->email)) {
138
  return;
139
+ }
140
 
141
+ $contact->isSync = false;
142
  $this->upsertContact($this->convertToContactModel($contact));
143
  } catch (\Exception $exception) {
144
  RaygunManager::get_instance()->exception_handler($exception);
148
  public function registerHooks()
149
  {
150
  add_action('gform_after_submission', array($this, 'ceHandleGravityFormSubmission'), 10, 2);
 
 
151
  }
152
 
153
  public function unregisterHooks()
154
  {
155
  remove_action('gform_after_submission', array($this, 'ceHandleGravityFormSubmission'));
 
 
156
  }
157
 
158
+ public function get_contacts($limit = null)
159
  {
160
  if (!is_int($limit) || $limit <= 0) {
161
  $limit = null;
199
  continue;
200
  }
201
  $contact->name = $this->GetNameValuesFromForm($entry, $formArray);
202
+ $this->FindFormData($contact, $entry, $formArray);
203
+ $contact->isSync = true;
204
 
205
  //Convert to contactModel
 
206
  $contactModel = null;
207
  try {
208
  $contactModel = $this->convertToContactModel($contact);
225
  }
226
 
227
  if (!empty($contactsArray)) {
228
+ return $contactsArray;
 
 
 
 
 
 
 
229
  }
230
+
231
+ return null;
232
  }
233
 
234
  function __construct()
src/modules/contacts/Handlers/JetpackPluginHandler.php CHANGED
@@ -43,7 +43,12 @@ class JetpackPluginHandler extends BaseContactFormPluginHandler
43
  if (!empty($lastName)) {
44
  $contactModel->setLastName($lastName);
45
  }
46
-
 
 
 
 
 
47
  return $contactModel;
48
  }
49
 
@@ -83,18 +88,14 @@ class JetpackPluginHandler extends BaseContactFormPluginHandler
83
  public function registerHooks()
84
  {
85
  add_action('grunion_after_message_sent', array($this, 'ceHandleJetpackFormSubmission'), 10, 7);
86
- // add hook function to synchronize
87
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
88
  }
89
 
90
  public function unregisterHooks()
91
  {
92
  remove_action('grunion_after_message_sent', array($this, 'ceHandleJetpackFormSubmission'));
93
- // remove hook function to synchronize
94
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
95
  }
96
 
97
- public function syncAction($limit = null)
98
  {
99
  if (!is_int($limit) || $limit <= 0) {
100
  $limit = null;
@@ -106,6 +107,8 @@ class JetpackPluginHandler extends BaseContactFormPluginHandler
106
  ) {
107
  $authorRegex = '/(?:^AUTHOR: )(.*)/mi';
108
  $authorMailRegex = '/(?:^AUTHOR EMAIL: )(.*)/mi';
 
 
109
  $consentRegex = '/(?:\[email_marketing_consent] =&gt; )(.*)/mi';
110
  $contactsArray = array();
111
 
@@ -150,6 +153,18 @@ class JetpackPluginHandler extends BaseContactFormPluginHandler
150
 
151
  $contact->opt_in = boolval($consentValue);
152
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  //Convert to contactModel and push to the array
154
  $contactModel = null;
155
  try {
@@ -173,15 +188,10 @@ class JetpackPluginHandler extends BaseContactFormPluginHandler
173
 
174
  //upsert the contacts
175
  if (!empty($contactsArray)) {
176
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
177
- foreach ($batches as $batch) {
178
- try {
179
- $this->batchUpsertContacts($batch);
180
- } catch (\Exception $exception) {
181
- RaygunManager::get_instance()->exception_handler($exception);
182
- }
183
- }
184
  }
185
  }
 
 
186
  }
187
  }
43
  if (!empty($lastName)) {
44
  $contactModel->setLastName($lastName);
45
  }
46
+ if (!empty($contact->phone)) {
47
+ $contactModel->setPhone($contact->phone);
48
+ }
49
+ if (!empty($contact->birthday)) {
50
+ $contactModel->set_birthday($contact->birthday);
51
+ }
52
  return $contactModel;
53
  }
54
 
88
  public function registerHooks()
89
  {
90
  add_action('grunion_after_message_sent', array($this, 'ceHandleJetpackFormSubmission'), 10, 7);
 
 
91
  }
92
 
93
  public function unregisterHooks()
94
  {
95
  remove_action('grunion_after_message_sent', array($this, 'ceHandleJetpackFormSubmission'));
 
 
96
  }
97
 
98
+ public function get_contacts($limit = null)
99
  {
100
  if (!is_int($limit) || $limit <= 0) {
101
  $limit = null;
107
  ) {
108
  $authorRegex = '/(?:^AUTHOR: )(.*)/mi';
109
  $authorMailRegex = '/(?:^AUTHOR EMAIL: )(.*)/mi';
110
+ $additionalFieldsRegex = '/(?:^\s{4})\[\d_(.*)\](?:.*;\s)(.*)/mi';
111
+
112
  $consentRegex = '/(?:\[email_marketing_consent] =&gt; )(.*)/mi';
113
  $contactsArray = array();
114
 
153
 
154
  $contact->opt_in = boolval($consentValue);
155
 
156
+ preg_match_all($additionalFieldsRegex, $feedbackHtml, $additionalFieldMatches);
157
+ if (count($additionalFieldMatches) > 1) {
158
+ foreach ($additionalFieldMatches[1] as $index => $label) {
159
+ $fieldValue = $additionalFieldMatches[2][$index];
160
+ if (in_array(strtolower($label), $this->phoneFields)) {
161
+ $contact->phone = $fieldValue;
162
+ } elseif (in_array(strtolower($label), $this->birthdayFields)) {
163
+ $contact->birthday = $fieldValue;
164
+ }
165
+ }
166
+ }
167
+
168
  //Convert to contactModel and push to the array
169
  $contactModel = null;
170
  try {
188
 
189
  //upsert the contacts
190
  if (!empty($contactsArray)) {
191
+ return $contactsArray;
 
 
 
 
 
 
 
192
  }
193
  }
194
+
195
+ return null;
196
  }
197
  }
src/modules/contacts/Handlers/NewsLetterContactFormPluginHandler.php CHANGED
@@ -49,18 +49,14 @@ class NewsLetterContactFormPluginHandler extends BaseContactFormPluginHandler
49
  public function registerHooks()
50
  {
51
  add_action('newsletter_user_confirmed', array($this, 'ceHandleContactNewsletterSubmit'));
52
- // add hook function to synchronize
53
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
54
  }
55
 
56
  public function unregisterHooks()
57
  {
58
  remove_action('newsletter_user_confirmed', array($this, 'ceHandleContactNewsletterSubmit'));
59
- // remove hook function to synchronize
60
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
61
  }
62
 
63
- public function syncAction($limit = null)
64
  {
65
  if (!is_int($limit) || $limit <= 0) {
66
  $limit = null;
@@ -116,16 +112,10 @@ class NewsLetterContactFormPluginHandler extends BaseContactFormPluginHandler
116
  }
117
 
118
  if (!empty($backfillArray)) {
119
-
120
- $batches = array_chunk($backfillArray, CE4WP_BATCH_SIZE);
121
- foreach ($batches as $batch) {
122
- try {
123
- $this->batchUpsertContacts($batch);
124
- } catch (\Exception $exception) {
125
- RaygunManager::get_instance()->exception_handler($exception);
126
- }
127
- }
128
  }
 
 
129
  }
130
 
131
  function __construct()
49
  public function registerHooks()
50
  {
51
  add_action('newsletter_user_confirmed', array($this, 'ceHandleContactNewsletterSubmit'));
 
 
52
  }
53
 
54
  public function unregisterHooks()
55
  {
56
  remove_action('newsletter_user_confirmed', array($this, 'ceHandleContactNewsletterSubmit'));
 
 
57
  }
58
 
59
+ public function get_contacts($limit = null)
60
  {
61
  if (!is_int($limit) || $limit <= 0) {
62
  $limit = null;
112
  }
113
 
114
  if (!empty($backfillArray)) {
115
+ return $backfillArray;
 
 
 
 
 
 
 
 
116
  }
117
+
118
+ return null;
119
  }
120
 
121
  function __construct()
src/modules/contacts/Handlers/NinjaFormsPluginHandler.php CHANGED
@@ -15,16 +15,6 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
15
  parent::__construct();
16
  }
17
 
18
- private function getEmailFromForm($fields)
19
- {
20
- foreach ($fields as $field) {
21
- if ($field["key"] == "email" || $field["type"] == "email") {
22
- return $field["value"];
23
- }
24
- }
25
- return null;
26
- }
27
-
28
  private function getNameFromForm($fields)
29
  {
30
  $name = null;
@@ -43,6 +33,19 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
43
  return !empty($name) ? $name : null;
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  public function convertToContactModel($contact)
47
  {
48
  $contactModel = new ContactModel();
@@ -51,10 +54,10 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
51
  //optin true on sync, false on form submission
52
  $contactModel->setOptIn($contact->opt_in);
53
  $contactModel->setOptOut(false);
54
- $contactModel->setOptActionBy(OptActionBy::Owner);
55
 
56
  if (isset($contact->optinByOwner)) {
57
- $contactModel->setOptIn(boolval($contact->optinByOwner));
58
  }
59
 
60
  $email = $contact->email;
@@ -80,6 +83,12 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
80
  if (!empty($lastName)) {
81
  $contactModel->setLastName($lastName);
82
  }
 
 
 
 
 
 
83
 
84
  return $contactModel;
85
  }
@@ -88,6 +97,9 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
88
  {
89
  //Attempt additional checking for name in an attempt to get custom form fields for names
90
  $name = null;
 
 
 
91
  if (strpos($field_key, "full_name") !== false || isset($field_values["name"])) {
92
  $contact->name = $field_values[$field_key];
93
  return;
@@ -97,7 +109,7 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
97
  return;
98
  }
99
  if (strpos($field_key, "last_name") !== false || isset($field_values["lastname"])) {
100
- $contact->lastname = $field_values[$field_key];
101
  return;
102
  }
103
  }
@@ -106,8 +118,7 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
106
  {
107
  try {
108
  $ninjaContact = new \stdClass();
109
- $ninjaContact->email = $this->getEmailFromForm($form_data["fields_by_key"]);
110
-
111
  if (empty($ninjaContact->email)) {
112
  return;
113
  };
@@ -122,18 +133,14 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
122
  public function registerHooks()
123
  {
124
  add_action('ninja_forms_after_submission', array($this, 'ceHandleNinjaFormSubmission'), 10, 1);
125
- // add hook function to synchronize
126
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
127
  }
128
 
129
  public function unregisterHooks()
130
  {
131
  remove_action('ninja_forms_after_submission', array($this, 'ceHandleNinjaFormSubmission'));
132
- // remove hook function to synchronize
133
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
134
  }
135
 
136
- public function syncAction($limit = null)
137
  {
138
  if (!is_int($limit) || $limit <= 0) {
139
  $limit = null;
@@ -160,25 +167,34 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
160
  $field_settings = $field->get_settings();
161
  $field_key = $field_settings["key"];
162
  $field_type = $field_settings["type"];
 
163
 
164
  switch ($field_type) {
165
  case 'email';
166
- $email = isset($field_values[$field_key]) ? $field_values[$field_key] : null;
167
  if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
168
  $contact->email = $email;
169
  }
170
  break;
 
 
 
 
 
 
 
 
171
  case 'name';
172
  case 'full_name';
173
- $contact->name = $field_values[$field_key];
174
  break;
175
  case 'firstname';
176
  case 'first_name';
177
- $contact->firstName = $field_values[$field_key];
178
  break;
179
  case 'lastname';
180
  case 'last_name';
181
- $contact->lastname = $field_values[$field_key];
182
  break;
183
  case 'textbox';
184
  case 'text';
@@ -194,7 +210,7 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
194
  if (!empty($contact->email) && $contact->email != null) {
195
  //set optin by owner on db sync
196
  $contact->optinByOwner = true;
197
-
198
 
199
  //Convert to contactModel and push to the array
200
  $contactModel = null;
@@ -219,14 +235,13 @@ class NinjaFormsPluginHandler extends BaseContactFormPluginHandler
219
 
220
  //upsert the contacts
221
  if (!empty($contactsArray)) {
222
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
223
- foreach ($batches as $batch) {
224
- $this->batchUpsertContacts($batch);
225
- }
226
  }
227
  }
228
  } catch (\Exception $exception) {
229
  RaygunManager::get_instance()->exception_handler($exception);
230
  }
 
 
231
  }
232
  }
15
  parent::__construct();
16
  }
17
 
 
 
 
 
 
 
 
 
 
 
18
  private function getNameFromForm($fields)
19
  {
20
  $name = null;
33
  return !empty($name) ? $name : null;
34
  }
35
 
36
+ private function FindFormValues($contact, $fields)
37
+ {
38
+ foreach ($fields as $field) {
39
+ if (in_array($field["key"], $this->emailFields) || in_array($field["type"], $this->emailFields)) {
40
+ $contact->email = $field["value"];
41
+ } elseif (in_array($field["key"], $this->phoneFields) || in_array($field["type"], $this->phoneFields)) {
42
+ $contact->phone = $field["value"];
43
+ } elseif (in_array($field["key"], $this->birthdayFields) || in_array(strtolower($field["label"]), $this->birthdayFields)) {
44
+ $contact->birthday = $field["value"];
45
+ }
46
+ }
47
+ }
48
+
49
  public function convertToContactModel($contact)
50
  {
51
  $contactModel = new ContactModel();
54
  //optin true on sync, false on form submission
55
  $contactModel->setOptIn($contact->opt_in);
56
  $contactModel->setOptOut(false);
57
+ $contactModel->setOptActionBy(OptActionBy::Visitor);
58
 
59
  if (isset($contact->optinByOwner)) {
60
+ $contactModel->setOptActionBy(OptActionBy::Owner);
61
  }
62
 
63
  $email = $contact->email;
83
  if (!empty($lastName)) {
84
  $contactModel->setLastName($lastName);
85
  }
86
+ if (!empty($contact->phone)) {
87
+ $contactModel->setPhone($contact->phone);
88
+ }
89
+ if (!empty($contact->birthday)) {
90
+ $contactModel->set_birthday($contact->birthday);
91
+ }
92
 
93
  return $contactModel;
94
  }
97
  {
98
  //Attempt additional checking for name in an attempt to get custom form fields for names
99
  $name = null;
100
+ if (!isset($field_values[$field_key])) {
101
+ return null;
102
+ }
103
  if (strpos($field_key, "full_name") !== false || isset($field_values["name"])) {
104
  $contact->name = $field_values[$field_key];
105
  return;
109
  return;
110
  }
111
  if (strpos($field_key, "last_name") !== false || isset($field_values["lastname"])) {
112
+ $contact->lastName = $field_values[$field_key];
113
  return;
114
  }
115
  }
118
  {
119
  try {
120
  $ninjaContact = new \stdClass();
121
+ $this->FindFormValues($ninjaContact, $form_data["fields_by_key"]);
 
122
  if (empty($ninjaContact->email)) {
123
  return;
124
  };
133
  public function registerHooks()
134
  {
135
  add_action('ninja_forms_after_submission', array($this, 'ceHandleNinjaFormSubmission'), 10, 1);
 
 
136
  }
137
 
138
  public function unregisterHooks()
139
  {
140
  remove_action('ninja_forms_after_submission', array($this, 'ceHandleNinjaFormSubmission'));
 
 
141
  }
142
 
143
+ public function get_contacts($limit = null)
144
  {
145
  if (!is_int($limit) || $limit <= 0) {
146
  $limit = null;
167
  $field_settings = $field->get_settings();
168
  $field_key = $field_settings["key"];
169
  $field_type = $field_settings["type"];
170
+ $field_value = isset($field_values[$field_key]) ? $field_values[$field_key] : null; //this prevents undefined index on altered forms
171
 
172
  switch ($field_type) {
173
  case 'email';
174
+ $email = $field_value;
175
  if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
176
  $contact->email = $email;
177
  }
178
  break;
179
+ case 'phone';
180
+ $contact->phone = $field_value;
181
+ break;
182
+ case 'date';
183
+ if (in_array(strtolower($field_settings['label']), $this->birthdayFields)) {
184
+ $contact->birthday = $field_value;
185
+ }
186
+ break;
187
  case 'name';
188
  case 'full_name';
189
+ $contact->name = $field_value;
190
  break;
191
  case 'firstname';
192
  case 'first_name';
193
+ $contact->firstName = $field_value;
194
  break;
195
  case 'lastname';
196
  case 'last_name';
197
+ $contact->lastName = $field_value;
198
  break;
199
  case 'textbox';
200
  case 'text';
210
  if (!empty($contact->email) && $contact->email != null) {
211
  //set optin by owner on db sync
212
  $contact->optinByOwner = true;
213
+ $contact->opt_in = true;
214
 
215
  //Convert to contactModel and push to the array
216
  $contactModel = null;
235
 
236
  //upsert the contacts
237
  if (!empty($contactsArray)) {
238
+ return $contactsArray;
 
 
 
239
  }
240
  }
241
  } catch (\Exception $exception) {
242
  RaygunManager::get_instance()->exception_handler($exception);
243
  }
244
+
245
+ return null;
246
  }
247
  }
src/modules/contacts/Handlers/WooCommercePluginHandler.php CHANGED
@@ -52,6 +52,10 @@ class WooCommercePluginHandler extends BaseContactFormPluginHandler
52
  $contactModel->setOptOut(false);
53
  }
54
 
 
 
 
 
55
  $checkbox_value = null;
56
 
57
  if (!empty($_POST[self::CHECKOUT_CONSENT_CHECKBOX_ID])) {
@@ -116,18 +120,14 @@ class WooCommercePluginHandler extends BaseContactFormPluginHandler
116
  public function registerHooks()
117
  {
118
  add_action('woocommerce_checkout_order_created', array($this, 'ceHandlerWooCommerceNewOrder'), 10, 1);
119
- // hook function to synchronize
120
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
121
  }
122
 
123
  public function unregisterHooks()
124
  {
125
  remove_action('woocommerce_checkout_order_created', array($this, 'ceHandlerWooCommerceOrder'));
126
- // remove hook function to synchronize
127
- remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
128
  }
129
 
130
- public function syncAction($limit = null)
131
  {
132
  if (!is_int($limit) || $limit <= 0) {
133
  $limit = null;
@@ -163,11 +163,10 @@ class WooCommercePluginHandler extends BaseContactFormPluginHandler
163
  }
164
 
165
  if (!empty($backfillArray)) {
166
- $batches = array_chunk($backfillArray, CE4WP_BATCH_SIZE);
167
- foreach ($batches as $batch) {
168
- $this->batchUpsertContacts($batch);
169
- }
170
  }
 
 
171
  }
172
 
173
  function __construct()
52
  $contactModel->setOptOut(false);
53
  }
54
 
55
+ if (!empty($products_detail["_billing_phone"])) {
56
+ $contactModel->setPhone($products_detail["_billing_phone"][0]);
57
+ }
58
+
59
  $checkbox_value = null;
60
 
61
  if (!empty($_POST[self::CHECKOUT_CONSENT_CHECKBOX_ID])) {
120
  public function registerHooks()
121
  {
122
  add_action('woocommerce_checkout_order_created', array($this, 'ceHandlerWooCommerceNewOrder'), 10, 1);
 
 
123
  }
124
 
125
  public function unregisterHooks()
126
  {
127
  remove_action('woocommerce_checkout_order_created', array($this, 'ceHandlerWooCommerceOrder'));
 
 
128
  }
129
 
130
+ public function get_contacts($limit = null)
131
  {
132
  if (!is_int($limit) || $limit <= 0) {
133
  $limit = null;
163
  }
164
 
165
  if (!empty($backfillArray)) {
166
+ return $backfillArray;
 
 
 
167
  }
168
+
169
+ return null;
170
  }
171
 
172
  function __construct()
src/modules/contacts/Handlers/WpFormsPluginHandler.php CHANGED
@@ -62,8 +62,22 @@ class WpFormsPluginHandler extends BaseContactFormPluginHandler
62
  }
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  $consentField = $this->get_form_type_field($formData, "gdpr-checkbox");
66
- if ($this->isNotNullOrEmpty($consentField) && array_key_exists('value', $consentField) && $consentField) {
67
  //If a gdpr checkbox is present it is required before submitting
68
  //The value is a string like "I consent to having this website store my information . . . " instead of a bool
69
  //Will assume people won't alter or change this to be the other way around so having this value == consent
@@ -78,8 +92,7 @@ class WpFormsPluginHandler extends BaseContactFormPluginHandler
78
  {
79
  try {
80
  $this->upsertContact($this->convertToContactModel($fields));
81
- }
82
- catch (\Exception $exception) {
83
  RaygunManager::get_instance()->exception_handler($exception);
84
  }
85
  }
@@ -88,7 +101,6 @@ class WpFormsPluginHandler extends BaseContactFormPluginHandler
88
  {
89
  // https://wpforms.com/developers/wpforms_process_complete/
90
  add_action('wpforms_process_complete', array($this, 'ceHandleWpFormsProcessComplete'), 10, 4);
91
- add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'syncAction'));
92
  }
93
 
94
  public function unregisterHooks()
@@ -96,7 +108,7 @@ class WpFormsPluginHandler extends BaseContactFormPluginHandler
96
  remove_action('wpforms_process_complete', array($this, 'ceHandleWpFormsProcessComplete'));
97
  }
98
 
99
- public function syncAction($limit = null)
100
  {
101
  if (!is_int($limit) || $limit <= 0) {
102
  $limit = null;
@@ -136,16 +148,11 @@ class WpFormsPluginHandler extends BaseContactFormPluginHandler
136
  }
137
 
138
  if (!empty($contactsArray)) {
139
- $batches = array_chunk($contactsArray, CE4WP_BATCH_SIZE);
140
- foreach ($batches as $batch) {
141
- try {
142
- $this->batchUpsertContacts($batch);
143
- } catch (\Exception $exception) {
144
- RaygunManager::get_instance()->exception_handler($exception);
145
- }
146
- }
147
  }
148
  }
 
 
149
  }
150
 
151
  function __construct()
62
  }
63
  }
64
 
65
+ $phoneField = $this->get_form_type_field($formData, 'phone');
66
+ if (!empty($phoneField) && array_key_exists('value', $phoneField)) {
67
+ if (!empty($phoneField['value'])) {
68
+ $contactModel->setPhone($phoneField['value']);
69
+ }
70
+ }
71
+
72
+ $dateField = $this->get_form_type_field($formData, 'date-time');
73
+ if (!empty($dateField) && array_key_exists('date', $dateField)) {
74
+ if (!empty($dateField['date']) && in_array(strtolower($dateField['name']), $this->birthdayFields)) {
75
+ $contactModel->set_birthday($dateField['date']);
76
+ }
77
+ }
78
+
79
  $consentField = $this->get_form_type_field($formData, "gdpr-checkbox");
80
+ if (!empty($consentField) && array_key_exists('value', $consentField) && $consentField) {
81
  //If a gdpr checkbox is present it is required before submitting
82
  //The value is a string like "I consent to having this website store my information . . . " instead of a bool
83
  //Will assume people won't alter or change this to be the other way around so having this value == consent
92
  {
93
  try {
94
  $this->upsertContact($this->convertToContactModel($fields));
95
+ } catch (\Exception $exception) {
 
96
  RaygunManager::get_instance()->exception_handler($exception);
97
  }
98
  }
101
  {
102
  // https://wpforms.com/developers/wpforms_process_complete/
103
  add_action('wpforms_process_complete', array($this, 'ceHandleWpFormsProcessComplete'), 10, 4);
 
104
  }
105
 
106
  public function unregisterHooks()
108
  remove_action('wpforms_process_complete', array($this, 'ceHandleWpFormsProcessComplete'));
109
  }
110
 
111
+ public function get_contacts($limit = null)
112
  {
113
  if (!is_int($limit) || $limit <= 0) {
114
  $limit = null;
148
  }
149
 
150
  if (!empty($contactsArray)) {
151
+ return $contactsArray;
 
 
 
 
 
 
 
152
  }
153
  }
154
+
155
+ return null;
156
  }
157
 
158
  function __construct()
src/modules/contacts/Managers/ContactsSyncManager.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Modules\Contacts\Managers;
4
+
5
+ use CreativeMail\Modules\Contacts\Processors\ContactsSyncBackgroundProcessor;
6
+
7
+ class ContactsSyncManager
8
+ {
9
+ private $contacts_sync_background_processor;
10
+
11
+ public function __construct()
12
+ {
13
+ $this->contacts_sync_background_processor = new ContactsSyncBackgroundProcessor();
14
+
15
+ add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'publish_contact_sync_request'));
16
+ }
17
+
18
+ public function __destruct()
19
+ {
20
+ remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'publish_contact_sync_request'));
21
+ }
22
+
23
+ public function publish_contact_sync_request()
24
+ {
25
+ $this->contacts_sync_background_processor->push_to_queue(null);
26
+
27
+ // Start the queue.
28
+ $this->contacts_sync_background_processor->save()->dispatch();
29
+ }
30
+ }
src/modules/contacts/Processes/ContactsSyncBackgroundProcessor.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace CreativeMail\Modules\Contacts\Processors;
4
+
5
+ use CreativeMail\Helpers\ValidationHelper;
6
+ use CreativeMail\Managers\IntegrationManager;
7
+ use CreativeMail\Managers\RaygunManager;
8
+ use CreativeMail\Modules\Contacts\Services\ContactsSyncService;
9
+ use CreativeMail\Integrations\Integration;
10
+ use ReflectionClass;
11
+ use WP_Background_Process;
12
+
13
+ class ContactsSyncBackgroundProcessor extends WP_Background_Process
14
+ {
15
+ protected $action = 'ce_contact_sync_background_process';
16
+
17
+ /**
18
+ * Task
19
+ *
20
+ * Override this method to perform any actions required on each
21
+ * queue item. Return the modified item for further processing
22
+ * in the next pass through. Or, return false to remove the
23
+ * item from the queue.
24
+ *
25
+ * @param mixed
26
+ *
27
+ * @return mixed
28
+ */
29
+ protected function task($item)
30
+ {
31
+ try {
32
+ // Synchronize contacts based on the active plugins
33
+ $integrationManager = new IntegrationManager();
34
+ $activated_integrations = $integrationManager->get_activated_integrations();
35
+
36
+ if (isset($activated_integrations) && !empty($activated_integrations)) {
37
+ $this->start_contacts_sync_for_all_integrations($activated_integrations);
38
+ }
39
+ } catch (\Exception $exception) {
40
+ RaygunManager::get_instance()->exception_handler($exception);
41
+ }
42
+
43
+ return false;
44
+ }
45
+
46
+ /**
47
+ * Starts the contacts sync for all the activated plugins
48
+ *
49
+ * @param Integration[] $activated_integrations
50
+ */
51
+ private function start_contacts_sync_for_all_integrations($activated_integrations)
52
+ {
53
+ if (!ValidationHelper::is_null_or_empty($activated_integrations)) {
54
+ // todo throw exception
55
+ }
56
+
57
+ $total_contacts = array();
58
+
59
+ // get all contacts
60
+ foreach ($activated_integrations as $activated_integration) {
61
+
62
+ $class = new ReflectionClass($activated_integration->get_integration_handler());
63
+ $plugin_handler = $class->newInstance();
64
+ $plugin_contacts = $plugin_handler->get_contacts(null);
65
+ if (isset($plugin_contacts) && !empty($plugin_contacts)) {
66
+ foreach ($plugin_contacts as $plugin_contact) {
67
+ array_push($total_contacts, $plugin_contact);
68
+ }
69
+ }
70
+ }
71
+
72
+ if (!empty($total_contacts)) {
73
+ // start contact sync
74
+
75
+ $contactSyncService = new ContactsSyncService();
76
+ $contactSyncService->upsertContacts($total_contacts);
77
+ }
78
+ }
79
+ }
src/modules/contacts/Services/ContactsSyncService.php CHANGED
@@ -3,12 +3,20 @@
3
  namespace CreativeMail\Modules\Contacts\Services;
4
 
5
  use CreativeMail\CreativeMail;
 
 
 
 
6
  use CreativeMail\Modules\Api\Models\ApiRequestItem;
7
  use CreativeMail\Modules\Contacts\Models\ContactModel;
8
  use Exception;
 
9
 
10
  class ContactsSyncService
11
  {
 
 
 
12
  private function validate_email_address($emailAddress)
13
  {
14
  if (!isset($emailAddress) && empty($emailAddress)) {
@@ -49,23 +57,12 @@ class ContactsSyncService
49
  $this->validate_email_address($contactModel->getEmail());
50
  $contactModel->setEventType($this->ensure_event_type($contactModel->getEventType()));
51
 
52
- $this->upsertContacts(array($contactModel), 1);
53
-
54
- return true;
55
- }
56
-
57
- public function upsertContacts($contactModels, $batchSize = 250)
58
- {
59
 
60
- $creativemail = CreativeMail::get_instance();
61
 
62
- // split in chunks of $batchSize
63
- $chunks = array_chunk($contactModels, $batchSize);
64
- foreach ($chunks as $chunk)
65
- {
66
- $jsonData = $this->build_payload($chunk);
67
 
68
- $creativemail->get_api_manager()->get_api_background_process()->push_to_queue(
69
  new ApiRequestItem(
70
  'POST',
71
  'application/json',
@@ -73,11 +70,209 @@ class ContactsSyncService
73
  $jsonData
74
  )
75
  );
76
- }
77
 
78
  // Start the queue.
79
- $creativemail->get_api_manager()->get_api_background_process()->save()->dispatch();
80
 
81
  return true;
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
3
  namespace CreativeMail\Modules\Contacts\Services;
4
 
5
  use CreativeMail\CreativeMail;
6
+ use CreativeMail\Helpers\EnvironmentHelper;
7
+ use CreativeMail\Helpers\OptionsHelper;
8
+ use CreativeMail\Helpers\ValidationHelper;
9
+ use CreativeMail\Managers\RaygunManager;
10
  use CreativeMail\Modules\Api\Models\ApiRequestItem;
11
  use CreativeMail\Modules\Contacts\Models\ContactModel;
12
  use Exception;
13
+ use stdClass;
14
 
15
  class ContactsSyncService
16
  {
17
+ const FAST_LANE_LIMIT = 250;
18
+ const CSV_FILE_MAX_MEMORY_SIZE = 1024 * 1024 * 5; // 5MB
19
+
20
  private function validate_email_address($emailAddress)
21
  {
22
  if (!isset($emailAddress) && empty($emailAddress)) {
57
  $this->validate_email_address($contactModel->getEmail());
58
  $contactModel->setEventType($this->ensure_event_type($contactModel->getEventType()));
59
 
60
+ $jsonData = $this->build_payload(array($contactModel));
 
 
 
 
 
 
61
 
62
+ $creativ_email = CreativeMail::get_instance();
63
 
 
 
 
 
 
64
 
65
+ $creativ_email->get_api_manager()->get_api_background_process()->push_to_queue(
66
  new ApiRequestItem(
67
  'POST',
68
  'application/json',
70
  $jsonData
71
  )
72
  );
 
73
 
74
  // Start the queue.
75
+ $creativ_email->get_api_manager()->get_api_background_process()->save()->dispatch();
76
 
77
  return true;
78
  }
79
+
80
+ public function upsertContacts($contactModels)
81
+ {
82
+ try {
83
+ if (ValidationHelper::is_null_or_empty($contactModels)) {
84
+ // todo throw exception
85
+ }
86
+
87
+ if (count($contactModels) > self::FAST_LANE_LIMIT) {
88
+ $this->fast_lane_contacts_sync(array_slice($contactModels, 0, self::FAST_LANE_LIMIT));
89
+ $this->slow_lane_contacts_sync(array_slice($contactModels, self::FAST_LANE_LIMIT, count($contactModels) - self::FAST_LANE_LIMIT));
90
+
91
+ } else {
92
+ $this->fast_lane_contacts_sync($contactModels);
93
+ }
94
+ } catch (Exception $exception) {
95
+ RaygunManager::get_instance()->exception_handler($exception);
96
+ }
97
+
98
+ return true;
99
+ }
100
+
101
+ private function fast_lane_contacts_sync($contactModels)
102
+ {
103
+ if (ValidationHelper::is_null_or_empty($contactModels)) {
104
+ // todo throw exception
105
+ }
106
+
107
+ $url = EnvironmentHelper::get_app_gateway_url('wordpress') . '/v1.0/contacts';
108
+
109
+ $jsonData = $this->build_payload($contactModels);
110
+
111
+ $args = [
112
+ 'headers' => [
113
+ 'x-api-key' => OptionsHelper::get_instance_api_key(),
114
+ 'x-account-id' => OptionsHelper::get_connected_account_id(),
115
+ 'content-type' => 'application/json'
116
+ ],
117
+ 'body' => $jsonData
118
+ ];
119
+
120
+ wp_remote_post($url, $args);
121
+ }
122
+
123
+ private function slow_lane_contacts_sync($contactModels)
124
+ {
125
+ if (ValidationHelper::is_null_or_empty($contactModels)) {
126
+ // todo throw exception
127
+ }
128
+
129
+ // 1. convert to csv file
130
+ $csv_file = $this->create_csv_file($contactModels);
131
+ // 2. request sas model (with url and uuid)
132
+ $sas_request_model = $this->request_sas_model();
133
+ // 3. upload csv file using sas url
134
+ $this->upload_csv_file($csv_file, $sas_request_model->url);
135
+ // 4. call endpoint to start import (using uuid)
136
+ $this->start_import_for_uuid($sas_request_model->uuid);
137
+
138
+ }
139
+
140
+ private function create_csv_file($contactModels)
141
+ {
142
+ if (ValidationHelper::is_null_or_empty($contactModels)) {
143
+ // todo throw exception
144
+ }
145
+
146
+ $fd = fopen('php://temp/maxmemory:' . self::CSV_FILE_MAX_MEMORY_SIZE, 'w');
147
+ if ($fd === false) {
148
+ // todo throw exception
149
+ }
150
+
151
+ foreach($contactModels as $contactModel) {
152
+ $contact_fields_array = $this->convert_contact_to_csv_array($contactModel);
153
+ if (!ValidationHelper::is_null_or_empty($contact_fields_array)) {
154
+ fputcsv($fd, $contact_fields_array);
155
+ }
156
+ }
157
+
158
+ rewind($fd);
159
+ $csv_content = stream_get_contents($fd);
160
+ fclose($fd);
161
+
162
+ return $csv_content;
163
+ }
164
+
165
+ private function request_sas_model()
166
+ {
167
+ $url = EnvironmentHelper::get_app_gateway_url('wordpress') . '/v1.0/contacts/request-import-sas-url';
168
+ $args = [
169
+ 'headers' => [
170
+ 'x-api-key' => OptionsHelper::get_instance_api_key(),
171
+ 'x-account-id' => OptionsHelper::get_connected_account_id()
172
+ ]
173
+ ];
174
+ $response = wp_remote_get($url,
175
+ $args);
176
+
177
+ if (is_wp_error($response)) {
178
+ // todo throw error
179
+ }
180
+
181
+ if (!$this->is_success_response($response)) {
182
+ // todo throw error
183
+ }
184
+
185
+ $json = json_decode($response['body']);
186
+
187
+ $request_sas_model = new stdClass();
188
+ $request_sas_model->url = $json->url;
189
+ $request_sas_model->uuid = $json->uuid;
190
+
191
+ return $request_sas_model;
192
+ }
193
+
194
+ private function upload_csv_file($csv_file, $upload_url)
195
+ {
196
+ $args = array(
197
+ 'headers' => array(
198
+ 'x-ms-blob-type' => 'BlockBlob',
199
+ 'content-type' => 'text/plain'
200
+ ),
201
+ 'body' => $csv_file,
202
+ 'method' => 'PUT'
203
+ );
204
+
205
+ $response = wp_remote_request($upload_url, $args);
206
+
207
+ if (is_wp_error($response)) {
208
+ // todo throw exception
209
+ }
210
+
211
+ if (!$this->is_success_response($response)) {
212
+ // todo throw exception
213
+ }
214
+ }
215
+
216
+ private function start_import_for_uuid($uuid)
217
+ {
218
+ $url = EnvironmentHelper::get_app_gateway_url('wordpress') . '/v1.0/contacts/import';
219
+
220
+ $data = array (
221
+ 'uuid' => $uuid
222
+ );
223
+
224
+ $args = [
225
+ 'headers' => [
226
+ 'x-api-key' => OptionsHelper::get_instance_api_key(),
227
+ 'x-account-id' => OptionsHelper::get_connected_account_id(),
228
+ 'content-type' => 'application/json'
229
+ ],
230
+ 'body' => wp_json_encode($data),
231
+ 'method' => 'POST'
232
+ ];
233
+
234
+ $response = wp_remote_post($url,
235
+ $args);
236
+
237
+ if (is_wp_error($response)) {
238
+ // todo throw exception
239
+ }
240
+
241
+ if(!$this->is_success_response($response)) {
242
+ // todo throw exception
243
+ }
244
+ }
245
+
246
+ private function convert_contact_to_csv_array(ContactModel $contactModel)
247
+ {
248
+ if (ValidationHelper::is_null_or_empty($contactModel)) {
249
+ return null;
250
+ }
251
+
252
+ $contact_fields = array(
253
+ strval($contactModel->getEmail()),
254
+ strval($contactModel->getFirstName()),
255
+ strval($contactModel->getLastName()));
256
+
257
+
258
+ $contactAddressModel = $contactModel->getContactAddress();
259
+
260
+ if (ValidationHelper::is_null_or_empty($contactAddressModel)) {
261
+ array_push($contact_fields, '','', '', '', '');
262
+ } else {
263
+ array_push($contact_fields, strval($contactAddressModel->getAddress()), strval($contactAddressModel->getCity()), strval($contactAddressModel->getPostalCode()),
264
+ strval($contactAddressModel->getCountryCode()), strval($contactAddressModel->getState()));
265
+ }
266
+
267
+ array_push($contact_fields, strval($contactModel->getPhone()), strval($contactModel->get_birthday()), strval($contactModel->getCompanyName()), '', // JobTitle
268
+ strval($contactModel->getOptIn()), strval($contactModel->getOptOut()), strval($contactModel->getEventType()));
269
+ return $contact_fields;
270
+ }
271
+
272
+ private function is_success_response($response)
273
+ {
274
+ $response_code = wp_remote_retrieve_response_code($response);
275
+
276
+ return $response_code >= 200 && $response_code <= 299;
277
+ }
278
  }
src/modules/contacts/models/ContactModel.php CHANGED
@@ -17,6 +17,7 @@ class ContactModel
17
  public $optActionBy;
18
  public $contactAddresses;
19
  public $eventType;
 
20
 
21
  function __construct()
22
  {
@@ -122,6 +123,11 @@ class ContactModel
122
  $this->contactAddresses = $contactAddresses;
123
  }
124
 
 
 
 
 
 
125
  public function getContactAddress()
126
  {
127
  return $this->contactAddresses;
@@ -137,6 +143,16 @@ class ContactModel
137
  return $this->eventType;
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
140
  function toArray()
141
  {
142
  $result = array(
17
  public $optActionBy;
18
  public $contactAddresses;
19
  public $eventType;
20
+ private $birthday;
21
 
22
  function __construct()
23
  {
123
  $this->contactAddresses = $contactAddresses;
124
  }
125
 
126
+ /**
127
+ * The address model for the contact.
128
+ *
129
+ * @return ContactAddressModel
130
+ */
131
  public function getContactAddress()
132
  {
133
  return $this->contactAddresses;
143
  return $this->eventType;
144
  }
145
 
146
+ public function get_birthday()
147
+ {
148
+ return $this->birthday;
149
+ }
150
+
151
+ public function set_birthday($birthday)
152
+ {
153
+ $this->birthday = $birthday;
154
+ }
155
+
156
  function toArray()
157
  {
158
  $result = array(
src/views/contact-sync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use CreativeMail\CreativeMail;
3
+ use CreativeMail\Helpers\EnvironmentHelper;
4
+ use CreativeMail\Helpers\OptionsHelper;
5
+
6
+ $contact_sync_available = !empty(CreativeMail::get_instance()->get_integration_manager()->get_active_plugins());
7
+ $supported_plugin_available = !empty(CreativeMail::get_instance()->get_integration_manager()->get_supported_integrations(true))
8
+ ?>
9
+
10
+ <div class="ce4wp-card">
11
+ <div class="ce4wp-px-4 ce4wp-py-4">
12
+ <h2 class="ce4wp-typography-root ce4wp-typography-h2 ce4wp-mb-2"><?= __( 'Contact Sync', 'ce4wp' ); ?></h2>
13
+ <?php
14
+ if ($contact_sync_available) {
15
+ include 'activated-integrations.php';
16
+ }
17
+ if($supported_plugin_available){
18
+ include 'available-integrations.php';
19
+ }
20
+ ?>
21
+ </div>
22
+ </div>
src/views/settings.php CHANGED
@@ -65,26 +65,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
65
  ?>
66
  </div>
67
  </div>
68
-
69
- <div class="ce4wp-card">
70
- <div class="ce4wp-px-4 ce4wp-py-4">
71
- <h2 class="ce4wp-typography-root ce4wp-typography-h2 ce4wp-mb-2"><?= __( 'Contact Sync', 'ce4wp' ); ?></h2>
72
-
73
- <?php
74
- if ($contact_sync_available) {
75
- include 'activated-integrations.php';
76
  }
77
- if($supported_plugin_available){
78
- include 'available-integrations.php';
79
  }
80
- ?>
81
- </div>
82
- </div>
83
-
84
- <?php
85
- if (EnvironmentHelper::is_test_environment()) {
86
- include 'settings-internal.php';
87
- }
88
  ?>
89
 
90
  <div class="ce4wp-card">
65
  ?>
66
  </div>
67
  </div>
68
+ <?php
69
+ if (OptionsHelper::get_instance_id()) {
70
+ include 'contact-sync.php';
 
 
 
 
 
71
  }
72
+ if (EnvironmentHelper::is_test_environment()) {
73
+ include 'settings-internal.php';
74
  }
 
 
 
 
 
 
 
 
75
  ?>
76
 
77
  <div class="ce4wp-card">
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInita94ac5d1b50913d18d3aa28a2e5a3c7b::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitf6dc660a62048f16678a088814efc407::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -15,6 +15,7 @@ return array(
15
  'CreativeMail\\Helpers\\GuidHelper' => $baseDir . '/src/helpers/GuidHelper.php',
16
  'CreativeMail\\Helpers\\OptionsHelper' => $baseDir . '/src/helpers/OptionsHelper.php',
17
  'CreativeMail\\Helpers\\SsoHelper' => $baseDir . '/src/helpers/SsoHelper.php',
 
18
  'CreativeMail\\Integrations\\Integration' => $baseDir . '/src/integrations/Integration.php',
19
  'CreativeMail\\Managers\\AdminManager' => $baseDir . '/src/managers/AdminManager.php',
20
  'CreativeMail\\Managers\\ApiManager' => $baseDir . '/src/managers/ApiManager.php',
@@ -30,6 +31,7 @@ return array(
30
  'CreativeMail\\Modules\\Blog\\Models\\BlogInformation' => $baseDir . '/src/modules/blog/models/BlogInformation.php',
31
  'CreativeMail\\Modules\\Blog\\Models\\BlogPost' => $baseDir . '/src/modules/blog/models/BlogPost.php',
32
  'CreativeMail\\Modules\\Contacts\\Handlers\\BaseContactFormPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/BaseContactFormPluginHandler.php',
 
33
  'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
34
  'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
35
  'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
@@ -39,16 +41,20 @@ return array(
39
  'CreativeMail\\Modules\\Contacts\\Handlers\\NinjaFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/NinjaFormsPluginHandler.php',
40
  'CreativeMail\\Modules\\Contacts\\Handlers\\WooCommercePluginHandler' => $baseDir . '/src/modules/contacts/Handlers/WooCommercePluginHandler.php',
41
  'CreativeMail\\Modules\\Contacts\\Handlers\\WpFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/WpFormsPluginHandler.php',
 
42
  'CreativeMail\\Modules\\Contacts\\Models\\ContactAddressModel' => $baseDir . '/src/modules/contacts/models/ContactAddressModel.php',
43
  'CreativeMail\\Modules\\Contacts\\Models\\ContactFormSevenSubmission' => $baseDir . '/src/modules/contacts/models/ContactFormSevenSubmission.php',
44
  'CreativeMail\\Modules\\Contacts\\Models\\ContactModel' => $baseDir . '/src/modules/contacts/models/ContactModel.php',
45
  'CreativeMail\\Modules\\Contacts\\Models\\OptActionBy' => $baseDir . '/src/modules/contacts/models/OptActionBy.php',
 
46
  'CreativeMail\\Modules\\Contacts\\Services\\ContactsSyncService' => $baseDir . '/src/modules/contacts/Services/ContactsSyncService.php',
47
  'CreativeMail\\Modules\\DashboardWidgetModule' => $baseDir . '/src/modules/DashboardWidgetModule.php',
48
  'CreativeMail\\Modules\\FeedbackNoticeModule' => $baseDir . '/src/modules/FeedbackNoticeModule.php',
49
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCInformationModel' => $baseDir . '/src/modules/woocommerce/models/WCInformationModel.php',
50
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCProductModel' => $baseDir . '/src/modules/woocommerce/models/WCProductModel.php',
51
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCStoreInformation' => $baseDir . '/src/modules/woocommerce/models/WCStoreInformation.php',
 
 
52
  'Defuse\\Crypto\\Core' => $vendorDir . '/defuse/php-encryption/src/Core.php',
53
  'Defuse\\Crypto\\Crypto' => $vendorDir . '/defuse/php-encryption/src/Crypto.php',
54
  'Defuse\\Crypto\\DerivedKeys' => $vendorDir . '/defuse/php-encryption/src/DerivedKeys.php',
15
  'CreativeMail\\Helpers\\GuidHelper' => $baseDir . '/src/helpers/GuidHelper.php',
16
  'CreativeMail\\Helpers\\OptionsHelper' => $baseDir . '/src/helpers/OptionsHelper.php',
17
  'CreativeMail\\Helpers\\SsoHelper' => $baseDir . '/src/helpers/SsoHelper.php',
18
+ 'CreativeMail\\Helpers\\ValidationHelper' => $baseDir . '/src/helpers/ValidationHelper.php',
19
  'CreativeMail\\Integrations\\Integration' => $baseDir . '/src/integrations/Integration.php',
20
  'CreativeMail\\Managers\\AdminManager' => $baseDir . '/src/managers/AdminManager.php',
21
  'CreativeMail\\Managers\\ApiManager' => $baseDir . '/src/managers/ApiManager.php',
31
  'CreativeMail\\Modules\\Blog\\Models\\BlogInformation' => $baseDir . '/src/modules/blog/models/BlogInformation.php',
32
  'CreativeMail\\Modules\\Blog\\Models\\BlogPost' => $baseDir . '/src/modules/blog/models/BlogPost.php',
33
  'CreativeMail\\Modules\\Contacts\\Handlers\\BaseContactFormPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/BaseContactFormPluginHandler.php',
34
+ 'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
35
  'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
36
  'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
37
  'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
41
  'CreativeMail\\Modules\\Contacts\\Handlers\\NinjaFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/NinjaFormsPluginHandler.php',
42
  'CreativeMail\\Modules\\Contacts\\Handlers\\WooCommercePluginHandler' => $baseDir . '/src/modules/contacts/Handlers/WooCommercePluginHandler.php',
43
  'CreativeMail\\Modules\\Contacts\\Handlers\\WpFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/WpFormsPluginHandler.php',
44
+ 'CreativeMail\\Modules\\Contacts\\Managers\\ContactsSyncManager' => $baseDir . '/src/modules/contacts/Managers/ContactsSyncManager.php',
45
  'CreativeMail\\Modules\\Contacts\\Models\\ContactAddressModel' => $baseDir . '/src/modules/contacts/models/ContactAddressModel.php',
46
  'CreativeMail\\Modules\\Contacts\\Models\\ContactFormSevenSubmission' => $baseDir . '/src/modules/contacts/models/ContactFormSevenSubmission.php',
47
  'CreativeMail\\Modules\\Contacts\\Models\\ContactModel' => $baseDir . '/src/modules/contacts/models/ContactModel.php',
48
  'CreativeMail\\Modules\\Contacts\\Models\\OptActionBy' => $baseDir . '/src/modules/contacts/models/OptActionBy.php',
49
+ 'CreativeMail\\Modules\\Contacts\\Processors\\ContactsSyncBackgroundProcessor' => $baseDir . '/src/modules/contacts/Processes/ContactsSyncBackgroundProcessor.php',
50
  'CreativeMail\\Modules\\Contacts\\Services\\ContactsSyncService' => $baseDir . '/src/modules/contacts/Services/ContactsSyncService.php',
51
  'CreativeMail\\Modules\\DashboardWidgetModule' => $baseDir . '/src/modules/DashboardWidgetModule.php',
52
  'CreativeMail\\Modules\\FeedbackNoticeModule' => $baseDir . '/src/modules/FeedbackNoticeModule.php',
53
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCInformationModel' => $baseDir . '/src/modules/woocommerce/models/WCInformationModel.php',
54
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCProductModel' => $baseDir . '/src/modules/woocommerce/models/WCProductModel.php',
55
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCStoreInformation' => $baseDir . '/src/modules/woocommerce/models/WCStoreInformation.php',
56
+ 'CreativeMail\\Modules\\contacts\\Exceptions\\InvalidContactSyncBackgroundRequestException' => $baseDir . '/src/modules/contacts/Exceptions/InvalidContactSyncBackgroundRequestException.php',
57
+ 'CreativeMail\\Modules\\contacts\\Exceptions\\InvalidHandlerContactSyncRequestException' => $baseDir . '/src/modules/contacts/Exceptions/InvalidHandlerContactSyncRequestException.php',
58
  'Defuse\\Crypto\\Core' => $vendorDir . '/defuse/php-encryption/src/Core.php',
59
  'Defuse\\Crypto\\Crypto' => $vendorDir . '/defuse/php-encryption/src/Crypto.php',
60
  'Defuse\\Crypto\\DerivedKeys' => $vendorDir . '/defuse/php-encryption/src/DerivedKeys.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInita94ac5d1b50913d18d3aa28a2e5a3c7b
6
  {
7
  private static $loader;
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInita94ac5d1b50913d18d3aa28a2e5a3c7b
22
  return self::$loader;
23
  }
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInita94ac5d1b50913d18d3aa28a2e5a3c7b', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
- spl_autoload_unregister(array('ComposerAutoloaderInita94ac5d1b50913d18d3aa28a2e5a3c7b', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitf6dc660a62048f16678a088814efc407
6
  {
7
  private static $loader;
8
 
22
  return self::$loader;
23
  }
24
 
25
+ spl_autoload_register(array('ComposerAutoloaderInitf6dc660a62048f16678a088814efc407', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitf6dc660a62048f16678a088814efc407', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
+ call_user_func(\Composer\Autoload\ComposerStaticInitf6dc660a62048f16678a088814efc407::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'F' =>
@@ -81,6 +81,7 @@ class ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b
81
  'CreativeMail\\Helpers\\GuidHelper' => __DIR__ . '/../..' . '/src/helpers/GuidHelper.php',
82
  'CreativeMail\\Helpers\\OptionsHelper' => __DIR__ . '/../..' . '/src/helpers/OptionsHelper.php',
83
  'CreativeMail\\Helpers\\SsoHelper' => __DIR__ . '/../..' . '/src/helpers/SsoHelper.php',
 
84
  'CreativeMail\\Integrations\\Integration' => __DIR__ . '/../..' . '/src/integrations/Integration.php',
85
  'CreativeMail\\Managers\\AdminManager' => __DIR__ . '/../..' . '/src/managers/AdminManager.php',
86
  'CreativeMail\\Managers\\ApiManager' => __DIR__ . '/../..' . '/src/managers/ApiManager.php',
@@ -96,6 +97,7 @@ class ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b
96
  'CreativeMail\\Modules\\Blog\\Models\\BlogInformation' => __DIR__ . '/../..' . '/src/modules/blog/models/BlogInformation.php',
97
  'CreativeMail\\Modules\\Blog\\Models\\BlogPost' => __DIR__ . '/../..' . '/src/modules/blog/models/BlogPost.php',
98
  'CreativeMail\\Modules\\Contacts\\Handlers\\BaseContactFormPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/BaseContactFormPluginHandler.php',
 
99
  'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
100
  'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
101
  'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
@@ -105,16 +107,20 @@ class ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b
105
  'CreativeMail\\Modules\\Contacts\\Handlers\\NinjaFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/NinjaFormsPluginHandler.php',
106
  'CreativeMail\\Modules\\Contacts\\Handlers\\WooCommercePluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/WooCommercePluginHandler.php',
107
  'CreativeMail\\Modules\\Contacts\\Handlers\\WpFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/WpFormsPluginHandler.php',
 
108
  'CreativeMail\\Modules\\Contacts\\Models\\ContactAddressModel' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactAddressModel.php',
109
  'CreativeMail\\Modules\\Contacts\\Models\\ContactFormSevenSubmission' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactFormSevenSubmission.php',
110
  'CreativeMail\\Modules\\Contacts\\Models\\ContactModel' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactModel.php',
111
  'CreativeMail\\Modules\\Contacts\\Models\\OptActionBy' => __DIR__ . '/../..' . '/src/modules/contacts/models/OptActionBy.php',
 
112
  'CreativeMail\\Modules\\Contacts\\Services\\ContactsSyncService' => __DIR__ . '/../..' . '/src/modules/contacts/Services/ContactsSyncService.php',
113
  'CreativeMail\\Modules\\DashboardWidgetModule' => __DIR__ . '/../..' . '/src/modules/DashboardWidgetModule.php',
114
  'CreativeMail\\Modules\\FeedbackNoticeModule' => __DIR__ . '/../..' . '/src/modules/FeedbackNoticeModule.php',
115
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCInformationModel' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCInformationModel.php',
116
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCProductModel' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCProductModel.php',
117
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCStoreInformation' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCStoreInformation.php',
 
 
118
  'Defuse\\Crypto\\Core' => __DIR__ . '/..' . '/defuse/php-encryption/src/Core.php',
119
  'Defuse\\Crypto\\Crypto' => __DIR__ . '/..' . '/defuse/php-encryption/src/Crypto.php',
120
  'Defuse\\Crypto\\DerivedKeys' => __DIR__ . '/..' . '/defuse/php-encryption/src/DerivedKeys.php',
@@ -151,10 +157,10 @@ class ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b
151
  public static function getInitializer(ClassLoader $loader)
152
  {
153
  return \Closure::bind(function () use ($loader) {
154
- $loader->prefixLengthsPsr4 = ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b::$prefixLengthsPsr4;
155
- $loader->prefixDirsPsr4 = ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b::$prefixDirsPsr4;
156
- $loader->prefixesPsr0 = ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b::$prefixesPsr0;
157
- $loader->classMap = ComposerStaticInita94ac5d1b50913d18d3aa28a2e5a3c7b::$classMap;
158
 
159
  }, null, ClassLoader::class);
160
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitf6dc660a62048f16678a088814efc407
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'F' =>
81
  'CreativeMail\\Helpers\\GuidHelper' => __DIR__ . '/../..' . '/src/helpers/GuidHelper.php',
82
  'CreativeMail\\Helpers\\OptionsHelper' => __DIR__ . '/../..' . '/src/helpers/OptionsHelper.php',
83
  'CreativeMail\\Helpers\\SsoHelper' => __DIR__ . '/../..' . '/src/helpers/SsoHelper.php',
84
+ 'CreativeMail\\Helpers\\ValidationHelper' => __DIR__ . '/../..' . '/src/helpers/ValidationHelper.php',
85
  'CreativeMail\\Integrations\\Integration' => __DIR__ . '/../..' . '/src/integrations/Integration.php',
86
  'CreativeMail\\Managers\\AdminManager' => __DIR__ . '/../..' . '/src/managers/AdminManager.php',
87
  'CreativeMail\\Managers\\ApiManager' => __DIR__ . '/../..' . '/src/managers/ApiManager.php',
97
  'CreativeMail\\Modules\\Blog\\Models\\BlogInformation' => __DIR__ . '/../..' . '/src/modules/blog/models/BlogInformation.php',
98
  'CreativeMail\\Modules\\Blog\\Models\\BlogPost' => __DIR__ . '/../..' . '/src/modules/blog/models/BlogPost.php',
99
  'CreativeMail\\Modules\\Contacts\\Handlers\\BaseContactFormPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/BaseContactFormPluginHandler.php',
100
+ 'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
101
  'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
102
  'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
103
  'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
107
  'CreativeMail\\Modules\\Contacts\\Handlers\\NinjaFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/NinjaFormsPluginHandler.php',
108
  'CreativeMail\\Modules\\Contacts\\Handlers\\WooCommercePluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/WooCommercePluginHandler.php',
109
  'CreativeMail\\Modules\\Contacts\\Handlers\\WpFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/WpFormsPluginHandler.php',
110
+ 'CreativeMail\\Modules\\Contacts\\Managers\\ContactsSyncManager' => __DIR__ . '/../..' . '/src/modules/contacts/Managers/ContactsSyncManager.php',
111
  'CreativeMail\\Modules\\Contacts\\Models\\ContactAddressModel' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactAddressModel.php',
112
  'CreativeMail\\Modules\\Contacts\\Models\\ContactFormSevenSubmission' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactFormSevenSubmission.php',
113
  'CreativeMail\\Modules\\Contacts\\Models\\ContactModel' => __DIR__ . '/../..' . '/src/modules/contacts/models/ContactModel.php',
114
  'CreativeMail\\Modules\\Contacts\\Models\\OptActionBy' => __DIR__ . '/../..' . '/src/modules/contacts/models/OptActionBy.php',
115
+ 'CreativeMail\\Modules\\Contacts\\Processors\\ContactsSyncBackgroundProcessor' => __DIR__ . '/../..' . '/src/modules/contacts/Processes/ContactsSyncBackgroundProcessor.php',
116
  'CreativeMail\\Modules\\Contacts\\Services\\ContactsSyncService' => __DIR__ . '/../..' . '/src/modules/contacts/Services/ContactsSyncService.php',
117
  'CreativeMail\\Modules\\DashboardWidgetModule' => __DIR__ . '/../..' . '/src/modules/DashboardWidgetModule.php',
118
  'CreativeMail\\Modules\\FeedbackNoticeModule' => __DIR__ . '/../..' . '/src/modules/FeedbackNoticeModule.php',
119
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCInformationModel' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCInformationModel.php',
120
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCProductModel' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCProductModel.php',
121
  'CreativeMail\\Modules\\WooCommerce\\Models\\WCStoreInformation' => __DIR__ . '/../..' . '/src/modules/woocommerce/models/WCStoreInformation.php',
122
+ 'CreativeMail\\Modules\\contacts\\Exceptions\\InvalidContactSyncBackgroundRequestException' => __DIR__ . '/../..' . '/src/modules/contacts/Exceptions/InvalidContactSyncBackgroundRequestException.php',
123
+ 'CreativeMail\\Modules\\contacts\\Exceptions\\InvalidHandlerContactSyncRequestException' => __DIR__ . '/../..' . '/src/modules/contacts/Exceptions/InvalidHandlerContactSyncRequestException.php',
124
  'Defuse\\Crypto\\Core' => __DIR__ . '/..' . '/defuse/php-encryption/src/Core.php',
125
  'Defuse\\Crypto\\Crypto' => __DIR__ . '/..' . '/defuse/php-encryption/src/Crypto.php',
126
  'Defuse\\Crypto\\DerivedKeys' => __DIR__ . '/..' . '/defuse/php-encryption/src/DerivedKeys.php',
157
  public static function getInitializer(ClassLoader $loader)
158
  {
159
  return \Closure::bind(function () use ($loader) {
160
+ $loader->prefixLengthsPsr4 = ComposerStaticInitf6dc660a62048f16678a088814efc407::$prefixLengthsPsr4;
161
+ $loader->prefixDirsPsr4 = ComposerStaticInitf6dc660a62048f16678a088814efc407::$prefixDirsPsr4;
162
+ $loader->prefixesPsr0 = ComposerStaticInitf6dc660a62048f16678a088814efc407::$prefixesPsr0;
163
+ $loader->classMap = ComposerStaticInitf6dc660a62048f16678a088814efc407::$classMap;
164
 
165
  }, null, ClassLoader::class);
166
  }