PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.1.76
Brevo – Email, SMS, Web Push, Chat, and more. v3.1.76
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 2 years ago
page-home.php
859 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 global $wp_roles;
40 $wp_roles->add_cap( 'administrator', 'view_custom_menu' );
41 $wp_roles->add_cap( 'editor', 'view_custom_menu' );
42
43 add_menu_page( __( 'Brevo', 'mailin' ), __( 'Brevo', 'mailin' ), 'view_custom_menu', self::PAGE_ID, array( &$this, 'generate' ), SIB_Manager::$plugin_url . '/img/favicon.ico' );
44 $this->page_hook = add_submenu_page( self::PAGE_ID, __( 'Home', 'mailin' ), __( 'Home', 'mailin' ), 'view_custom_menu', self::PAGE_ID, array( &$this, 'generate' ) );
45 add_action( 'load-' . $this->page_hook, array( &$this, 'init' ) );
46 add_action( 'admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ) );
47 add_action( 'admin_print_styles-' . $this->page_hook, array( $this, 'enqueue_styles' ) );
48 }
49
50 /**
51 * Init Process
52 */
53 function Init() {
54 if ( ( isset( $_GET['sib_action'] ) ) && ( 'logout' === sanitize_text_field($_GET['sib_action'] )) ) {
55 $this->logout();
56 }
57 }
58
59 /**
60 * Enqueue scripts of plugin
61 */
62 function enqueue_scripts() {
63 wp_enqueue_script( 'sib-admin-js' );
64 wp_enqueue_script( 'sib-bootstrap-js' );
65 wp_enqueue_script( 'sib-chosen-js' );
66 wp_localize_script(
67 'sib-admin-js', 'ajax_sib_object',
68 array(
69 'ajax_url' => admin_url( 'admin-ajax.php' ),
70 'ajax_nonce' => wp_create_nonce( 'ajax_sib_admin_nonce' ),
71 )
72 );
73 }
74
75 /**
76 * Enqueue style sheets of plugin
77 */
78 function enqueue_styles() {
79 wp_enqueue_style( 'sib-admin-css' );
80 wp_enqueue_style( 'sib-bootstrap-css' );
81 wp_enqueue_style( 'sib-chosen-css' );
82 wp_enqueue_style( 'sib-fontawesome-css' );
83 }
84
85 /** Generate page script */
86 function generate() {
87 ?>
88 <div id="wrap" class="wrap box-border-box container-fluid">
89 <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" viewBox="0 0 32 32">
90 <circle cx="16" cy="16" r="16" fill="#0B996E"/>
91 <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"/>
92 </svg>
93 <svg xmlns="http://www.w3.org/2000/svg" width="80" height="25" fill="currentColor" viewBox="0 0 90 31">
94 <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"/>
95 </svg>
96
97 <div class="row">
98 <div id="wrap-left" class="box-border-box col-md-9">
99 <div id="sib-message-box" class="row alert alert-success" style="display: none;">
100 <p id="sib-message-body"></p>
101 </div>
102 <?php
103 if ( SIB_Manager::is_done_validation(false)) {
104 $this->generate_main_content();
105 } else {
106 $this->generate_welcome_content();
107 }
108 ?>
109 </div>
110 <div id="wrap-right-side" class="box-border-box col-md-3">
111 <?php
112 self::generate_side_bar();
113 ?>
114 </div>
115 </div>
116 </div>
117 <?php
118 }
119
120 /** Generate welcome page before validation */
121 function generate_welcome_content() {
122 ?>
123
124 <div id="main-content" class="sib-content">
125 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
126 <div class="card sib-small-content">
127 <div class="card-header">
128 <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>
129 </div>
130 <div class="card-body">
131 <div class="col-md-9">
132 <p><?php esc_attr_e( 'By creating a free Brevo account, you will be able to send confirmation emails and:', 'mailin' ); ?></p>
133 <ul class="sib-home-feature">
134 <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>
135 <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>
136 <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>
137 <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>
138 <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>
139 </ul>
140 <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>
141 </div>
142 </div>
143 </div>
144 <div class="card sib-small-content">
145 <div class="card-header">
146 <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>
147 </div>
148 <div class="card-body">
149 <div class="col-md-9 row">
150 <div id="success-alert" class="alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'You successfully activate your account.', 'mailin' ); ?></div>
151 <input type="hidden" id="general_error" value="<?php esc_attr_e( 'Please input a valid API v3 key', 'mailin' ); ?>">
152 <input type="hidden" id="curl_no_exist_error" value="<?php esc_attr_e( 'Please install curl on site to use brevo plugin.', 'mailin' ); ?>">
153 <input type="hidden" id="curl_error" value="<?php esc_attr_e( 'Curl error.', 'mailin' ); ?>">
154 <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>
155 <p>
156 <?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>
157 <?php esc_attr_e( 'To activate your plugin, enter your API v3 Access key.', 'mailin' ); ?><br>
158 </p>
159 <p>
160 <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>
161 </p>
162 <p>
163 <div class="col-md-7">
164 <p class="col-md-12"><input id="sib_access_key" type="text" class="col-md-10" style="margin-top: 10px;" placeholder="xkeysib-xxxxxx"></p>
165 <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>
166 </div>
167 </p>
168 </div>
169 </div>
170 </div>
171 </div>
172 <?php
173 }
174
175 /** Generate main home page after validation */
176 function generate_main_content() {
177
178 // display account info.
179 $account_settings = SIB_API_Manager::get_account_info();
180 $account_email = $account_settings['account_email'];
181 $account_user_name = isset( $account_settings['account_user_name'] ) ? $account_settings['account_user_name'] : '';
182 $account_data = isset( $account_settings['account_data'] ) ? $account_settings['account_data'] : '';
183 // check smtp available.
184 $smtp_status = SIB_API_Manager::get_smtp_status();
185
186 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
187 // for upgrade to 2.6.0 from old version.
188 if ( ! isset( $home_settings['activate_ma'] ) ) {
189 $home_settings['activate_ma'] = 'no';
190 }
191 // set default sender info.
192 $senders = SIB_API_Manager::get_sender_lists();
193 if (is_array( $senders) && (!isset( $home_settings['sender'] ) || (count($senders) == 1 && $home_settings['from_email'] != $senders[0]['from_email']))) {
194 $home_settings['sender'] = $senders[0]['id'];
195 $home_settings['from_name'] = $senders[0]['from_name'];
196 $home_settings['from_email'] = $senders[0]['from_email'];
197 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
198 }
199
200 // Users Sync part.
201 $currentUsers = count_users();
202 $isSynced = get_option( 'sib_sync_users', '0' );
203 $isEnableSync = '0';
204 if ( $isSynced != $currentUsers['total_users'] ) {
205 $isEnableSync = '1';
206 /* translators: %s: total users */
207 $desc = sprintf( esc_attr__( 'You have %s existing users. Do you want to add them to Brevo?', 'mailin' ), $currentUsers['total_users'] );
208 self::print_sync_popup();
209 } else {
210 $desc = esc_attr__( 'All your users have been added to a Brevo list.','mailin' );
211 }
212 ?>
213
214 <div id="main-content" class="sib-content">
215 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
216 <!-- Account Info -->
217 <div class="card sib-small-content">
218 <div class="card-header">
219 <strong><?php esc_attr_e( 'My Account', 'mailin' ); ?></strong>
220 </div>
221 <div class="card-body">
222 <div class="col-md-12">
223 <span><b><?php esc_attr_e( 'You are currently logged in as : ', 'mailin' ); ?></b></span>
224 <div style="margin-bottom: 10px;">
225 <p class="col-md-12" style="margin-top: 5px;">
226 <?php echo esc_attr( $account_user_name ); ?>&nbsp;-&nbsp;<?php echo esc_attr( $account_email ); ?><br>
227 <?php
228 $count = count( $account_data );
229 for ( $i = 0; $i < $count; $i ++ ) {
230 if ( isset($account_data[$i]['type']) )
231 {
232 echo esc_attr( $account_data[ $i ]['type'] ) . ' - ' . esc_attr( $account_data[ $i ]['credits'] ) . ' ' . esc_attr__( 'credits', 'mailin' ) . '<br>';
233 }
234 }
235 ?>
236 <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>
237 </p>
238 </div>
239
240 <span><b><?php esc_attr_e( 'Contacts', 'mailin' ); ?></b></span>
241 </div>
242 <div class="row" style="padding-top: 10px;">
243 <div class="col-md-6">
244 <p style="margin-top: 5px;">
245 <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>
246 </p>
247 </div>
248 <div class="col-md-6 row">
249 <p class="col-md-7">
250 <b><?php echo esc_attr__( 'Users Synchronisation', 'mailin' ); ?></b><br>
251 <?php echo esc_attr( $desc ); ?><br>
252 </p>
253 <div class="col-md-5">
254 <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>
255 </div>
256 </div>
257 </div>
258 </div>
259 </div>
260 <!-- Transactional Email -->
261 <div class="card sib-small-content">
262 <div class="card-header">
263 <strong><?php esc_attr_e( 'Transactional emails', 'mailin' ); ?></strong>
264 </div>
265 <div class="card-body">
266 <?php
267 if ( 'disabled' == $smtp_status ) :
268 ?>
269 <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>
270 <?php
271 endif;
272 ?>
273 <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>
274 <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>
275 <div class="row">
276 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate email through Brevo', 'mailin' ); ?></p>
277 <div class="col-md-3">
278 <label class="col-md-5"><input type="radio" name="activate_email" id="activate_email_radio_yes" value="yes"
279 <?php
280 checked( $home_settings['activate_email'], 'yes' );
281 if ( 'disabled' === $smtp_status ) {
282 echo ' disabled';
283 }
284 ?>
285 >&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
286 <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>
287 </div>
288 <div class="col-md-5">
289 <small style="font-style: italic;"><?php esc_attr_e( 'Choose "Yes" if you want to use Brevo SMTP to send transactional emails', 'mailin' ); ?></small>
290 </div>
291 </div>
292 <div id="email_send_field"
293 <?php
294 if ( 'yes' !== $home_settings['activate_email'] ) {
295 echo 'style="display:none;"';
296 }
297 ?>
298 >
299 <div class="row" style="margin-bottom: 10px;">
300 <p class="col-md-4 text-left"><?php esc_attr_e( 'Choose your sender', 'mailin' ); ?></p>
301 <div class="col-md-3">
302 <select id="sender_list" class="col-md-12">
303 <?php
304 $senders = SIB_API_Manager::get_sender_lists();
305 foreach ( $senders as $sender ) {
306 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>';
307 }
308 ?>
309 </select>
310 </div>
311 <div class="col-md-5">
312 <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>
313 </div>
314 </div>
315 <div class="row">
316 <p class="col-md-4 text-left"><?php esc_attr_e( 'Enter email to send a test', 'mailin' ); ?></p>
317 <div class="col-md-3">
318 <input id="activate_email" type="email" class="col-md-12">
319 <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>
320 </div>
321 <div class="col-md-5">
322 <small style="font-style: italic;"><?php esc_attr_e( 'Select here the email address you want to send a test email to.', 'mailin' ); ?></small>
323 </div>
324 </div>
325 </div>
326 </div>
327 </div>
328 <!-- Marketing Automation -->
329 <div class="card sib-small-content">
330 <div class="card-header">
331 <strong><?php esc_attr_e( 'Automation', 'mailin' ); ?></strong>
332 </div>
333 <div class="card-body">
334 <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>
335 <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>
336 <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>
337 <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' ); ?>">
338 <div class="row">
339 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate Marketing Automation through Brevo', 'mailin' ); ?></p>
340 <div class="col-md-3">
341 <label class="col-md-5"><input type="radio" name="activate_ma" id="activate_ma_radio_yes" value="yes"
342 <?php
343 checked( $home_settings['activate_ma'], 'yes' );
344 ?>
345 >&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
346 <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>
347 </div>
348 <div class="col-md-5">
349 <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>
350 </div>
351 </div>
352 <div class="row" style="">
353 <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>
354 <div class="col-md-3">
355 <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>
356 </div>
357 <div class="col-md-5">
358 </div>
359 </div>
360 </div>
361 </div>
362
363 </div>
364 <?php
365 }
366
367 /**
368 * Generate a language box on the plugin admin page.
369 */
370 public static function generate_side_bar() {
371 do_action( 'sib_language_sidebar' );
372 ?>
373
374 <div class="card text-left box-border-box sib-small-content">
375 <div class="card-header"><strong><?php esc_attr_e( 'About Brevo', 'mailin' ); ?></strong></div>
376 <div class="card-body">
377 <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>
378 <ul class="sib-widget-menu list-group">
379 <li>
380 <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>
381 </li>
382 <li>
383 <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>
384 </li>
385 <li>
386 <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>
387 </li>
388 </ul>
389 </div>
390
391 </div>
392 <div class="card text-left box-border-box sib-small-content">
393 <div class="card-header"><strong><?php esc_attr_e( 'Need Help?', 'mailin' ); ?></strong></div>
394 <div class="card-body">
395 <p><?php esc_attr_e( 'Do you have a question or need more information?', 'mailin' ); ?></p>
396 <ul class="sib-widget-menu list-group">
397 <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>
398 <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>
399 </ul>
400 <hr>
401 </div>
402 </div>
403 <div class="card text-left box-border-box sib-small-content">
404 <div class="card-header"><strong><?php esc_attr_e( 'Recommend this plugin', 'mailin' ); ?></strong></div>
405 <div class="card-body">
406 <p><?php esc_attr_e( 'Let everyone know you like this plugin through a review!' ,'mailin' ); ?></p>
407 <ul class="sib-widget-menu list-group">
408 <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>
409 </ul>
410 </div>
411 </div>
412 <?php
413 }
414
415 /**
416 * Get narration script
417 *
418 * @param string $title - pop up title.
419 * @param string $text - pop up content text.
420 */
421 static function get_narration_script( $title, $text ) {
422 ?>
423 <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>
424 <?php
425 }
426
427 /** Print disable mode popup */
428 static function print_disable_popup() {
429 ?>
430 <div class="modal fade sib-disable-modal">
431 <div class="modal-dialog">
432 <div class="modal-content">
433 <div class="modal-header">
434 <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>
435 <h4 class="modal-title"><?php esc_attr_e( 'Brevo','mailin' ); ?></h4>
436 </div>
437 <div class="modal-body" style="padding: 30px;">
438 <p>
439 <?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' ); ?>
440 </p>
441 <ul>
442 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Collect and manage your contacts', 'mailin' ); ?></li>
443 <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>
444 <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>
445 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Edit and send email marketing', 'mailin' ); ?></li>
446 </ul>
447 <div class="row" style="margin-top: 40px;">
448 <div class="col-md-6">
449 <a href="https://www.brevo.com/users/login/" target="_blank" rel="noopener"><i><?php esc_attr_e( 'Have an account?', 'mailin' ); ?></i></a>
450 </div>
451 <div class="col-md-6">
452 <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>
453 </div>
454 </div>
455 </div>
456
457 </div><!-- /.modal-content -->
458 </div><!-- /.modal-dialog -->
459 </div><!-- /.modal -->
460 <button id="sib-disable-popup" class="btn btn-success" data-toggle="modal" data-target=".sib-disable-modal" style="display: none;">sss</button>
461 <script>
462 jQuery(document).ready(function() {
463 jQuery('.sib-disable-modal').modal();
464
465 jQuery('.sib-disable-modal').on('hidden.bs.modal', function() {
466 window.location.href = '<?php echo esc_url( add_query_arg( 'page', 'sib_page_home', admin_url( 'admin.php' ) ) ); ?>';
467 });
468 });
469
470 </script>
471
472 <?php
473 }
474
475 /** Print user sync popup */
476 static function print_sync_popup() {
477 ?>
478 <div class="modal fade sib-sync-modal" id="syncUsers">
479 <div class="modal-dialog">
480 <div class="modal-content">
481 <div class="modal-header">
482 <h5 class="modal-title"><?php esc_attr_e( 'Users Synchronisation','mailin' ); ?></h5>
483 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
484 </div>
485 <div class="modal-body sync-modal-body" style="padding: 10px;">
486 <div id="sync-failure" class="sib_alert alert alert-danger" style="margin-bottom: 0px;display: none;"></div>
487 <form id="sib-sync-form">
488 <!-- roles -->
489 <div class="row sync-row" style="margin-top: 0;">
490 <b><p><?php esc_attr_e( 'Roles to sync', 'mailin' ); ?></p></b>
491 <?php foreach ( wp_roles()->roles as $role_name => $role_info ) : ?>
492 <div class="col-md-6">
493 <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>
494 </div>
495 <?php endforeach; ?>
496 </div>
497 <!-- lists -->
498 <?php $lists = SIB_API_Manager::get_lists(); ?>
499 <div class="row sync-row">
500 <b><p><?php esc_attr_e( 'Sync Lists', 'mailin' ); ?></p></b>
501 <div class="row" style="margin-top: 0;">
502 <div class="col-md-6">
503 <p><?php esc_attr_e( 'Choose the Brevo list in which you want to add your existing customers:', 'mailin' ); ?></p>
504 </div>
505 <div class="col-md-6">
506 <select data-placeholder="Please select the list" id="sib_select_list" name="list_id" multiple="true">
507 <?php foreach ( $lists as $list ) : ?>
508 <option value="<?php echo esc_attr( $list['id'] ); ?>"><?php echo esc_attr( $list['name'] ); ?></option>
509 <?php endforeach; ?>
510 </select>
511 </div>
512 </div>
513 </div>
514 <!-- Match Attributes -->
515 <?php
516 // available WordPress attributes.
517 $wpAttrs = array(
518 'first_name' => __( 'First Name','mailin' ),
519 'last_name' => __( 'Last Name','mailin' ),
520 'user_url' => __( 'Website URL','mailin' ),
521 'roles' => __( 'User Role','mailin' ),
522 'user_login' => __( 'Username','mailin' ),
523 'nickname' => __( 'Nickname','mailin' ),
524 'user_registered' => __( 'User Registration Date','mailin' ),
525 'display_name' => __( 'Display Name','mailin' ),
526 'description' => __( 'Description about user','mailin' ),
527 );
528 // available sendinblue attributes.
529 $sibAllAttrs = SIB_API_Manager::get_attributes();
530 $sibAttrs = $sibAllAttrs['attributes']['normal_attributes'];
531 ?>
532 <div class="row sync-row" id="sync-attr-area">
533 <b><p><?php esc_attr_e( 'Match Attributes', 'mailin' ); ?></p></b>
534 <div class="row" style="padding: 5px;margin-top: 0;">
535 <div class="row" style="margin-top: 0;">
536 <div class="col-md-6">
537 <p><?php esc_attr_e( 'WordPress Users Attributes', 'mailin' ); ?></p>
538 </div>
539 <div class="col-md-6">
540 <p><?php esc_attr_e( 'Brevo Contact Attributes', 'mailin' ); ?></p>
541 </div>
542 </div>
543 </div>
544
545 <div class="col-md-11 sync-attr-line">
546 <div class="row sync-attr" style="padding: 5px;border-top: dotted 1px #dedede;border-bottom: dotted 1px #dedede;margin-top: 0;">
547 <div class="col-md-5">
548 <select class="sync-wp-attr" name="" style="width: 100%;">
549 <?php foreach ( $wpAttrs as $id => $label ) : ?>
550 <option value="<?php echo esc_attr( $id ); ?>"><?php echo esc_attr( $label ); ?></option>
551 <?php endforeach; ?>
552 </select>
553 </div>
554 <div class="col-md-1" style="padding-left: 10px;padding-top: 3px;"><span class="dashicons dashicons-leftright"></span></div>
555 <div class="col-md-5">
556 <select class="sync-sib-attr" name="" style="width: 100%;">
557 <?php foreach ( $sibAttrs as $attr ) : ?>
558 <option value="<?php echo esc_attr( $attr['name'] ); ?>"><?php echo esc_attr( $attr['name'] ); ?></option>
559 <?php endforeach; ?>
560 </select>
561 </div>
562 <div class="col-md-1" style="padding-top: 3px;">
563 <a href="javascript:void(0)" class="sync-attr-dismiss" style="display: none;"><span class="dashicons dashicons-dismiss"></span></a>
564 </div>
565 <input type="hidden" class="sync-match" name="<?php echo esc_attr( $sibAttrs[0]['name'] ); ?>" value="first_name">
566 </div>
567 </div>
568 <div class="col-md-1 sync-attr-plus-col">
569 <div class="row sync-attr-plus">
570 <a href="javascript:void(0)"><span class="dashicons dashicons-plus-alt "></span></a>
571 </div>
572 </div>
573 </div>
574 <!-- Apply button -->
575 <div class="col-md-12 mt-2">
576 <a href="javascript:void(0)" id="sib_sync_users_btn" class="btn btn-success" style="float: right;"><?php esc_attr_e( 'Apply', 'mailin' ); ?></a>
577 </div>
578 </form>
579 </div>
580 </div><!-- /.modal-content -->
581 </div><!-- /.modal-dialog -->
582 </div><!-- /.modal -->
583 <?php
584 }
585
586 /** Ajax module for validation (Home - welcome) */
587 public static function ajax_validation_process() {
588 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
589 $access_key = isset( $_POST['access_key'] ) ? sanitize_text_field( wp_unslash( $_POST['access_key'] ) ) : '';
590 try {
591 update_option(SIB_Manager::API_KEY_V3_OPTION_NAME, $access_key);
592 $apiClient = new SendinblueApiClient();
593 $response = $apiClient->getAccount();
594 if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK ) {
595 self::processInstallationInfo("login");
596 // create tables for users and forms.
597 SIB_Model_Users::createTable();
598 SIB_Forms::createTable(); // create default form also
599
600 // If the client don't have attributes regarding Double OptIn then we will create these.
601 SIB_API_Manager::create_default_dopt();
602 $message = 'success';
603 } else {
604 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
605 $message = isset($response['code']) ? $response['code'] . ': ' . $response['message'] :'Please input a valid API v3 key';
606 }
607 } catch ( Exception $e ) {
608 $message = $e->getMessage();
609 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
610 } finally {
611 wp_send_json($message);
612 }
613 }
614
615 /** Ajax module to change activate marketing automation option */
616 public static function ajax_validate_ma() {
617 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
618 $main_settings = get_option( SIB_Manager::MAIN_OPTION_NAME );
619 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
620 $ma_key = $main_settings['ma_key'];
621 if ( '' != $ma_key ) {
622 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
623 $home_settings['activate_ma'] = $option_val;
624 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
625 wp_send_json( $option_val );
626 } else {
627 $home_settings['activate_ma'] = 'no';
628 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
629 wp_send_json( 'disabled' );
630 }
631 }
632
633 /** Ajax module to change activate email option */
634 public static function ajax_activate_email_change() {
635 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
636 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
637 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
638 $home_settings['activate_email'] = $option_val;
639 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
640 wp_send_json( $option_val );
641 }
642
643 /** Ajax module to change sender detail */
644 public static function ajax_sender_change() {
645 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
646 $sender_id = isset( $_POST['sender'] ) ? sanitize_text_field( wp_unslash( $_POST['sender'] ) ) : ''; // sender id.
647 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
648 $home_settings['sender'] = $sender_id;
649 $senders = SIB_API_Manager::get_sender_lists();
650 foreach ( $senders as $sender ) {
651 if ( $sender['id'] == $sender_id ) {
652 $home_settings['from_name'] = $sender['from_name'];
653 $home_settings['from_email'] = $sender['from_email'];
654 }
655 }
656 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
657 wp_send_json( 'success' );
658 }
659
660 /** Ajax module for send a test email */
661 public static function ajax_send_email() {
662 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
663
664 $subject = __( '[Brevo SMTP] test email', 'mailin' );
665 // Get sender info.
666 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
667 if ( isset( $home_settings['sender'] ) ) {
668 $fromname = $home_settings['from_name'];
669 $from_email = $home_settings['from_email'];
670 } else {
671 $from_email = __( 'no-reply@' . parse_url(get_site_url(), PHP_URL_HOST), 'mailin' );
672 $fromname = __( 'Brevo', 'mailin' );
673 }
674
675 $from = array( $from_email, $fromname );
676 $email_templates = SIB_API_Manager::get_email_template( 'test' );
677
678 $html = $email_templates['html_content'];
679
680 $html = str_replace( '{title}', $subject, $html );
681
682 $mailin = new SendinblueApiClient();
683
684 $data = [
685 'sender' => [
686 'name' => $fromname,
687 'email' => $from_email,
688 ],
689 'replyTo' => [
690 'email' => $from_email,
691 ],
692 'to' => [
693 [
694 'email' => sanitize_email($_POST['email'])
695 ]
696 ],
697 'subject' => $subject,
698 'htmlContent' => $html
699 ];
700 $mailin->sendEmail( $data );
701
702 wp_send_json( 'success' );
703 }
704
705 /** Ajax module for remove all transient value */
706 public static function ajax_remove_cache() {
707 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
708 wp_send_json( 'success' );
709 }
710
711 /** Ajax module for sync wp users to contact list */
712 public static function ajax_sync_users() {
713 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
714
715 // phpcs:ignore
716 $postData = isset( $_POST['data'] ) ? $_POST['data'] : array();
717
718 if ( ! isset( $postData['sync_role'] ) ) {
719 wp_send_json(
720 array(
721 'code' => 'empty_role',
722 'message' => __( 'Please select a user role.','mailin' ),
723 )
724 );}
725 if ( isset( $postData['errAttr'] ) ) {
726 wp_send_json(
727 array(
728 'code' => 'attr_duplicated',
729 'message' => sprintf( esc_attr__( 'The attribute %s is duplicated. You can select one at a time.','mailin' ), '<b>' . esc_html($postData['errAttr']) . '</b>' ),
730 )
731 );}
732
733 $roles = (array) $postData['sync_role']; // array or string.
734 $listIDs = array_map('intval', (array) $postData['list_id']);
735
736 unset( $postData['sync_role'] );
737 unset( $postData['list_id'] );
738
739 $usersData = 'EMAIL';
740 foreach ( $postData as $attrSibName => $attrWP ) {
741 $usersData .= ';' . sanitize_text_field($attrSibName);
742 }
743
744 // sync users to sendinblue.
745 // create body data like csv.
746 // NAME;SURNAME;EMAIL\nName1;Surname1;example1@example.net\nName2;Surname2;example2@example.net.
747 $contentData = '';
748 $usersCount = 0;
749 foreach ( $roles as $role ) {
750 $users = get_users(
751 array(
752 'role' => sanitize_text_field($role),
753 )
754 );
755 if ( empty( $users ) ) {
756 continue;
757 }
758 $usersCount += count($users);
759 foreach ( $users as $user ) {
760 $userId = $user->ID;
761 $user_info = get_userdata( $userId );
762 $userData = $user_info->user_email;
763 foreach ( $postData as $attrSibName => $attrWP ) {
764 if ( $attrWP == 'roles' )
765 {
766 $userData .= ';' . implode( ', ', $user_info->$attrWP ) ;
767 }
768 else {
769 $userData .= ';' . $user_info->$attrWP;
770 }
771
772 }
773 $contentData .= "\n" . strip_tags($userData);
774 }
775 }
776 if ( '' == $contentData ) {
777 wp_send_json(
778 array(
779 'code' => 'empty_users',
780 'message' => __( 'There is not any user in the roles.','mailin' ),
781 )
782 );}
783
784 $usersData .= $contentData;
785 $result = SIB_API_Manager::sync_users( $usersData, $listIDs );
786 update_option('sib_sync_users', $usersCount);
787 wp_send_json( $result );
788 }
789
790 /** Logout process */
791 function logout() {
792 self::processInstallationInfo("logout");
793 $setting = array();
794 update_option( SIB_Manager::MAIN_OPTION_NAME, $setting );
795 delete_option(SIB_Manager::API_KEY_V3_OPTION_NAME);
796
797 $home_settings = array(
798 'activate_email' => 'no',
799 'activate_ma' => 'no',
800 );
801 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
802
803 // remove sync users option.
804 delete_option( 'sib_sync_users' );
805 // remove all transients.
806 SIB_API_Manager::remove_transients();
807
808 // remove all forms.
809 SIB_Forms::removeAllForms();
810 SIB_Forms_Lang::remove_all_trans();
811
812 wp_safe_redirect( add_query_arg( 'page', self::PAGE_ID, admin_url( 'admin.php' ) ) );
813 exit();
814 }
815
816 public static function processInstallationInfo($action)
817 {
818 global $wp_version;
819
820 if($action == "login")
821 {
822 $apiClient = new SendinblueApiClient();
823
824 $params["partnerName"] = "WORDPRESS";
825 $params["active"] = true;
826 $params["plugin_version"] = SendinblueApiClient::PLUGIN_VERSION;
827 if(!empty($wp_version))
828 {
829 $params["shop_version"] = $wp_version;
830 }
831 $params["shop_url"] = get_home_url();
832 $params["created_at"] = gmdate("Y-m-d\TH:i:s\Z");
833 $params["activated_at"] = gmdate("Y-m-d\TH:i:s\Z");
834 $params["type"] = "sib";
835 $response = $apiClient->createInstallationInfo($params);
836 if ( $apiClient->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_CREATED )
837 {
838 if(!empty($response["id"]))
839 {
840 update_option(SIB_Manager::INSTALLATION_ID, $response["id"]);
841 }
842 }
843 }
844 elseif($action == "logout")
845 {
846 $installationId = get_option( SIB_Manager::INSTALLATION_ID );
847 if(!empty($installationId))
848 {
849 $apiClient = new SendinblueApiClient();
850 $params["active"] = false;
851 $params["deactivated_at"] = gmdate("Y-m-d\TH:i:s\Z");
852 $apiClient->updateInstallationInfo($installationId, $params);
853 }
854 }
855 }
856 }
857
858 }
859