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