Version Description
Bug fixes: * Multi-list selection * Recipients boolean attributes
Download this release
Release Info
Developer | neeraj_slit |
Plugin | SendinBlue Subscribe Form And WP SMTP |
Version | 3.0.5 |
Comparing to | |
See all releases |
Code changes from version 3.0.4 to 3.0.5
- inc/SendinblueApiClient.php +30 -23
- inc/sib-api-manager.php +46 -42
- page/page-form.php +1 -0
- page/page-home.php +1 -1
- page/page-statistics.php +6 -5
- readme.txt +6 -1
- sendinblue.php +27 -16
inc/SendinblueApiClient.php
CHANGED
@@ -42,12 +42,12 @@ class SendinblueApiClient
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* @param $type,$name,$data
|
46 |
* @return mixed
|
47 |
*/
|
48 |
-
public function createAttribute($type
|
49 |
{
|
50 |
-
return $this->post("/contacts/attributes/"
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -56,7 +56,7 @@ class SendinblueApiClient
|
|
56 |
*/
|
57 |
public function getEmailTemplate($id)
|
58 |
{
|
59 |
-
return $this->get("/smtp/templates/"
|
60 |
}
|
61 |
|
62 |
/**
|
@@ -66,7 +66,7 @@ class SendinblueApiClient
|
|
66 |
*/
|
67 |
public function getAllCampaignsByType($type = self::CAMPAIGN_TYPE_EMAIL, $data = [])
|
68 |
{
|
69 |
-
$campaigns =[];
|
70 |
|
71 |
if (!isset($data['offset'])) {
|
72 |
$data['offset'] = 0;
|
@@ -94,7 +94,7 @@ class SendinblueApiClient
|
|
94 |
*/
|
95 |
public function getEmailCampaigns($data)
|
96 |
{
|
97 |
-
return $this->get("/emailCampaigns"
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -103,7 +103,7 @@ class SendinblueApiClient
|
|
103 |
*/
|
104 |
public function getSmsCampaigns($data)
|
105 |
{
|
106 |
-
return $this->get("/smsCampaigns"
|
107 |
}
|
108 |
|
109 |
/**
|
@@ -112,7 +112,7 @@ class SendinblueApiClient
|
|
112 |
*/
|
113 |
public function getEmailTemplates($data)
|
114 |
{
|
115 |
-
return $this->get("/smtp/templates"
|
116 |
}
|
117 |
|
118 |
/**
|
@@ -121,16 +121,16 @@ class SendinblueApiClient
|
|
121 |
*/
|
122 |
public function sendEmail($data)
|
123 |
{
|
124 |
-
return $this->post("/smtp/email"
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
-
* @param $id,$data
|
129 |
* @return mixed
|
130 |
*/
|
131 |
-
public function sendTransactionalTemplate($id
|
132 |
{
|
133 |
-
return $this->post("/smtp/templates/"
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -139,7 +139,7 @@ class SendinblueApiClient
|
|
139 |
*/
|
140 |
public function getUser($email)
|
141 |
{
|
142 |
-
return $this->get("/contacts/". urlencode($email));
|
143 |
}
|
144 |
|
145 |
/**
|
@@ -148,7 +148,7 @@ class SendinblueApiClient
|
|
148 |
*/
|
149 |
public function createUser($data)
|
150 |
{
|
151 |
-
return $this->post("/contacts"
|
152 |
}
|
153 |
|
154 |
/**
|
@@ -160,12 +160,12 @@ class SendinblueApiClient
|
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
-
* @param $email,$data
|
164 |
* @return mixed
|
165 |
*/
|
166 |
public function updateUser($email, $data)
|
167 |
{
|
168 |
-
return $this->put("/contacts/"
|
169 |
}
|
170 |
|
171 |
/**
|
@@ -174,7 +174,7 @@ class SendinblueApiClient
|
|
174 |
*/
|
175 |
public function createList($data)
|
176 |
{
|
177 |
-
return $this->post("/contacts/lists"
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -183,7 +183,7 @@ class SendinblueApiClient
|
|
183 |
*/
|
184 |
public function getLists($data)
|
185 |
{
|
186 |
-
return $this->get("/contacts/lists"
|
187 |
}
|
188 |
|
189 |
/**
|
@@ -198,12 +198,11 @@ class SendinblueApiClient
|
|
198 |
do {
|
199 |
$list_data = $this->getLists(array('limit' => $limit, 'offset' => $offset));
|
200 |
if (isset($list_data["lists"]) && is_array($list_data["lists"])) {
|
201 |
-
$lists["lists"] = array_merge($lists["lists"]
|
202 |
$offset += 50;
|
203 |
$lists["count"] = $list_data["count"];
|
204 |
}
|
205 |
-
}
|
206 |
-
while(!empty($lists['lists']) && count($lists["lists"]) < $list_data["count"]);
|
207 |
|
208 |
return $lists;
|
209 |
}
|
@@ -277,9 +276,12 @@ class SendinblueApiClient
|
|
277 |
|
278 |
if ($method != self::HTTP_METHOD_GET && $method != self::HTTP_METHOD_DELETE) {
|
279 |
if (isset($body['listIds'])) {
|
280 |
-
$body['listIds'] =
|
|
|
|
|
|
|
281 |
}
|
282 |
-
|
283 |
}
|
284 |
|
285 |
$response = wp_remote_request($url, $args);
|
@@ -297,6 +299,11 @@ class SendinblueApiClient
|
|
297 |
return $data;
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
300 |
/**
|
301 |
* @return int
|
302 |
*/
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
+
* @param $type ,$name,$data
|
46 |
* @return mixed
|
47 |
*/
|
48 |
+
public function createAttribute($type, $name, $data)
|
49 |
{
|
50 |
+
return $this->post("/contacts/attributes/" . $type . "/" . $name, $data);
|
51 |
}
|
52 |
|
53 |
/**
|
56 |
*/
|
57 |
public function getEmailTemplate($id)
|
58 |
{
|
59 |
+
return $this->get("/smtp/templates/" . $id);
|
60 |
}
|
61 |
|
62 |
/**
|
66 |
*/
|
67 |
public function getAllCampaignsByType($type = self::CAMPAIGN_TYPE_EMAIL, $data = [])
|
68 |
{
|
69 |
+
$campaigns = [];
|
70 |
|
71 |
if (!isset($data['offset'])) {
|
72 |
$data['offset'] = 0;
|
94 |
*/
|
95 |
public function getEmailCampaigns($data)
|
96 |
{
|
97 |
+
return $this->get("/emailCampaigns", $data);
|
98 |
}
|
99 |
|
100 |
/**
|
103 |
*/
|
104 |
public function getSmsCampaigns($data)
|
105 |
{
|
106 |
+
return $this->get("/smsCampaigns", $data);
|
107 |
}
|
108 |
|
109 |
/**
|
112 |
*/
|
113 |
public function getEmailTemplates($data)
|
114 |
{
|
115 |
+
return $this->get("/smtp/templates", $data);
|
116 |
}
|
117 |
|
118 |
/**
|
121 |
*/
|
122 |
public function sendEmail($data)
|
123 |
{
|
124 |
+
return $this->post("/smtp/email", $data);
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* @param $id ,$data
|
129 |
* @return mixed
|
130 |
*/
|
131 |
+
public function sendTransactionalTemplate($id, $data)
|
132 |
{
|
133 |
+
return $this->post("/smtp/templates/" . $id . "/send", $data);
|
134 |
}
|
135 |
|
136 |
/**
|
139 |
*/
|
140 |
public function getUser($email)
|
141 |
{
|
142 |
+
return $this->get("/contacts/" . urlencode($email));
|
143 |
}
|
144 |
|
145 |
/**
|
148 |
*/
|
149 |
public function createUser($data)
|
150 |
{
|
151 |
+
return $this->post("/contacts", $data);
|
152 |
}
|
153 |
|
154 |
/**
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
+
* @param $email ,$data
|
164 |
* @return mixed
|
165 |
*/
|
166 |
public function updateUser($email, $data)
|
167 |
{
|
168 |
+
return $this->put("/contacts/" . $email, $data);
|
169 |
}
|
170 |
|
171 |
/**
|
174 |
*/
|
175 |
public function createList($data)
|
176 |
{
|
177 |
+
return $this->post("/contacts/lists", $data);
|
178 |
}
|
179 |
|
180 |
/**
|
183 |
*/
|
184 |
public function getLists($data)
|
185 |
{
|
186 |
+
return $this->get("/contacts/lists", $data);
|
187 |
}
|
188 |
|
189 |
/**
|
198 |
do {
|
199 |
$list_data = $this->getLists(array('limit' => $limit, 'offset' => $offset));
|
200 |
if (isset($list_data["lists"]) && is_array($list_data["lists"])) {
|
201 |
+
$lists["lists"] = array_merge($lists["lists"], $list_data["lists"]);
|
202 |
$offset += 50;
|
203 |
$lists["count"] = $list_data["count"];
|
204 |
}
|
205 |
+
} while (!empty($lists['lists']) && count($lists["lists"]) < $list_data["count"]);
|
|
|
206 |
|
207 |
return $lists;
|
208 |
}
|
276 |
|
277 |
if ($method != self::HTTP_METHOD_GET && $method != self::HTTP_METHOD_DELETE) {
|
278 |
if (isset($body['listIds'])) {
|
279 |
+
$body['listIds'] = $this->getListsIds($body['listIds']);
|
280 |
+
}
|
281 |
+
if (isset($body['unlinkListIds'])) {
|
282 |
+
$body['unlinkListIds'] = $this->getListsIds($body['unlinkListIds']);
|
283 |
}
|
284 |
+
$args['body'] = wp_json_encode($body);
|
285 |
}
|
286 |
|
287 |
$response = wp_remote_request($url, $args);
|
299 |
return $data;
|
300 |
}
|
301 |
|
302 |
+
private function getListsIds($listIds)
|
303 |
+
{
|
304 |
+
return array_unique(array_values(array_map('intval', (array)$listIds)));
|
305 |
+
}
|
306 |
+
|
307 |
/**
|
308 |
* @return int
|
309 |
*/
|
inc/sib-api-manager.php
CHANGED
@@ -278,16 +278,16 @@ if ( ! class_exists( 'SIB_API_Manager' ) ) {
|
|
278 |
return $result;
|
279 |
}
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
|
292 |
$isDopted = false;
|
293 |
|
@@ -299,11 +299,6 @@ if ( ! class_exists( 'SIB_API_Manager' ) ) {
|
|
299 |
$list_id = array( $temp_dopt_list );
|
300 |
}
|
301 |
|
302 |
-
$data = array(
|
303 |
-
'email' => $email,
|
304 |
-
);
|
305 |
-
$res = $mailin->getUser( $data["email"] );
|
306 |
-
|
307 |
// new user.
|
308 |
if ( isset($res['code']) && $res['code'] == 'document_not_found' ) {
|
309 |
$ret = array(
|
@@ -371,8 +366,10 @@ if ( ! class_exists( 'SIB_API_Manager' ) ) {
|
|
371 |
* @return string
|
372 |
*/
|
373 |
public static function create_subscriber( $type = 'simple', $email, $list_id, $info, $list_unlink = null ) {
|
|
|
|
|
374 |
|
375 |
-
$response = self::validation_email( $type, $email, $list_id );
|
376 |
$exist = '';
|
377 |
|
378 |
if ( 'already_exist' == $response['code'] ) {
|
@@ -388,34 +385,43 @@ if ( ! class_exists( 'SIB_API_Manager' ) ) {
|
|
388 |
}
|
389 |
}
|
390 |
}
|
|
|
391 |
$listid = $response['listid'];
|
392 |
-
if( $list_unlink != null )
|
393 |
-
{
|
394 |
$listid = array_diff( $listid, $list_unlink );
|
395 |
}
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
unset($info["email"]);
|
402 |
-
if(isset($info["internalUserHistory"]) && is_array($info["internalUserHistory"])) {
|
403 |
$info["internalUserHistory"][] = array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress");
|
404 |
-
|
405 |
$info["internalUserHistory"] = array(array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress"));
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
else
|
418 |
-
{
|
419 |
$info["internalUserHistory"] = array(array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress"));
|
420 |
$data = [
|
421 |
'email' => $email,
|
@@ -428,14 +434,12 @@ if ( ! class_exists( 'SIB_API_Manager' ) ) {
|
|
428 |
$created_user = $mailin->createUser( $data );
|
429 |
}
|
430 |
|
431 |
-
if('' != $exist)
|
432 |
-
{
|
433 |
$response['code'] = $exist;
|
434 |
-
}
|
435 |
-
else if(isset($created_user['id']))
|
436 |
-
{
|
437 |
$response['code'] = "success";
|
438 |
}
|
|
|
439 |
return $response['code'];
|
440 |
}
|
441 |
|
278 |
return $result;
|
279 |
}
|
280 |
|
281 |
+
/**
|
282 |
+
* Validation the email if it exist in contact list
|
283 |
+
*
|
284 |
+
* @param $res
|
285 |
+
* @param string $type - form type.
|
286 |
+
* @param string $email - email.
|
287 |
+
* @param array $list_id - list ids.
|
288 |
+
* @return array
|
289 |
+
*/
|
290 |
+
static function validation_email( $res, $type = 'simple', $email, $list_id ) {
|
291 |
|
292 |
$isDopted = false;
|
293 |
|
299 |
$list_id = array( $temp_dopt_list );
|
300 |
}
|
301 |
|
|
|
|
|
|
|
|
|
|
|
302 |
// new user.
|
303 |
if ( isset($res['code']) && $res['code'] == 'document_not_found' ) {
|
304 |
$ret = array(
|
366 |
* @return string
|
367 |
*/
|
368 |
public static function create_subscriber( $type = 'simple', $email, $list_id, $info, $list_unlink = null ) {
|
369 |
+
$mailin = new SendinblueApiClient();
|
370 |
+
$user = $mailin->getUser($email);
|
371 |
|
372 |
+
$response = self::validation_email( $user, $type, $email, $list_id );
|
373 |
$exist = '';
|
374 |
|
375 |
if ( 'already_exist' == $response['code'] ) {
|
385 |
}
|
386 |
}
|
387 |
}
|
388 |
+
|
389 |
$listid = $response['listid'];
|
390 |
+
if ( $list_unlink != null ) {
|
|
|
391 |
$listid = array_diff( $listid, $list_unlink );
|
392 |
}
|
393 |
|
394 |
+
$attributes = SIB_API_Manager::get_attributes();
|
395 |
+
if( !empty($attributes["attributes"]["normal_attributes"]) ) {
|
396 |
+
foreach ( $attributes["attributes"]["normal_attributes"] as $key => $value ) {
|
397 |
+
if( "boolean" == $value["type"] && array_key_exists($value["name"], $info) )
|
398 |
+
if( in_array($info[ $value["name"] ], array("true","True","TRUE",1)) ) {
|
399 |
+
$info[ $value["name"] ] = true;
|
400 |
+
}
|
401 |
+
else {
|
402 |
+
$info[ $value["name"] ] = false;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
if ($mailin->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK && isset($user['email'])) {
|
408 |
unset($info["email"]);
|
409 |
+
if (isset($info["internalUserHistory"]) && is_array($info["internalUserHistory"])) {
|
410 |
$info["internalUserHistory"][] = array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress");
|
411 |
+
} else {
|
412 |
$info["internalUserHistory"] = array(array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress"));
|
413 |
+
}
|
414 |
+
$data = [
|
415 |
+
'email' => $email,
|
416 |
+
'attributes' => $info,
|
417 |
+
'emailBlacklisted' => false,
|
418 |
+
'smsBlacklisted' => false,
|
419 |
+
'listIds' => $listid,
|
420 |
+
'unlinkListIds' => $list_unlink
|
421 |
+
];
|
422 |
+
$mailin->updateUser($email ,$data );
|
423 |
+
$exist = $mailin->getLastResponseCode() == 204 ? 'success' : '' ;
|
424 |
+
} else {
|
|
|
425 |
$info["internalUserHistory"] = array(array("action"=>"SUBSCRIBE_BY_PLUGIN", "id"=> 1, "name"=>"wordpress"));
|
426 |
$data = [
|
427 |
'email' => $email,
|
434 |
$created_user = $mailin->createUser( $data );
|
435 |
}
|
436 |
|
437 |
+
if ('' != $exist) {
|
|
|
438 |
$response['code'] = $exist;
|
439 |
+
} else if(isset($created_user['id'])) {
|
|
|
|
|
440 |
$response['code'] = "success";
|
441 |
}
|
442 |
+
|
443 |
return $response['code'];
|
444 |
}
|
445 |
|
page/page-form.php
CHANGED
@@ -59,6 +59,7 @@ if ( ! class_exists( 'SIB_Page_Form' ) ) {
|
|
59 |
* Init Process
|
60 |
*/
|
61 |
function Init() {
|
|
|
62 |
$this->forms = new SIB_Forms_List();
|
63 |
$this->forms->prepare_items();
|
64 |
}
|
59 |
* Init Process
|
60 |
*/
|
61 |
function Init() {
|
62 |
+
SIB_Manager::is_done_validation();
|
63 |
$this->forms = new SIB_Forms_List();
|
64 |
$this->forms->prepare_items();
|
65 |
}
|
page/page-home.php
CHANGED
@@ -88,7 +88,7 @@ if ( ! class_exists( 'SIB_Page_Home' ) ) {
|
|
88 |
<p id="sib-message-body"></p>
|
89 |
</div>
|
90 |
<?php
|
91 |
-
if ( SIB_Manager::is_done_validation()
|
92 |
$this->generate_main_content();
|
93 |
} else {
|
94 |
$this->generate_welcome_content();
|
88 |
<p id="sib-message-body"></p>
|
89 |
</div>
|
90 |
<?php
|
91 |
+
if ( SIB_Manager::is_done_validation(false)) {
|
92 |
$this->generate_main_content();
|
93 |
} else {
|
94 |
$this->generate_welcome_content();
|
page/page-statistics.php
CHANGED
@@ -49,6 +49,7 @@ if ( ! class_exists( 'SIB_Page_Statistics' ) ) {
|
|
49 |
* Init Process
|
50 |
*/
|
51 |
function Init() {
|
|
|
52 |
add_action( 'admin_notices', array( 'SIB_Manager', 'language_admin_notice' ) );
|
53 |
}
|
54 |
|
@@ -83,11 +84,11 @@ if ( ! class_exists( 'SIB_Page_Statistics' ) ) {
|
|
83 |
<div id="wrap1" class="box-border-box container-fluid">
|
84 |
<div id="main-content" class="row">
|
85 |
<?php
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
?>
|
92 |
</div>
|
93 |
</div>
|
49 |
* Init Process
|
50 |
*/
|
51 |
function Init() {
|
52 |
+
SIB_Manager::is_done_validation();
|
53 |
add_action( 'admin_notices', array( 'SIB_Manager', 'language_admin_notice' ) );
|
54 |
}
|
55 |
|
84 |
<div id="wrap1" class="box-border-box container-fluid">
|
85 |
<div id="main-content" class="row">
|
86 |
<?php
|
87 |
+
if ( SIB_Manager::is_api_key_set() ) {
|
88 |
+
$this->generate_main_page();
|
89 |
+
} else {
|
90 |
+
$this->generate_welcome_page();
|
91 |
+
}
|
92 |
?>
|
93 |
</div>
|
94 |
</div>
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Stable tag: trunk
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -112,6 +112,11 @@ In order to create a signup form, you need to:
|
|
112 |
2. Integrate the form in a sidebar using a widget from WP panel > Appearance > Widgets. The Sendinblue widget form should appear in your widgets list, you just to have to drag and drop the widget into the sidebar of your choice.
|
113 |
|
114 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
115 |
= 3.0.4 =
|
116 |
* Some Improvements
|
117 |
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
Manage your contact lists, subscription forms and all email and marketing-related topics from your wp panel, within one single plugin
|
11 |
|
12 |
== Description ==
|
13 |
|
112 |
2. Integrate the form in a sidebar using a widget from WP panel > Appearance > Widgets. The Sendinblue widget form should appear in your widgets list, you just to have to drag and drop the widget into the sidebar of your choice.
|
113 |
|
114 |
== Changelog ==
|
115 |
+
= 3.0.5 =
|
116 |
+
**Bug fixes:**
|
117 |
+
* Multi-list selection
|
118 |
+
* Recipients boolean attributes
|
119 |
+
|
120 |
= 3.0.4 =
|
121 |
* Some Improvements
|
122 |
|
sendinblue.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Sendinblue Subscribe Form And WP SMTP
|
4 |
* Plugin URI: https://www.sendinblue.com/?r=wporg
|
5 |
-
* Description:
|
6 |
-
* Version: 3.0.
|
7 |
* Author: Sendinblue
|
8 |
* Author URI: https://www.sendinblue.com/?r=wporg
|
9 |
* License: GPLv2 or later
|
@@ -437,28 +437,39 @@ if ( ! class_exists( 'SIB_Manager' ) ) {
|
|
437 |
SIB_API_Manager::remove_transients();
|
438 |
}
|
439 |
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
443 |
static function is_done_validation($redirect = true) {
|
444 |
-
|
445 |
$apiClient = new SendinblueApiClient();
|
446 |
-
$
|
447 |
-
if ( $apiClient->getLastResponseCode()
|
448 |
return true;
|
449 |
}
|
450 |
-
|
451 |
-
if ($redirect) {
|
452 |
-
delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
|
453 |
-
wp_safe_redirect(add_query_arg('page', SIB_Page_Home::PAGE_ID, admin_url('admin.php')));
|
454 |
-
}
|
455 |
}
|
456 |
|
|
|
|
|
|
|
|
|
457 |
return false;
|
458 |
}
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
static function is_api_key_set() {
|
461 |
-
|
|
|
462 |
}
|
463 |
|
464 |
/**
|
@@ -677,8 +688,8 @@ if ( ! class_exists( 'SIB_Manager' ) ) {
|
|
677 |
if (empty($listID)) {
|
678 |
$listID = array();
|
679 |
}
|
680 |
-
$interestingLists = isset( $_POST['interestingLists']) ?
|
681 |
-
$expectedLists = isset( $_POST['listIDs'] ) ?
|
682 |
if ( empty($interestingLists) )
|
683 |
{
|
684 |
$unlinkedLists = [];
|
2 |
/**
|
3 |
* Plugin Name: Sendinblue Subscribe Form And WP SMTP
|
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.0.5
|
7 |
* Author: Sendinblue
|
8 |
* Author URI: https://www.sendinblue.com/?r=wporg
|
9 |
* License: GPLv2 or later
|
437 |
SIB_API_Manager::remove_transients();
|
438 |
}
|
439 |
|
440 |
+
/**
|
441 |
+
* Check if plugin is logged in.
|
442 |
+
*
|
443 |
+
* @param bool $redirect
|
444 |
+
* @return bool
|
445 |
+
*/
|
446 |
static function is_done_validation($redirect = true) {
|
447 |
+
if (self::is_api_key_set()) {
|
448 |
$apiClient = new SendinblueApiClient();
|
449 |
+
$apiClient->getAccount();
|
450 |
+
if ( SendinblueApiClient::RESPONSE_CODE_OK === $apiClient->getLastResponseCode() ) {
|
451 |
return true;
|
452 |
}
|
453 |
+
delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
|
|
|
|
|
|
|
|
|
454 |
}
|
455 |
|
456 |
+
if ($redirect) {
|
457 |
+
self::redirect_to_sib_plugin_homepage();
|
458 |
+
}
|
459 |
+
|
460 |
return false;
|
461 |
}
|
462 |
|
463 |
+
static function redirect_to_sib_plugin_homepage() {
|
464 |
+
wp_safe_redirect(add_query_arg('page', SIB_Page_Home::PAGE_ID, admin_url('admin.php')));
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* @return bool
|
469 |
+
*/
|
470 |
static function is_api_key_set() {
|
471 |
+
$api_key = get_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
|
472 |
+
return !empty($api_key);
|
473 |
}
|
474 |
|
475 |
/**
|
688 |
if (empty($listID)) {
|
689 |
$listID = array();
|
690 |
}
|
691 |
+
$interestingLists = isset( $_POST['interestingLists']) ? array_map( 'esc_attr', $_POST['interestingLists'] ) : array();
|
692 |
+
$expectedLists = isset( $_POST['listIDs'] ) ? array_map( 'esc_attr', $_POST['listIDs'] ) : array();
|
693 |
if ( empty($interestingLists) )
|
694 |
{
|
695 |
$unlinkedLists = [];
|