PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.1.67
Brevo – Email, SMS, Web Push, Chat, and more. v3.1.67
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / page / page-home.php
mailin / page Last commit date
index.php 11 years ago page-form.php 2 years ago page-home.php 2 years ago page-scenarios.php 3 years ago page-statistics.php 3 years ago
page-home.php
855 lines
1 <?php
2 /**
3 * Admin page : dashboard
4 *
5 * @package SIB_Page_Home
6 */
7
8 if ( ! class_exists( 'SIB_Page_Home' ) ) {
9 /**
10 * Page class that handles backend page <i>dashboard ( for admin )</i> with form generation and processing
11 *
12 * @package SIB_Page_Home
13 */
14 class SIB_Page_Home {
15
16 /**
17 * Page slug
18 */
19 const PAGE_ID = 'sib_page_home';
20
21 /**
22 * Page hook
23 *
24 * @var string
25 */
26 protected $page_hook;
27
28 /**
29 * Page tabs
30 *
31 * @var mixed
32 */
33 protected $tabs;
34
35 /**
36 * Constructs new page object and adds entry to WordPress admin menu
37 */
38 function __construct() {
39 add_menu_page( __( 'Brevo', 'mailin' ), __( 'Brevo', 'mailin' ), 'manage_options', self::PAGE_ID, array( &$this, 'generate' ), SIB_Manager::$plugin_url . '/img/favicon.ico' );
40 $this->page_hook = add_submenu_page( self::PAGE_ID, __( 'Home', 'mailin' ), __( 'Home', 'mailin' ), 'manage_options', self::PAGE_ID, array( &$this, 'generate' ) );
41 add_action( 'load-' . $this->page_hook, array( &$this, 'init' ) );
42 add_action( 'admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ) );
43 add_action( 'admin_print_styles-' . $this->page_hook, array( $this, 'enqueue_styles' ) );
44 }
45
46 /**
47 * Init Process
48 */
49 function Init() {
50 if ( ( isset( $_GET['sib_action'] ) ) && ( 'logout' === sanitize_text_field($_GET['sib_action'] )) ) {
51 $this->logout();
52 }
53 }
54
55 /**
56 * Enqueue scripts of plugin
57 */
58 function enqueue_scripts() {
59 wp_enqueue_script( 'sib-admin-js' );
60 wp_enqueue_script( 'sib-bootstrap-js' );
61 wp_enqueue_script( 'sib-chosen-js' );
62 wp_localize_script(
63 'sib-admin-js', 'ajax_sib_object',
64 array(
65 'ajax_url' => admin_url( 'admin-ajax.php' ),
66 'ajax_nonce' => wp_create_nonce( 'ajax_sib_admin_nonce' ),
67 )
68 );
69 }
70
71 /**
72 * Enqueue style sheets of plugin
73 */
74 function enqueue_styles() {
75 wp_enqueue_style( 'sib-admin-css' );
76 wp_enqueue_style( 'sib-bootstrap-css' );
77 wp_enqueue_style( 'sib-chosen-css' );
78 wp_enqueue_style( 'sib-fontawesome-css' );
79 }
80
81 /** Generate page script */
82 function generate() {
83 ?>
84 <div id="wrap" class="wrap box-border-box container-fluid">
85 <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" viewBox="0 0 32 32">
86 <circle cx="16" cy="16" r="16" fill="#0B996E"/>
87 <path fill="#fff" d="M21.002 14.54c.99-.97 1.453-2.089 1.453-3.45 0-2.814-2.07-4.69-5.19-4.69H9.6v20h6.18c4.698 0 8.22-2.874 8.22-6.686 0-2.089-1.081-3.964-2.998-5.174Zm-8.62-5.538h4.573c1.545 0 2.565.877 2.565 2.208 0 1.513-1.329 2.663-4.048 3.54-1.854.574-2.688 1.059-2.997 1.634l-.094.001V9.002Zm3.151 14.796h-3.152v-3.085c0-1.362 1.175-2.693 2.813-3.208 1.453-.484 2.657-.969 3.677-1.482 1.36.787 2.194 2.148 2.194 3.57 0 2.42-2.35 4.205-5.532 4.205Z"/>
88 </svg>
89 <svg xmlns="http://www.w3.org/2000/svg" width="80" height="25" fill="currentColor" viewBox="0 0 90 31">
90 <path fill="#0B996E" d="M73.825 19.012c0-4.037 2.55-6.877 6.175-6.877 3.626 0 6.216 2.838 6.216 6.877s-2.59 6.715-6.216 6.715c-3.626 0-6.175-2.799-6.175-6.715Zm-3.785 0c0 5.957 4.144 10.155 9.96 10.155 5.816 0 10-4.198 10-10.155 0-5.957-4.143-10.314-10-10.314s-9.96 4.278-9.96 10.314ZM50.717 8.937l7.81 19.989h3.665l7.81-19.989h-3.945L60.399 24.37h-.08L54.662 8.937h-3.945Zm-15.18 9.354c.239-3.678 2.67-6.156 5.977-6.156 2.867 0 5.02 1.84 5.338 4.598h-6.614c-2.35 0-3.626.28-4.58 1.56h-.12v-.002Zm-3.784.6c0 5.957 4.183 10.274 9.96 10.274 3.904 0 7.33-1.998 8.804-5.158l-3.187-1.6c-1.115 2.08-3.267 3.319-5.618 3.319-2.83 0-5.379-2.16-5.379-4.238 0-1.08.718-1.56 1.753-1.56h12.63v-1.079c0-5.997-3.825-10.155-9.323-10.155-5.497 0-9.641 4.279-9.641 10.195M20.916 28.924h3.586V16.653c0-2.639 1.632-4.518 3.905-4.518.956 0 1.951.32 2.43.758.36-.96.917-1.918 1.753-2.878-.957-.799-2.59-1.32-4.184-1.32-4.382 0-7.49 3.279-7.49 7.956v12.274-.001Zm-17.33-13.23V5.937h5.896c1.992 0 3.307 1.16 3.307 2.919 0 1.998-1.713 3.518-5.218 4.677-2.39.759-3.466 1.399-3.865 2.16h-.12Zm0 9.794v-4.077c0-1.799 1.514-3.558 3.626-4.238 1.873-.64 3.425-1.28 4.74-1.958 1.754 1.04 2.829 2.837 2.829 4.717 0 3.198-3.028 5.556-7.132 5.556H3.586ZM0 28.926h7.968c6.057 0 10.597-3.798 10.597-8.835 0-2.759-1.393-5.237-3.864-6.836 1.275-1.28 1.873-2.76 1.873-4.559 0-3.717-2.67-6.196-6.693-6.196H0v26.426Z"/>
91 </svg>
92
93 <div class="row">
94 <div id="wrap-left" class="box-border-box col-md-9">
95 <div id="sib-message-box" class="row alert alert-success" style="display: none;">
96 <p id="sib-message-body"></p>
97 </div>
98 <?php
99 if ( SIB_Manager::is_done_validation(false)) {
100 $this->generate_main_content();
101 } else {
102 $this->generate_welcome_content();
103 }
104 ?>
105 </div>
106 <div id="wrap-right-side" class="box-border-box col-md-3">
107 <?php
108 self::generate_side_bar();
109 ?>
110 </div>
111 </div>
112 </div>
113 <?php
114 }
115
116 /** Generate welcome page before validation */
117 function generate_welcome_content() {
118 ?>
119
120 <div id="main-content" class="sib-content">
121 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
122 <div class="card sib-small-content">
123 <div class="card-header">
124 <span style="color: #777777;"><?php esc_attr_e( 'Step', 'mailin' ); ?> 1&nbsp;|&nbsp;</span><strong><?php esc_attr_e( 'Create a Brevo Account', 'mailin' ); ?></strong>
125 </div>
126 <div class="card-body">
127 <div class="col-md-9">
128 <p><?php esc_attr_e( 'By creating a free Brevo account, you will be able to send confirmation emails and:', 'mailin' ); ?></p>
129 <ul class="sib-home-feature">
130 <li><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Collect your contacts and upload your lists', 'mailin' ); ?></li>
131 <li><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Use Brevo SMTP to send your transactional emails', 'mailin' ); ?></li>
132 <li class="home-read-more-content"><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Email marketing builders', 'mailin' ); ?></li>
133 <li class="home-read-more-content"><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Create and schedule your email marketing campaigns', 'mailin' ); ?></li>
134 <li class="home-read-more-content"><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Try all of', 'mailin' ); ?>&nbsp;<a href="https://www.brevo.com/features/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><?php esc_attr_e( 'Brevo\'s features', 'mailin' ); ?></a></li>
135 </ul>
136 <a href="https://www.brevo.com/users/signup?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" class="btn btn-success" target="_blank" rel="noopener" style="margin-top: 10px;"><?php esc_attr_e( 'Create an account', 'mailin' ); ?></a>
137 </div>
138 </div>
139 </div>
140 <div class="card sib-small-content">
141 <div class="card-header">
142 <span style="color: #777777;"><?php esc_attr_e( 'Step', 'mailin' ); ?> 2&nbsp;|&nbsp;</span><strong><?php esc_attr_e( 'Activate your account with your API key v3', 'mailin' ); ?></strong>
143 </div>
144 <div class="card-body">
145 <div class="col-md-9 row">
146 <div id="success-alert" class="alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'You successfully activate your account.', 'mailin' ); ?></div>
147 <input type="hidden" id="general_error" value="<?php esc_attr_e( 'Please input a valid API v3 key', 'mailin' ); ?>">
148 <input type="hidden" id="curl_no_exist_error" value="<?php esc_attr_e( 'Please install curl on site to use brevo plugin.', 'mailin' ); ?>">
149 <input type="hidden" id="curl_error" value="<?php esc_attr_e( 'Curl error.', 'mailin' ); ?>">
150 <div id="failure-alert" class="alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'Please input a valid API v3 key.', 'mailin' ); ?></div>
151 <p>
152 <?php esc_attr_e( 'Once you have created a Brevo account, activate this plugin to send all of your transactional emails via Brevo SMTP. Brevo optimizes email delivery to ensure emails reach the inbox.', 'mailin' ); ?><br>
153 <?php esc_attr_e( 'To activate your plugin, enter your API v3 Access key.', 'mailin' ); ?><br>
154 </p>
155 <p>
156 <a href="https://app.brevo.com/settings/keys/api?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Get your API key from your account', 'mailin' ); ?></a>
157 </p>
158 <p>
159 <div class="col-md-7">
160 <p class="col-md-12"><input id="sib_access_key" type="text" class="col-md-10" style="margin-top: 10px;" placeholder="xkeysib-xxxxxx"></p>
161 <p class="col-md-12"><button type="button" id="sib_validate_btn" class="col-md-4 btn btn-success"><span class="sib-spin"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i>&nbsp;&nbsp;</span><?php esc_attr_e( 'Login', 'mailin' ); ?></button></p>
162 </div>
163 </p>
164 </div>
165 </div>
166 </div>
167 </div>
168 <?php
169 }
170
171 /** Generate main home page after validation */
172 function generate_main_content() {
173
174 // display account info.
175 $account_settings = SIB_API_Manager::get_account_info();
176 $account_email = $account_settings['account_email'];
177 $account_user_name = isset( $account_settings['account_user_name'] ) ? $account_settings['account_user_name'] : '';
178 $account_data = isset( $account_settings['account_data'] ) ? $account_settings['account_data'] : '';
179 // check smtp available.
180 $smtp_status = SIB_API_Manager::get_smtp_status();
181
182 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
183 // for upgrade to 2.6.0 from old version.
184 if ( ! isset( $home_settings['activate_ma'] ) ) {
185 $home_settings['activate_ma'] = 'no';
186 }
187 // set default sender info.
188 $senders = SIB_API_Manager::get_sender_lists();
189 if (is_array( $senders) && (!isset( $home_settings['sender'] ) || (count($senders) == 1 && $home_settings['from_email'] != $senders[0]['from_email']))) {
190 $home_settings['sender'] = $senders[0]['id'];
191 $home_settings['from_name'] = $senders[0]['from_name'];
192 $home_settings['from_email'] = $senders[0]['from_email'];
193 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
194 }
195
196 // Users Sync part.
197 $currentUsers = count_users();
198 $isSynced = get_option( 'sib_sync_users', '0' );
199 $isEnableSync = '0';
200 if ( $isSynced != $currentUsers['total_users'] ) {
201 $isEnableSync = '1';
202 /* translators: %s: total users */
203 $desc = sprintf( esc_attr__( 'You have %s existing users. Do you want to add them to Brevo?', 'mailin' ), $currentUsers['total_users'] );
204 self::print_sync_popup();
205 } else {
206 $desc = esc_attr__( 'All your users have been added to a Brevo list.','mailin' );
207 }
208 ?>
209
210 <div id="main-content" class="sib-content">
211 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
212 <!-- Account Info -->
213 <div class="card sib-small-content">
214 <div class="card-header">
215 <strong><?php esc_attr_e( 'My Account', 'mailin' ); ?></strong>
216 </div>
217 <div class="card-body">
218 <div class="col-md-12">
219 <span><b><?php esc_attr_e( 'You are currently logged in as : ', 'mailin' ); ?></b></span>
220 <div style="margin-bottom: 10px;">
221 <p class="col-md-12" style="margin-top: 5px;">
222 <?php echo esc_attr( $account_user_name ); ?>&nbsp;-&nbsp;<?php echo esc_attr( $account_email ); ?><br>
223 <?php
224 $count = count( $account_data );
225 for ( $i = 0; $i < $count; $i ++ ) {
226 if ( isset($account_data[$i]['type']) )
227 {
228 echo esc_attr( $account_data[ $i ]['type'] ) . ' - ' . esc_attr( $account_data[ $i ]['credits'] ) . ' ' . esc_attr__( 'credits', 'mailin' ) . '<br>';
229 }
230 }
231 ?>
232 <a class="text-decoration-none" href="<?php echo esc_url( add_query_arg( 'sib_action', 'logout' ) ); ?>"><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Log out', 'mailin' ); ?></a>
233 </p>
234 </div>
235
236 <span><b><?php esc_attr_e( 'Contacts', 'mailin' ); ?></b></span>
237 </div>
238 <div class="row" style="padding-top: 10px;">
239 <div class="col-md-6">
240 <p style="margin-top: 5px;">
241 <a id="sib_list_link" class="text-decoration-none" href="https://app.brevo.com/contact/list/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Access to the list of all my contacts', 'mailin' ); ?></a>
242 </p>
243 </div>
244 <div class="col-md-6 row">
245 <p class="col-md-7">
246 <b><?php echo esc_attr__( 'Users Synchronisation', 'mailin' ); ?></b><br>
247 <?php echo esc_attr( $desc ); ?><br>
248 </p>
249 <div class="col-md-5">
250 <a <?= '1' === $isEnableSync ? 'id="sib-sync-btn" data-bs-toggle="modal" data-bs-target="#syncUsers"' : 'disabled href="javascript:void(0)"'; ?> class="<?= '1' !== $isEnableSync ? 'disabled not-allowed shadow-none' : ''; ?> btn btn-success" style="margin-top: 28px; " name="<?php echo esc_attr__( 'Users Synchronisation', 'mailin' ); ?>" href="#"><?php esc_attr_e( 'Sync my users', 'mailin' ); ?></a>
251 </div>
252 </div>
253 </div>
254 </div>
255 </div>
256 <!-- Transactional Email -->
257 <div class="card sib-small-content">
258 <div class="card-header">
259 <strong><?php esc_attr_e( 'Transactional emails', 'mailin' ); ?></strong>
260 </div>
261 <div class="card-body">
262 <?php
263 if ( 'disabled' == $smtp_status ) :
264 ?>
265 <div id="smtp-failure-alert" class="col-md-12 sib_alert alert alert-danger" role="alert"><?php esc_attr_e( 'Unfortunately, your "Transactional emails" are not activated because your Brevo SMTP account is not active. Please send an email to contact@brevo.com in order to ask for SMTP account activation', 'mailin' ); ?></div>
266 <?php
267 endif;
268 ?>
269 <div id="success-alert" class="col-md-12 sib_alert alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'Mail Sent.', 'mailin' ); ?></div>
270 <div id="failure-alert" class="col-md-12 sib_alert alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'Please input valid email.', 'mailin' ); ?></div>
271 <div class="row">
272 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate email through Brevo', 'mailin' ); ?></p>
273 <div class="col-md-3">
274 <label class="col-md-5"><input type="radio" name="activate_email" id="activate_email_radio_yes" value="yes"
275 <?php
276 checked( $home_settings['activate_email'], 'yes' );
277 if ( 'disabled' === $smtp_status ) {
278 echo ' disabled';
279 }
280 ?>
281 >&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
282 <label class="col-md-5"><input type="radio" name="activate_email" id="activate_email_radio_no" value="no" <?php checked( $home_settings['activate_email'], 'no' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?></label>
283 </div>
284 <div class="col-md-5">
285 <small style="font-style: italic;"><?php esc_attr_e( 'Choose "Yes" if you want to use Brevo SMTP to send transactional emails', 'mailin' ); ?></small>
286 </div>
287 </div>
288 <div id="email_send_field"
289 <?php
290 if ( 'yes' !== $home_settings['activate_email'] ) {
291 echo 'style="display:none;"';
292 }
293 ?>
294 >
295 <div class="row" style="margin-bottom: 10px;">
296 <p class="col-md-4 text-left"><?php esc_attr_e( 'Choose your sender', 'mailin' ); ?></p>
297 <div class="col-md-3">
298 <select id="sender_list" class="col-md-12">
299 <?php
300 $senders = SIB_API_Manager::get_sender_lists();
301 foreach ( $senders as $sender ) {
302 echo "<option value='" . esc_attr( $sender['id'] ) . "' " . selected( $home_settings['sender'], $sender['id'] ) . '>' . esc_attr( $sender['from_name'] ) . '&nbsp;&lt;' . esc_attr( $sender['from_email'] ) . '&gt;</option>';
303 }
304 ?>
305 </select>
306 </div>
307 <div class="col-md-5">
308 <a class="text-decoration-none" href="https://app.brevo.com/senders/" style="font-style: italic;" target="_blank" rel="noopener" ><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Create a new sender', 'mailin' ); ?></a>
309 </div>
310 </div>
311 <div class="row">
312 <p class="col-md-4 text-left"><?php esc_attr_e( 'Enter email to send a test', 'mailin' ); ?></p>
313 <div class="col-md-3">
314 <input id="activate_email" type="email" class="col-md-12">
315 <button type="button" id="send_email_btn" class="col-md-12 btn btn-success"><span class="sib-spin"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i>&nbsp;&nbsp;</span><?php esc_attr_e( 'Send email', 'mailin' ); ?></button>
316 </div>
317 <div class="col-md-5">
318 <small style="font-style: italic;"><?php esc_attr_e( 'Select here the email address you want to send a test email to.', 'mailin' ); ?></small>
319 </div>
320 </div>
321 </div>
322 </div>
323 </div>
324 <!-- Marketing Automation -->
325 <div class="card sib-small-content">
326 <div class="card-header">
327 <strong><?php esc_attr_e( 'Automation', 'mailin' ); ?></strong>
328 </div>
329 <div class="card-body">
330 <div class="sib-ma-alert sib-ma-active alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'Your Marketing Automation script is installed correctly.', 'mailin' ); ?></div>
331 <div class="sib-ma-alert sib-ma-inactive alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'Your Marketing Automation script has been uninstalled', 'mailin' ); ?></div>
332 <div class="sib-ma-alert sib-ma-disabled alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'You have not enabled automation in Brevo. Please do so by choosing the Automation application here: ', 'mailin' ); ?> <a href="https://account-app.brevo.com/account/apps/" target="_blank" rel="noopener">account-app.brevo.com/account/apps/</a> <?php esc_attr_e( 'Thanks', 'mailin' ) ?></div>
333 <input type="hidden" id="sib-ma-unistall" value="<?php esc_attr_e( 'Your Marketing Automation script will be uninstalled, you won\'t have access to any Marketing Automation data and workflows', 'mailin' ); ?>">
334 <div class="row">
335 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate Marketing Automation through Brevo', 'mailin' ); ?></p>
336 <div class="col-md-3">
337 <label class="col-md-5"><input type="radio" name="activate_ma" id="activate_ma_radio_yes" value="yes"
338 <?php
339 checked( $home_settings['activate_ma'], 'yes' );
340 ?>
341 >&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
342 <label class="col-md-5"><input type="radio" name="activate_ma" id="activate_ma_radio_no" value="no" <?php checked( $home_settings['activate_ma'], 'no' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?></label>
343 </div>
344 <div class="col-md-5">
345 <small style="font-style: italic;"><?php esc_attr_e( 'Choose "Yes" if you want to use Brevo Automation to track your website activity', 'mailin' ); ?></small>
346 </div>
347 </div>
348 <div class="row" style="">
349 <p class="col-md-4 text-left" style="font-size: 13px; font-style: italic;"><?php printf( esc_attr__( '%s Explore our resource %s to learn more about Brevo Automation', 'mailin' ), '<a class="text-decoration-none" href="https://help.brevo.com/hc/en-us/articles/208775609/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener">', '</a>' ); ?></p>
350 <div class="col-md-3">
351 <button type="button" id="validate_ma_btn" class="col-md-12 btn btn-success"><span class="sib-spin"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i>&nbsp;&nbsp;</span><?php esc_attr_e( 'Activate', 'mailin' ); ?></button>
352 </div>
353 <div class="col-md-5">
354 </div>
355 </div>
356 </div>
357 </div>
358
359 </div>
360 <?php
361 }
362
363 /**
364 * Generate a language box on the plugin admin page.
365 */
366 public static function generate_side_bar() {
367 do_action( 'sib_language_sidebar' );
368 ?>
369
370 <div class="card text-left box-border-box sib-small-content">
371 <div class="card-header"><strong><?php esc_attr_e( 'About Brevo', 'mailin' ); ?></strong></div>
372 <div class="card-body">
373 <p><?php esc_attr_e( 'Brevo is an online software that helps you build and grow relationships through marketing and transactional emails, marketing automation, and text messages.', 'mailin' ); ?></p>
374 <ul class="sib-widget-menu list-group">
375 <li>
376 <a class="text-decoration-none" href="https://www.brevo.com/about/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Who we are', 'mailin' ); ?></a>
377 </li>
378 <li>
379 <a class="text-decoration-none" href="https://www.brevo.com/pricing/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Pricing', 'mailin' ); ?></a>
380 </li>
381 <li>
382 <a class="text-decoration-none" href="https://www.brevo.com/features/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Features', 'mailin' ); ?></a>
383 </li>
384 </ul>
385 </div>
386
387 </div>
388 <div class="card text-left box-border-box sib-small-content">
389 <div class="card-header"><strong><?php esc_attr_e( 'Need Help?', 'mailin' ); ?></strong></div>
390 <div class="card-body">
391 <p><?php esc_attr_e( 'Do you have a question or need more information?', 'mailin' ); ?></p>
392 <ul class="sib-widget-menu list-group">
393 <li><a class="text-decoration-none" href="https://help.brevo.com/hc/en-us/sections/202171729/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Tutorials', 'mailin' ); ?></a></li>
394 <li><a class="text-decoration-none" href="https://help.brevo.com/hc/en-us?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'FAQ', 'mailin' ); ?></a></li>
395 </ul>
396 <hr>
397 </div>
398 </div>
399 <div class="card text-left box-border-box sib-small-content">
400 <div class="card-header"><strong><?php esc_attr_e( 'Recommend this plugin', 'mailin' ); ?></strong></div>
401 <div class="card-body">
402 <p><?php esc_attr_e( 'Let everyone know you like this plugin through a review!' ,'mailin' ); ?></p>
403 <ul class="sib-widget-menu list-group">
404 <li><a class="text-decoration-none" href="http://wordpress.org/support/view/plugin-reviews/mailin" target="_blank" rel="noopener"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Recommend the Brevo plugin', 'mailin' ); ?></a></li>
405 </ul>
406 </div>
407 </div>
408 <?php
409 }
410
411 /**
412 * Get narration script
413 *
414 * @param string $title - pop up title.
415 * @param string $text - pop up content text.
416 */
417 static function get_narration_script( $title, $text ) {
418 ?>
419 <i title="<?php echo esc_attr( $title ); ?>" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="<?php echo esc_attr( $text ); ?>" data-html="true" class="fa fa-question-circle popover-help-form"></i>
420 <?php
421 }
422
423 /** Print disable mode popup */
424 static function print_disable_popup() {
425 ?>
426 <div class="modal fade sib-disable-modal">
427 <div class="modal-dialog">
428 <div class="modal-content">
429 <div class="modal-header">
430 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true" style="font-size: 22px;">&times;</span><span class="sr-only">Close</span></button>
431 <h4 class="modal-title"><?php esc_attr_e( 'Brevo','mailin' ); ?></h4>
432 </div>
433 <div class="modal-body" style="padding: 30px;">
434 <p>
435 <?php esc_attr_e( 'You are currently not logged in. Create an account or log in to benefit from all of Brevo\'s features an your WordPress site.', 'mailin' ); ?>
436 </p>
437 <ul>
438 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Collect and manage your contacts', 'mailin' ); ?></li>
439 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Send transactional emails via SMTP or API', 'mailin' ); ?></li>
440 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Real time statistics and email tracking', 'mailin' ); ?></li>
441 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Edit and send email marketing', 'mailin' ); ?></li>
442 </ul>
443 <div class="row" style="margin-top: 40px;">
444 <div class="col-md-6">
445 <a href="https://www.brevo.com/users/login/" target="_blank" rel="noopener"><i><?php esc_attr_e( 'Have an account?', 'mailin' ); ?></i></a>
446 </div>
447 <div class="col-md-6">
448 <a href="https://www.brevo.com/users/signup/" target="_blank" rel="noopener" class="btn btn-default"><i class="fa fa-angle-double-right"></i>&nbsp;<?php esc_attr_e( 'Free Subscribe Now', 'mailin' ); ?>&nbsp;<i class="fa fa-angle-double-left"></i></a>
449 </div>
450 </div>
451 </div>
452
453 </div><!-- /.modal-content -->
454 </div><!-- /.modal-dialog -->
455 </div><!-- /.modal -->
456 <button id="sib-disable-popup" class="btn btn-success" data-toggle="modal" data-target=".sib-disable-modal" style="display: none;">sss</button>
457 <script>
458 jQuery(document).ready(function() {
459 jQuery('.sib-disable-modal').modal();
460
461 jQuery('.sib-disable-modal').on('hidden.bs.modal', function() {
462 window.location.href = '<?php echo esc_url( add_query_arg( 'page', 'sib_page_home', admin_url( 'admin.php' ) ) ); ?>';
463 });
464 });
465
466 </script>
467
468 <?php
469 }
470
471 /** Print user sync popup */
472 static function print_sync_popup() {
473 ?>
474 <div class="modal fade sib-sync-modal" id="syncUsers">
475 <div class="modal-dialog">
476 <div class="modal-content">
477 <div class="modal-header">
478 <h5 class="modal-title"><?php esc_attr_e( 'Users Synchronisation','mailin' ); ?></h5>
479 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
480 </div>
481 <div class="modal-body sync-modal-body" style="padding: 10px;">
482 <div id="sync-failure" class="sib_alert alert alert-danger" style="margin-bottom: 0px;display: none;"></div>
483 <form id="sib-sync-form">
484 <!-- roles -->
485 <div class="row sync-row" style="margin-top: 0;">
486 <b><p><?php esc_attr_e( 'Roles to sync', 'mailin' ); ?></p></b>
487 <?php foreach ( wp_roles()->roles as $role_name => $role_info ) : ?>
488 <div class="col-md-6">
489 <span class="" style="display: block;float:left;padding-left: 16px;"><input type="checkbox" id="<?php echo esc_attr( $role_name ); ?>" value="<?php echo esc_attr( $role_name ); ?>" name="sync_role" checked><label for="<?php echo esc_attr( $role_name ); ?>" style="margin: 4px 24px 0 7px;font-weight: normal;"><?php esc_attr_e( ucfirst($role_name), 'mailin' ); ?></label></span>
490 </div>
491 <?php endforeach; ?>
492 </div>
493 <!-- lists -->
494 <?php $lists = SIB_API_Manager::get_lists(); ?>
495 <div class="row sync-row">
496 <b><p><?php esc_attr_e( 'Sync Lists', 'mailin' ); ?></p></b>
497 <div class="row" style="margin-top: 0;">
498 <div class="col-md-6">
499 <p><?php esc_attr_e( 'Choose the Brevo list in which you want to add your existing customers:', 'mailin' ); ?></p>
500 </div>
501 <div class="col-md-6">
502 <select data-placeholder="Please select the list" id="sib_select_list" name="list_id" multiple="true">
503 <?php foreach ( $lists as $list ) : ?>
504 <option value="<?php echo esc_attr( $list['id'] ); ?>"><?php echo esc_attr( $list['name'] ); ?></option>
505 <?php endforeach; ?>
506 </select>
507 </div>
508 </div>
509 </div>
510 <!-- Match Attributes -->
511 <?php
512 // available WordPress attributes.
513 $wpAttrs = array(
514 'first_name' => __( 'First Name','mailin' ),
515 'last_name' => __( 'Last Name','mailin' ),
516 'user_url' => __( 'Website URL','mailin' ),
517 'roles' => __( 'User Role','mailin' ),
518 'user_login' => __( 'Username','mailin' ),
519 'nickname' => __( 'Nickname','mailin' ),
520 'user_registered' => __( 'User Registration Date','mailin' ),
521 'display_name' => __( 'Display Name','mailin' ),
522 'description' => __( 'Description about user','mailin' ),
523 );
524 // available sendinblue attributes.
525 $sibAllAttrs = SIB_API_Manager::get_attributes();
526 $sibAttrs = $sibAllAttrs['attributes']['normal_attributes'];
527 ?>
528 <div class="row sync-row" id="sync-attr-area">
529 <b><p><?php esc_attr_e( 'Match Attributes', 'mailin' ); ?></p></b>
530 <div class="row" style="padding: 5px;margin-top: 0;">
531 <div class="row" style="margin-top: 0;">
532 <div class="col-md-6">
533 <p><?php esc_attr_e( 'WordPress Users Attributes', 'mailin' ); ?></p>
534 </div>
535 <div class="col-md-6">
536 <p><?php esc_attr_e( 'Brevo Contact Attributes', 'mailin' ); ?></p>
537 </div>
538 </div>
539 </div>
540
541 <div class="col-md-11 sync-attr-line">
542 <div class="row sync-attr" style="padding: 5px;border-top: dotted 1px #dedede;border-bottom: dotted 1px #dedede;margin-top: 0;">
543 <div class="col-md-5">
544 <select class="sync-wp-attr" name="" style="width: 100%;">
545 <?php foreach ( $wpAttrs as $id => $label ) : ?>
546 <option value="<?php echo esc_attr( $id ); ?>"><?php echo esc_attr( $label ); ?></option>
547 <?php endforeach; ?>
548 </select>
549 </div>
550 <div class="col-md-1" style="padding-left: 10px;padding-top: 3px;"><span class="dashicons dashicons-leftright"></span></div>
551 <div class="col-md-5">
552 <select class="sync-sib-attr" name="" style="width: 100%;">
553 <?php foreach ( $sibAttrs as $attr ) : ?>
554 <option value="<?php echo esc_attr( $attr['name'] ); ?>"><?php echo esc_attr( $attr['name'] ); ?></option>
555 <?php endforeach; ?>
556 </select>
557 </div>
558 <div class="col-md-1" style="padding-top: 3px;">
559 <a href="javascript:void(0)" class="sync-attr-dismiss" style="display: none;"><span class="dashicons dashicons-dismiss"></span></a>
560 </div>
561 <input type="hidden" class="sync-match" name="<?php echo esc_attr( $sibAttrs[0]['name'] ); ?>" value="first_name">
562 </div>
563 </div>
564 <div class="col-md-1 sync-attr-plus-col">
565 <div class="row sync-attr-plus">
566 <a href="javascript:void(0)"><span class="dashicons dashicons-plus-alt "></span></a>
567 </div>
568 </div>
569 </div>
570 <!-- Apply button -->
571 <div class="col-md-12 mt-2">
572 <a href="javascript:void(0)" id="sib_sync_users_btn" class="btn btn-success" style="float: right;"><?php esc_attr_e( 'Apply', 'mailin' ); ?></a>
573 </div>
574 </form>
575 </div>
576 </div><!-- /.modal-content -->
577 </div><!-- /.modal-dialog -->
578 </div><!-- /.modal -->
579 <?php
580 }
581
582 /** Ajax module for validation (Home - welcome) */
583 public static function ajax_validation_process() {
584 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
585 $access_key = isset( $_POST['access_key'] ) ? sanitize_text_field( wp_unslash( $_POST['access_key'] ) ) : '';
586 try {
587 update_option(SIB_Manager::API_KEY_V3_OPTION_NAME, $access_key);
588 $apiClient = new SendinblueApiClient();
589 $response = $apiClient->getAccount();
590 if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK ) {
591 self::processInstallationInfo("login");
592 // create tables for users and forms.
593 SIB_Model_Users::createTable();
594 SIB_Forms::createTable(); // create default form also
595
596 // If the client don't have attributes regarding Double OptIn then we will create these.
597 SIB_API_Manager::create_default_dopt();
598 $message = 'success';
599 } else {
600 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
601 $message = isset($response['code']) ? $response['code'] . ': ' . $response['message'] :'Please input a valid API v3 key';
602 }
603 } catch ( Exception $e ) {
604 $message = $e->getMessage();
605 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
606 } finally {
607 wp_send_json($message);
608 }
609 }
610
611 /** Ajax module to change activate marketing automation option */
612 public static function ajax_validate_ma() {
613 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
614 $main_settings = get_option( SIB_Manager::MAIN_OPTION_NAME );
615 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
616 $ma_key = $main_settings['ma_key'];
617 if ( '' != $ma_key ) {
618 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
619 $home_settings['activate_ma'] = $option_val;
620 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
621 wp_send_json( $option_val );
622 } else {
623 $home_settings['activate_ma'] = 'no';
624 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
625 wp_send_json( 'disabled' );
626 }
627 }
628
629 /** Ajax module to change activate email option */
630 public static function ajax_activate_email_change() {
631 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
632 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
633 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
634 $home_settings['activate_email'] = $option_val;
635 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
636 wp_send_json( $option_val );
637 }
638
639 /** Ajax module to change sender detail */
640 public static function ajax_sender_change() {
641 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
642 $sender_id = isset( $_POST['sender'] ) ? sanitize_text_field( wp_unslash( $_POST['sender'] ) ) : ''; // sender id.
643 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
644 $home_settings['sender'] = $sender_id;
645 $senders = SIB_API_Manager::get_sender_lists();
646 foreach ( $senders as $sender ) {
647 if ( $sender['id'] == $sender_id ) {
648 $home_settings['from_name'] = $sender['from_name'];
649 $home_settings['from_email'] = $sender['from_email'];
650 }
651 }
652 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
653 wp_send_json( 'success' );
654 }
655
656 /** Ajax module for send a test email */
657 public static function ajax_send_email() {
658 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
659
660 $subject = __( '[Brevo SMTP] test email', 'mailin' );
661 // Get sender info.
662 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
663 if ( isset( $home_settings['sender'] ) ) {
664 $fromname = $home_settings['from_name'];
665 $from_email = $home_settings['from_email'];
666 } else {
667 $from_email = __( 'no-reply@brevo.com', 'mailin' );
668 $fromname = __( 'Brevo', 'mailin' );
669 }
670
671 $from = array( $from_email, $fromname );
672 $email_templates = SIB_API_Manager::get_email_template( 'test' );
673
674 $html = $email_templates['html_content'];
675
676 $html = str_replace( '{title}', $subject, $html );
677
678 $mailin = new SendinblueApiClient();
679
680 $data = [
681 'sender' => [
682 'name' => $fromname,
683 'email' => $from_email,
684 ],
685 'replyTo' => [
686 'email' => $from_email,
687 ],
688 'to' => [
689 [
690 'email' => sanitize_email($_POST['email'])
691 ]
692 ],
693 'subject' => $subject,
694 'htmlContent' => $html
695 ];
696 $mailin->sendEmail( $data );
697
698 wp_send_json( 'success' );
699 }
700
701 /** Ajax module for remove all transient value */
702 public static function ajax_remove_cache() {
703 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
704 wp_send_json( 'success' );
705 }
706
707 /** Ajax module for sync wp users to contact list */
708 public static function ajax_sync_users() {
709 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
710
711 // phpcs:ignore
712 $postData = isset( $_POST['data'] ) ? $_POST['data'] : array();
713
714 if ( ! isset( $postData['sync_role'] ) ) {
715 wp_send_json(
716 array(
717 'code' => 'empty_role',
718 'message' => __( 'Please select a user role.','mailin' ),
719 )
720 );}
721 if ( isset( $postData['errAttr'] ) ) {
722 wp_send_json(
723 array(
724 'code' => 'attr_duplicated',
725 'message' => sprintf( esc_attr__( 'The attribute %s is duplicated. You can select one at a time.','mailin' ), '<b>' . esc_html($postData['errAttr']) . '</b>' ),
726 )
727 );}
728
729 $roles = (array) $postData['sync_role']; // array or string.
730 $listIDs = array_map('intval', (array) $postData['list_id']);
731
732 unset( $postData['sync_role'] );
733 unset( $postData['list_id'] );
734
735 $usersData = 'EMAIL';
736 foreach ( $postData as $attrSibName => $attrWP ) {
737 $usersData .= ';' . sanitize_text_field($attrSibName);
738 }
739
740 // sync users to sendinblue.
741 // create body data like csv.
742 // NAME;SURNAME;EMAIL\nName1;Surname1;example1@example.net\nName2;Surname2;example2@example.net.
743 $contentData = '';
744 $usersCount = 0;
745 foreach ( $roles as $role ) {
746 $users = get_users(
747 array(
748 'role' => sanitize_text_field($role),
749 )
750 );
751 if ( empty( $users ) ) {
752 continue;
753 }
754 $usersCount += count($users);
755 foreach ( $users as $user ) {
756 $userId = $user->ID;
757 $user_info = get_userdata( $userId );
758 $userData = $user_info->user_email;
759 foreach ( $postData as $attrSibName => $attrWP ) {
760 if ( $attrWP == 'roles' )
761 {
762 $userData .= ';' . implode( ', ', $user_info->$attrWP ) ;
763 }
764 else {
765 $userData .= ';' . $user_info->$attrWP;
766 }
767
768 }
769 $contentData .= "\n" . strip_tags($userData);
770 }
771 }
772 if ( '' == $contentData ) {
773 wp_send_json(
774 array(
775 'code' => 'empty_users',
776 'message' => __( 'There is not any user in the roles.','mailin' ),
777 )
778 );}
779
780 $usersData .= $contentData;
781 $result = SIB_API_Manager::sync_users( $usersData, $listIDs );
782 update_option('sib_sync_users', $usersCount);
783 wp_send_json( $result );
784 }
785
786 /** Logout process */
787 function logout() {
788 self::processInstallationInfo("logout");
789 $setting = array();
790 update_option( SIB_Manager::MAIN_OPTION_NAME, $setting );
791 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
792
793 $home_settings = array(
794 'activate_email' => 'no',
795 'activate_ma' => 'no',
796 );
797 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
798
799 // remove sync users option.
800 delete_option( 'sib_sync_users' );
801 // remove all transients.
802 SIB_API_Manager::remove_transients();
803
804 // remove all forms.
805 SIB_Forms::removeAllForms();
806 SIB_Forms_Lang::remove_all_trans();
807
808 wp_safe_redirect( add_query_arg( 'page', self::PAGE_ID, admin_url( 'admin.php' ) ) );
809 exit();
810 }
811
812 public static function processInstallationInfo($action)
813 {
814 global $wp_version;
815
816 if($action == "login")
817 {
818 $apiClient = new SendinblueApiClient();
819
820 $params["partnerName"] = "WORDPRESS";
821 $params["active"] = true;
822 $params["plugin_version"] = SendinblueApiClient::PLUGIN_VERSION;
823 if(!empty($wp_version))
824 {
825 $params["shop_version"] = $wp_version;
826 }
827 $params["shop_url"] = get_home_url();
828 $params["created_at"] = gmdate("Y-m-d\TH:i:s\Z");
829 $params["activated_at"] = gmdate("Y-m-d\TH:i:s\Z");
830 $params["type"] = "sib";
831 $response = $apiClient->createInstallationInfo($params);
832 if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_CREATED )
833 {
834 if(!empty($response["id"]))
835 {
836 update_option(SIB_Manager::INSTALLATION_ID, $response["id"]);
837 }
838 }
839 }
840 elseif($action == "logout")
841 {
842 $installationId = get_option( SIB_Manager::INSTALLATION_ID );
843 if(!empty($installationId))
844 {
845 $apiClient = new SendinblueApiClient();
846 $params["active"] = false;
847 $params["deactivated_at"] = gmdate("Y-m-d\TH:i:s\Z");
848 $apiClient->updateInstallationInfo($installationId, $params);
849 }
850 }
851 }
852 }
853
854 }
855