SendinBlue Subscribe Form And WP SMTP - Version 3.1.7

Version Description

Improvements

  • Improved technical performance of the plugin
Download this release

Release Info

Developer neeraj_slit
Plugin Icon 128x128 SendinBlue Subscribe Form And WP SMTP
Version 3.1.7
Comparing to
See all releases

Code changes from version 3.1.6 to 3.1.7

Files changed (4) hide show
  1. inc/SendinblueApiClient.php +20 -11
  2. page/page-home.php +42 -2
  3. readme.txt +5 -0
  4. sendinblue.php +5 -2
inc/SendinblueApiClient.php CHANGED
@@ -14,7 +14,7 @@ class SendinblueApiClient
14
  const RESPONSE_CODE_CREATED = 201;
15
  const RESPONSE_CODE_ACCEPTED = 202;
16
  const RESPONSE_CODE_UNAUTHORIZED = 401;
17
- const PLUGIN_VERSION = '3.1.6';
18
 
19
  private $apiKey;
20
  private $lastResponseCode;
@@ -161,6 +161,24 @@ class SendinblueApiClient
161
  return $this->put("/contacts/" . $email, $data);
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  /**
165
  * @param $data
166
  * @return mixed
@@ -248,15 +266,6 @@ class SendinblueApiClient
248
  return $this->post('/contacts/import', $data);
249
  }
250
 
251
- /**
252
- * @param $data
253
- * @return mixed
254
- */
255
- public function setPartner($data)
256
- {
257
- return $this->post('/account/partner',$data);
258
- }
259
-
260
  /**
261
  * @param $endpoint
262
  * @param array $parameters
@@ -326,7 +335,7 @@ class SendinblueApiClient
326
  }
327
  if(is_array($body)) {
328
  foreach($body as $key => $val) {
329
- if(empty($val)) {
330
  unset($body[$key]);
331
  }
332
  }
14
  const RESPONSE_CODE_CREATED = 201;
15
  const RESPONSE_CODE_ACCEPTED = 202;
16
  const RESPONSE_CODE_UNAUTHORIZED = 401;
17
+ const PLUGIN_VERSION = '3.1.7';
18
 
19
  private $apiKey;
20
  private $lastResponseCode;
161
  return $this->put("/contacts/" . $email, $data);
162
  }
163
 
164
+ /**
165
+ * @param $data
166
+ * @return mixed
167
+ */
168
+ public function createInstallationInfo($data)
169
+ {
170
+ return $this->post("/account/partner/information", $data);
171
+ }
172
+
173
+ /**
174
+ * @param $installationId ,$data
175
+ * @return mixed
176
+ */
177
+ public function updateInstallationInfo($installationId, $data)
178
+ {
179
+ return $this->put("/account/partner/information/" . $installationId, $data);
180
+ }
181
+
182
  /**
183
  * @param $data
184
  * @return mixed
266
  return $this->post('/contacts/import', $data);
267
  }
268
 
 
 
 
 
 
 
 
 
 
269
  /**
270
  * @param $endpoint
271
  * @param array $parameters
335
  }
336
  if(is_array($body)) {
337
  foreach($body as $key => $val) {
338
+ if(empty($val) && $val!==false && $val!==0) {
339
  unset($body[$key]);
340
  }
341
  }
page/page-home.php CHANGED
@@ -568,8 +568,7 @@ if ( ! class_exists( 'SIB_Page_Home' ) ) {
568
  $apiClient = new SendinblueApiClient();
569
  $response = $apiClient->getAccount();
570
  if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK ) {
571
- $data["partnerName"] = "WORDPRESS";
572
- $apiClient->setPartner($data);
573
  // create tables for users and forms.
574
  SIB_Model_Users::createTable();
575
  SIB_Forms::createTable(); // create default form also
@@ -761,6 +760,7 @@ if ( ! class_exists( 'SIB_Page_Home' ) ) {
761
 
762
  /** Logout process */
763
  function logout() {
 
764
  $setting = array();
765
  update_option( SIB_Manager::MAIN_OPTION_NAME, $setting );
766
  delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
@@ -784,6 +784,46 @@ if ( ! class_exists( 'SIB_Page_Home' ) ) {
784
  exit();
785
  }
786
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
787
  }
788
 
789
  }
568
  $apiClient = new SendinblueApiClient();
569
  $response = $apiClient->getAccount();
570
  if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK ) {
571
+ self::processInstallationInfo("login");
 
572
  // create tables for users and forms.
573
  SIB_Model_Users::createTable();
574
  SIB_Forms::createTable(); // create default form also
760
 
761
  /** Logout process */
762
  function logout() {
763
+ self::processInstallationInfo("logout");
764
  $setting = array();
765
  update_option( SIB_Manager::MAIN_OPTION_NAME, $setting );
766
  delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
784
  exit();
785
  }
786
 
787
+ public static function processInstallationInfo($action)
788
+ {
789
+ global $wp_version;
790
+
791
+ if($action == "login")
792
+ {
793
+ $apiClient = new SendinblueApiClient();
794
+
795
+ $params["partnerName"] = "WORDPRESS";
796
+ $params["active"] = true;
797
+ $params["plugin_version"] = SendinblueApiClient::PLUGIN_VERSION;
798
+ if(!empty($wp_version))
799
+ {
800
+ $params["shop_version"] = $wp_version;
801
+ }
802
+ $params["shop_url"] = get_home_url();
803
+ $params["created_at"] = gmdate("Y-m-d\TH:i:s.v\Z");
804
+ $params["activated_at"] = gmdate("Y-m-d\TH:i:s.v\Z");
805
+ $params["type"] = "sib";
806
+ $response = $apiClient->createInstallationInfo($params);
807
+ if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_CREATED )
808
+ {
809
+ if(!empty($response["id"]))
810
+ {
811
+ update_option(SIB_Manager::INSTALLATION_ID, $response["id"]);
812
+ }
813
+ }
814
+ }
815
+ elseif($action == "logout")
816
+ {
817
+ $installationId = get_option( SIB_Manager::INSTALLATION_ID );
818
+ if(!empty($installationId))
819
+ {
820
+ $apiClient = new SendinblueApiClient();
821
+ $params["active"] = false;
822
+ $params["deactivated_at"] = gmdate("Y-m-d\TH:i:s.v\Z");
823
+ $apiClient->updateInstallationInfo($installationId, $params);
824
+ }
825
+ }
826
+ }
827
  }
828
 
829
  }
readme.txt CHANGED
@@ -115,6 +115,11 @@ In order to create a signup form, you need to:
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
118
  = 3.1.6 =
119
  **Bug fixes**
120
 
115
 
116
  == Changelog ==
117
 
118
+ = 3.1.7 =
119
+ **Improvements**
120
+
121
+ * Improved technical performance of the plugin
122
+
123
  = 3.1.6 =
124
  **Bug fixes**
125
 
sendinblue.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Newsletter, SMTP, Email marketing and Subscribe forms by Sendinblue
4
  * Plugin URI: https://www.sendinblue.com/?r=wporg
5
  * Description: Manage your contact lists, subscription forms and all email and marketing-related topics from your wp panel, within one single plugin
6
- * Version: 3.1.6
7
  * Author: Sendinblue
8
  * Author URI: https://www.sendinblue.com/?r=wporg
9
  * License: GPLv2 or later
@@ -81,7 +81,10 @@ if ( ! class_exists( 'SIB_Manager' ) ) {
81
 
82
  const API_KEY_V3_OPTION_NAME = 'sib_api_key_v3';
83
 
84
- const RECAPTCHA_API_TEMPLATE = 'https://www.google.com/recaptcha/api/siteverify?%s';
 
 
 
85
 
86
  /**
87
  * API key
3
  * Plugin Name: Newsletter, SMTP, Email marketing and Subscribe forms by Sendinblue
4
  * Plugin URI: https://www.sendinblue.com/?r=wporg
5
  * Description: Manage your contact lists, subscription forms and all email and marketing-related topics from your wp panel, within one single plugin
6
+ * Version: 3.1.7
7
  * Author: Sendinblue
8
  * Author URI: https://www.sendinblue.com/?r=wporg
9
  * License: GPLv2 or later
81
 
82
  const API_KEY_V3_OPTION_NAME = 'sib_api_key_v3';
83
 
84
+ const RECAPTCHA_API_TEMPLATE = 'https://www.google.com/recaptcha/api/siteverify?%s';
85
+
86
+ /** Installation id option name */
87
+ const INSTALLATION_ID = 'sib_installation_id';
88
 
89
  /**
90
  * API key