PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 2.9.5
Brevo – Email, SMS, Web Push, Chat, and more. v2.9.5
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-campaigns.php 8 years ago page-form.php 7 years ago page-home.php 7 years ago page-lists.php 8 years ago page-scenarios.php 8 years ago page-statistics.php 8 years ago
page-home.php
985 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( __( 'SendinBlue', 'sib_lang' ), __( 'SendinBlue', 'sib_lang' ), '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', 'sib_lang' ), __( 'Home', 'sib_lang' ), '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' === $_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="box-border-box container-fluid">
85 <h2><img id="logo-img" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/logo.png' ); ?>"></h2>
86 <div id="wrap-left" class="box-border-box col-md-9">
87 <?php
88 if ( SIB_Manager::is_done_validation() == true ) {
89 $this->generate_main_content();
90 } else {
91 $this->generate_welcome_content();
92 }
93 ?>
94 </div>
95 <div id="wrap-right-side" class="box-border-box col-md-3">
96 <?php
97 self::generate_side_bar();
98 ?>
99 </div>
100 </div>
101 <?php
102 }
103
104 /** Generate welcome page before validation */
105 function generate_welcome_content() {
106 ?>
107
108 <div id="main-content" class="sib-content">
109 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
110 <div class="panel panel-default row small-content">
111 <div class="page-header">
112 <span style="color: #777777;"><?php esc_attr_e( 'Step', 'sib_lang' ); ?> 1&nbsp;|&nbsp;</span><strong><?php esc_attr_e( 'Create a SendinBlue Account', 'sib_lang' ); ?></strong>
113 </div>
114 <div class="panel-body">
115 <div class="col-md-9 row">
116 <p><?php esc_attr_e( 'By creating a free SendinBlue account, you will be able to send confirmation emails and:', 'sib_lang' ); ?></p>
117 <ul class="sib-home-feature">
118 <li><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Collect your contacts and upload your lists', 'sib_lang' ); ?></li>
119 <li><span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Use SendinBlue SMTP to send your transactional emails', 'sib_lang' ); ?></li>
120 <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', 'sib_lang' ); ?></li>
121 <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', 'sib_lang' ); ?></li>
122 <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', 'sib_lang' ); ?>&nbsp;<a href="https://www.sendinblue.com/features/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><?php esc_attr_e( 'SendinBlue\'s features', 'sib_lang' ); ?></a></li>
123 </ul>
124 <a href="https://www.sendinblue.com/users/signup?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" class="btn btn-primary" target="_blank" style="margin-top: 10px;"><?php esc_attr_e( 'Create an account', 'sib_lang' ); ?></a>
125 </div>
126 </div>
127 </div>
128 <div class="panel panel-default row small-content">
129 <div class="page-header">
130 <span style="color: #777777;"><?php esc_attr_e( 'Step', 'sib_lang' ); ?> 2&nbsp;|&nbsp;</span><strong><?php esc_attr_e( 'Activate your account with your API key', 'sib_lang' ); ?></strong>
131 </div>
132 <div class="panel-body">
133 <div class="col-md-9 row">
134 <div id="success-alert" class="alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'You successfully activate your account.', 'sib_lang' ); ?></div>
135 <input type="hidden" id="general_error" value="<?php esc_attr_e( 'Please input correct information.', 'sib_lang' ); ?>">
136 <input type="hidden" id="curl_no_exist_error" value="<?php esc_attr_e( 'Please install curl on site to use sendinblue plugin.', 'sib_lang' ); ?>">
137 <input type="hidden" id="curl_error" value="<?php esc_attr_e( 'Curl error.', 'sib_lang' ); ?>">
138 <div id="failure-alert" class="alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'Please input correct information.', 'sib_lang' ); ?></div>
139 <p>
140 <?php esc_attr_e( 'Once you have created a SendinBlue account, activate this plugin to send all of your transactional emails via SendinBlue SMTP. SendinBlue optimizes email delivery to ensure emails reach the inbox.', 'sib_lang' ); ?><br>
141 <?php esc_attr_e( 'To activate your plugin, enter your API Access key.', 'sib_lang' ); ?><br>
142 </p>
143 <p>
144 <a href="https://my.sendinblue.com/advanced/apikey/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Get your API key from your account', 'sib_lang' ); ?></a>
145 </p>
146 <p>
147 <div class="col-md-7 row">
148 <p class="col-md-12 row"><input id="sib_access_key" type="text" class="col-md-10" style="margin-top: 10px;" placeholder="<?php esc_attr_e( 'Access Key', 'sib_lang' ); ?>"></p>
149 <p class="col-md-12 row"><button type="button" id="sib_validate_btn" class="col-md-4 btn btn-primary"><span class="sib-spin"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i>&nbsp;&nbsp;</span><?php esc_attr_e( 'Login', 'sib_lang' ); ?></button></p>
150 </div>
151 </p>
152 </div>
153 </div>
154 </div>
155 </div>
156 <?php
157 }
158
159 /** Generate main home page after validation */
160 function generate_main_content() {
161 $total_subscribers = SIB_API_Manager::get_totalusers();
162
163 // get campaigns.
164 $campaign_stat = SIB_API_Manager::get_campaign_stats();
165
166 // display account info.
167 $account_settings = SIB_API_Manager::get_account_info();
168 $account_email = isset( $account_settings['account_email'] ) ? $account_settings['account_email'] : '';
169 $account_user_name = isset( $account_settings['account_user_name'] ) ? $account_settings['account_user_name'] : '';
170 $account_data = isset( $account_settings['account_data'] ) ? $account_settings['account_data'] : '';
171 // check smtp available.
172 $smtp_status = SIB_API_Manager::get_smtp_status();
173
174 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
175 // for upgrade to 2.6.0 from old version.
176 if ( ! isset( $home_settings['activate_ma'] ) ) {
177 $home_settings['activate_ma'] = 'no';
178 }
179 // set default sender info.
180 $senders = SIB_API_Manager::get_sender_lists();
181 if ( ! isset( $home_settings['sender'] ) && SIB_Manager::is_done_validation() && is_array( $senders ) ) {
182 $home_settings['sender'] = $senders[0]['id'];
183 $home_settings['from_name'] = $senders[0]['from_name'];
184 $home_settings['from_email'] = $senders[0]['from_email'];
185 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
186 }
187
188 // Users Sync part.
189 $currentUsers = count_users();
190 $isSynced = get_option( 'sib_sync_users', '0' );
191 $isEnableSync = '0';
192 if ( $isSynced != $currentUsers ) {
193 $isEnableSync = '1';
194 /* translators: %s: total users */
195 $desc = sprintf( esc_attr__( 'You have %s existing users. Do you want to add them to SendinBlue?', 'sib_lang' ), $currentUsers['total_users'] );
196 } else {
197 $desc = esc_attr__( 'All your users have been added to a SendinBlue list.','sib_lang' );
198 }
199 self::print_sync_popup();
200 ?>
201
202 <div id="main-content" class="sib-content">
203 <input type="hidden" id="cur_refer_url" value="<?php echo esc_url( add_query_arg( array( 'page' => 'sib_page_home' ), admin_url( 'admin.php' ) ) ); ?> ">
204 <!-- Account Info -->
205 <div class="panel panel-default row small-content">
206 <div class="page-header">
207 <strong><?php esc_attr_e( 'My Account', 'sib_lang' ); ?></strong>
208 </div>
209 <div class="panel-body">
210 <span class="col-md-12"><b><?php esc_attr_e( 'You are currently logged in as : ', 'sib_lang' ); ?></b></span>
211 <div class="col-md-8 row" style="margin-bottom: 10px;">
212 <p class="col-md-12" style="margin-top: 5px;">
213 <?php echo esc_attr( $account_user_name ); ?>&nbsp;-&nbsp;<?php echo esc_attr( $account_email ); ?><br>
214 <?php
215 $count = count( $account_data );
216 for ( $i = 0; $i < $count; $i ++ ) {
217 if ( isset($account_data[$i]['plan_type']) )
218 {
219 echo esc_attr( $account_data[ $i ]['plan_type'] ) . ' - ' . esc_attr( $account_data[ $i ]['credits'] ) . ' ' . esc_attr__( 'credits', 'sib_lang' ) . '<br>';
220 }
221 }
222 ?>
223 <a 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', 'sib_lang' ); ?></a>
224 </p>
225 </div>
226
227 <span class="col-md-12"><b><?php esc_attr_e( 'Contacts', 'sib_lang' ); ?></b></span>
228 <div class="col-md-12 row" style="padding-top: 10px;">
229 <div class="col-md-6" style="margin-bottom: 10px;">
230 <p style="margin-top: 5px;">
231 <?php echo esc_attr__( 'You have', 'sib_lang' ) . ' <span id="sib_total_contacts">' . esc_attr( $total_subscribers ) . '</span> ' . esc_attr__( 'contacts.', 'sib_lang' ); ?><br>
232 <a id="sib_list_link" href="https://my.sendinblue.com/users/list/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Access to the list of all my contacts', 'sib_lang' ); ?></a>
233 </p>
234 </div>
235
236 <div class="col-md-6 row" style="margin-bottom: 10px;">
237 <p class="col-md-8" style="margin-top: 5px;">
238 <b><?php echo esc_attr__( 'Users Synchronisation', 'sib_lang' ); ?></b><br>
239 <?php echo esc_attr( $desc ); ?><br>
240 </p>
241 <div class="col-md-4">
242 <a <?php echo '1' === $isEnableSync ? '' : 'disabled'; ?> id="sib-sync-btn" class="btn btn-primary" style="margin-top: 28px; " name="<?php echo esc_attr__( 'Users Synchronisation', 'sib_lang' ); ?>" href="#"><?php esc_attr_e( 'Sync my users', 'sib_lang' ); ?></a>
243 </div>
244
245 </div>
246 </div>
247
248 <span class="col-md-12"><b><?php esc_attr_e( 'Campaigns', 'sib_lang' ); ?></b></span>
249 <div class="col-md-12 row" style="padding-top: 10px;">
250 <div class="col-md-4">
251 <span style="line-height: 200%;">
252 <span class="glyphicon glyphicon-envelope"></span>
253 <?php esc_attr_e( 'Email Campaigns', 'sib_lang' ); ?>
254 </span>
255 <div class="list-group" id="list-group-email-campaign">
256 <a class="list-group-item" href="
257 <?php
258 echo esc_url(
259 add_query_arg(
260 array(
261 'page' => 'sib_page_campaigns',
262 'sort' => 'sent_c',
263 ), admin_url( 'admin.php' )
264 )
265 );
266 ?>
267 ">
268 <span class="badge"><?php echo esc_attr( $campaign_stat['classic']['Sent'] ); ?></span>
269 <span class="glyphicon glyphicon-send"></span>
270 <?php esc_attr_e( 'Sent', 'sib_lang' ); ?>
271 </a>
272 <a class="list-group-item" href="
273 <?php
274 echo esc_url(
275 add_query_arg(
276 array(
277 'page' => 'sib_page_campaigns',
278 'sort' => 'draft_c',
279 ), admin_url( 'admin.php' )
280 )
281 );
282 ?>
283 ">
284 <span class="badge"><?php echo esc_attr( $campaign_stat['classic']['Draft'] ); ?></span>
285 <span class="glyphicon glyphicon-edit"></span>
286 <?php esc_attr_e( 'Draft', 'sib_lang' ); ?>
287 </a>
288 <a class="list-group-item" href="
289 <?php
290 echo esc_url(
291 add_query_arg(
292 array(
293 'page' => 'sib_page_campaigns',
294 'sort' => 'submitted_c',
295 ), admin_url( 'admin.php' )
296 )
297 );
298 ?>
299 ">
300 <span class="badge"><?php echo esc_attr( $campaign_stat['classic']['Queued'] ); ?></span>
301 <span class="glyphicon glyphicon-dashboard"></span>
302 <?php esc_attr_e( 'Scheduled', 'sib_lang' ); ?>
303 </a>
304 </div>
305 </div>
306 <div class="col-md-4">
307 <span style="line-height: 200%;">
308 <span class="glyphicon glyphicon-phone"></span>
309 <?php esc_attr_e( 'SMS Campaigns', 'sib_lang' ); ?>
310 </span>
311 <div class="list-group" id="list-group-email-campaign">
312 <a class="list-group-item" href="
313 <?php
314 echo esc_url(
315 add_query_arg(
316 array(
317 'page' => 'sib_page_campaigns',
318 'sort' => 'sent_s',
319 ), admin_url( 'admin.php' )
320 )
321 );
322 ?>
323 ">
324 <span class="badge"><?php echo esc_attr( $campaign_stat['sms']['Sent'] ); ?></span>
325 <span class="glyphicon glyphicon-send"></span>
326 <?php esc_attr_e( 'Sent', 'sib_lang' ); ?>
327 </a>
328 <a class="list-group-item" href="
329 <?php
330 echo esc_url(
331 add_query_arg(
332 array(
333 'page' => 'sib_page_campaigns',
334 'sort' => 'draft_s',
335 ), admin_url( 'admin.php' )
336 )
337 );
338 ?>
339 ">
340 <span class="badge"><?php echo esc_attr( $campaign_stat['sms']['Draft'] ); ?></span>
341 <span class="glyphicon glyphicon-edit"></span>
342 <?php esc_attr_e( 'Draft', 'sib_lang' ); ?>
343 </a>
344 <a class="list-group-item" href="
345 <?php
346 echo esc_url(
347 add_query_arg(
348 array(
349 'page' => 'sib_page_campaigns',
350 'sort' => 'submitted_s',
351 ), admin_url( 'admin.php' )
352 )
353 );
354 ?>
355 ">
356 <span class="badge"><?php echo esc_attr( $campaign_stat['sms']['Queued'] ); ?></span>
357 <span class="glyphicon glyphicon-dashboard"></span>
358 <?php esc_attr_e( 'Scheduled', 'sib_lang' ); ?>
359 </a>
360 </div>
361 </div>
362 <div class="col-md-4">
363 <span style="line-height: 200%;">
364 <span class="glyphicon glyphicon-play-circle"></span>
365 <?php esc_attr_e( 'Trigger Marketing', 'sib_lang' ); ?>
366 </span>
367 <div class="list-group" id="list-group-email-campaign">
368 <a class="list-group-item" href="
369 <?php
370 echo esc_url(
371 add_query_arg(
372 array(
373 'page' => 'sib_page_campaigns',
374 'sort' => 'sent_t',
375 ), admin_url( 'admin.php' )
376 )
377 );
378 ?>
379 ">
380 <span class="badge"><?php echo esc_attr( $campaign_stat['trigger']['Sent'] ); ?></span>
381 <span class="glyphicon glyphicon-send"></span>
382 <?php esc_attr_e( 'Sent', 'sib_lang' ); ?>
383 </a>
384 <a class="list-group-item" href="
385 <?php
386 echo esc_url(
387 add_query_arg(
388 array(
389 'page' => 'sib_page_campaigns',
390 'sort' => 'draft_t',
391 ), admin_url( 'admin.php' )
392 )
393 );
394 ?>
395 ">
396 <span class="badge"><?php echo esc_attr( $campaign_stat['trigger']['Draft'] ); ?></span>
397 <span class="glyphicon glyphicon-edit"></span>
398 <?php esc_attr_e( 'Draft', 'sib_lang' ); ?>
399 </a>
400 <a class="list-group-item" href="
401 <?php
402 echo esc_url(
403 add_query_arg(
404 array(
405 'page' => 'sib_page_campaigns',
406 'sort' => 'submitted_t',
407 ), admin_url( 'admin.php' )
408 )
409 );
410 ?>
411 ">
412 <span class="badge"><?php echo esc_attr( $campaign_stat['trigger']['Queued'] ); ?></span>
413 <span class="glyphicon glyphicon-dashboard"></span>
414 <?php esc_attr_e( 'Scheduled', 'sib_lang' ); ?>
415 </a>
416 </div>
417 </div>
418 </div>
419 </div>
420 </div>
421 <!-- Transactional Email -->
422 <div class="panel panel-default row small-content">
423 <div class="page-header">
424 <strong><?php esc_attr_e( 'Transactional emails', 'sib_lang' ); ?></strong>
425 </div>
426 <div class="panel-body">
427 <?php
428 if ( 'disabled' == $smtp_status ) :
429 ?>
430 <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 SendinBlue SMTP account is not active. Please send an email to contact@sendinblue.com in order to ask for SMTP account activation', 'sib_lang' ); ?></div>
431 <?php
432 endif;
433 ?>
434 <div id="success-alert" class="col-md-12 sib_alert alert alert-success" role="alert" style="display: none;"><?php esc_attr_e( 'Mail Sent.', 'sib_lang' ); ?></div>
435 <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.', 'sib_lang' ); ?></div>
436 <div class="row">
437 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate email through SendinBlue', 'sib_lang' ); ?></p>
438 <div class="col-md-3">
439 <label class="col-md-6"><input type="radio" name="activate_email" id="activate_email_radio_yes" value="yes"
440 <?php
441 checked( $home_settings['activate_email'], 'yes' );
442 if ( 'disabled' === $smtp_status ) {
443 echo ' disabled';
444 }
445 ?>
446 >&nbsp;Yes</label>
447 <label class="col-md-6"><input type="radio" name="activate_email" id="activate_email_radio_no" value="no" <?php checked( $home_settings['activate_email'], 'no' ); ?>>&nbsp;No</label>
448 </div>
449 <div class="col-md-5">
450 <small style="font-style: italic;"><?php esc_attr_e( 'Choose "Yes" if you want to use SendinBlue SMTP to send transactional emails', 'sib_lang' ); ?></small>
451 </div>
452 </div>
453 <div class="row" id="email_send_field"
454 <?php
455 if ( 'yes' !== $home_settings['activate_email'] ) {
456 echo 'style="display:none;"';
457 }
458 ?>
459 >
460 <div class="row" style="margin-left: 0px;margin-bottom: 10px;">
461 <p class="col-md-4 text-left"><?php esc_attr_e( 'Choose your sender', 'sib_lang' ); ?></p>
462 <div class="col-md-3">
463 <select id="sender_list" class="col-md-12">
464 <?php
465 $senders = SIB_API_Manager::get_sender_lists();
466 foreach ( $senders as $sender ) {
467 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>';
468 }
469 ?>
470 </select>
471 </div>
472 <div class="col-md-5">
473 <a href="https://my.sendinblue.com/users/settings/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" style="font-style: italic;" target="_blank" ><i class="fa fa-angle-right"></i>&nbsp;<?php esc_attr_e( 'Create a new sender', 'sib_lang' ); ?></a>
474 </div>
475 </div>
476 <div class="row" style="margin-left: 0px;">
477 <p class="col-md-4 text-left"><?php esc_attr_e( 'Enter email to send a test', 'sib_lang' ); ?></p>
478 <div class="col-md-3">
479 <input id="activate_email" type="email" class="col-md-12">
480 <button type="button" id="send_email_btn" class="col-md-12 btn btn-primary"><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', 'sib_lang' ); ?></button>
481 </div>
482 <div class="col-md-5">
483 <small style="font-style: italic;"><?php esc_attr_e( 'Select here the email address you want to send a test email to.', 'sib_lang' ); ?></small>
484 </div>
485 </div>
486 </div>
487 </div>
488 </div>
489 <!-- Marketing Automation -->
490 <div class="panel panel-default row small-content">
491 <div class="page-header">
492 <strong><?php esc_attr_e( 'Automation', 'sib_lang' ); ?></strong>
493 </div>
494 <div class="panel-body">
495 <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.', 'sib_lang' ); ?></div>
496 <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', 'sib_lang' ); ?></div>
497 <div class="sib-ma-alert sib-ma-disabled alert alert-danger" role="alert" style="display: none;"><?php esc_attr_e( 'To activate Marketing Automation (beta), please go to your SendinBlue\'s account or contact us at contact@sendinblue.com', 'sib_lang' ); ?></div>
498 <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', 'sib_lang' ); ?>">
499 <div class="row">
500 <p class="col-md-4 text-left"><?php esc_attr_e( 'Activate Marketing Automation through SendinBlue', 'sib_lang' ); ?></p>
501 <div class="col-md-3">
502 <label class="col-md-6"><input type="radio" name="activate_ma" id="activate_ma_radio_yes" value="yes"
503 <?php
504 checked( $home_settings['activate_ma'], 'yes' );
505 ?>
506 >&nbsp;Yes</label>
507 <label class="col-md-6"><input type="radio" name="activate_ma" id="activate_ma_radio_no" value="no" <?php checked( $home_settings['activate_ma'], 'no' ); ?>>&nbsp;No</label>
508 </div>
509 <div class="col-md-5">
510 <small style="font-style: italic;"><?php esc_attr_e( 'Choose "Yes" if you want to use SendinBlue Automation to track your website activity', 'sib_lang' ); ?></small>
511 </div>
512 </div>
513 <div class="row" style="">
514 <p class="col-md-4 text-left" style="font-size: 13px; font-style: italic;"><?php printf( esc_attr__( '%1$s Explore our resource %2$s to learn more about SendinBlue Automation', 'sib_lang' ), '<a href="https://help.sendinblue.com/hc/en-us/articles/208775609" target="_blank">', '</a>' ); ?></p>
515 <div class="col-md-3">
516 <button type="button" id="validate_ma_btn" class="col-md-12 btn btn-primary"><span class="sib-spin"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i>&nbsp;&nbsp;</span><?php esc_attr_e( 'Activate', 'sib_lang' ); ?></button>
517 </div>
518 <div class="col-md-5">
519 </div>
520 </div>
521 </div>
522 </div>
523
524 </div>
525 <?php
526 }
527
528 /**
529 * Generate a language box on the plugin admin page.
530 */
531 public static function generate_side_bar() {
532 do_action( 'sib_language_sidebar' );
533 ?>
534
535 <div class="panel panel-default text-left box-border-box small-content">
536 <div class="panel-heading"><strong><?php esc_attr_e( 'About SendinBlue', 'sib_lang' ); ?></strong></div>
537 <div class="panel-body">
538 <p><?php esc_attr_e( 'SendinBlue is an online software that helps you build and grow relationships through marketing and transactional emails, marketing automation, and text messages.', 'sib_lang' ); ?></p>
539 <ul class="sib-widget-menu">
540 <li>
541 <a href="https://www.sendinblue.com/about/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Who we are', 'sib_lang' ); ?></a>
542 </li>
543 <li>
544 <a href="https://www.sendinblue.com/pricing/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Pricing', 'sib_lang' ); ?></a>
545 </li>
546 <li>
547 <a href="https://www.sendinblue.com/features/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Features', 'sib_lang' ); ?></a>
548 </li>
549 </ul>
550 </div>
551
552 </div>
553 <div class="panel panel-default text-left box-border-box small-content">
554 <div class="panel-heading"><strong><?php esc_attr_e( 'Need Help?', 'sib_lang' ); ?></strong></div>
555 <div class="panel-body">
556 <p><?php esc_attr_e( 'Do you have a question or need more information?', 'sib_lang' ); ?></p>
557 <ul class="sib-widget-menu">
558 <li><a href="https://help.sendinblue.com/hc/en-us/sections/202171729" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Tutorials', 'sib_lang' ); ?></a></li>
559 <li><a href="https://resources.sendinblue.com/category/faq/?utm_source=wordpress_plugin&utm_medium=plugin&utm_campaign=module_link" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'FAQ', 'sib_lang' ); ?></a></li>
560 </ul>
561 <hr>
562 </div>
563 </div>
564 <div class="panel panel-default text-left box-border-box small-content">
565 <div class="panel-heading"><strong><?php esc_attr_e( 'Recommend this plugin', 'sib_lang' ); ?></strong></div>
566 <div class="panel-body">
567 <p><?php esc_attr_e( 'Let everyone know you like this plugin through a review!' ,'sib_lang' ); ?></p>
568 <ul class="sib-widget-menu">
569 <li><a href="http://wordpress.org/support/view/plugin-reviews/mailin" target="_blank"><i class="fa fa-angle-right"></i> &nbsp;<?php esc_attr_e( 'Recommend the SendinBlue plugin', 'sib_lang' ); ?></a></li>
570 </ul>
571 </div>
572 </div>
573 <?php
574 }
575
576 /**
577 * Get narration script
578 *
579 * @param string $title - pop up title.
580 * @param string $text - pop up content text.
581 */
582 static function get_narration_script( $title, $text ) {
583 ?>
584 <i title="<?php echo esc_attr( $title ); ?>" data-container="body" data-toggle="popover" data-placement="right" data-content="<?php echo esc_attr( $text ); ?>" data-html="true" class="fa fa-question-circle popover-help-form"></i>
585 <?php
586 }
587
588 /** Print disable mode popup */
589 static function print_disable_popup() {
590 ?>
591 <div class="modal fade sib-disable-modal">
592 <div class="modal-dialog">
593 <div class="modal-content">
594 <div class="modal-header">
595 <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>
596 <h4 class="modal-title"><?php esc_attr_e( 'SendinBlue','sib_lang' ); ?></h4>
597 </div>
598 <div class="modal-body" style="padding: 30px;">
599 <p>
600 <?php esc_attr_e( 'You are currently not logged in. Create an account or log in to benefit from all of SendinBlue\'s features an your WordPress site.', 'sib_lang' ); ?>
601 </p>
602 <ul>
603 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Collect and manage your contacts', 'sib_lang' ); ?></li>
604 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Send transactional emails via SMTP or API', 'sib_lang' ); ?></li>
605 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Real time statistics and email tracking', 'sib_lang' ); ?></li>
606 <li> <span class="glyphicon glyphicon-ok" style="font-size: 12px;"></span>&nbsp;&nbsp;<?php esc_attr_e( 'Edit and send email marketing', 'sib_lang' ); ?></li>
607 </ul>
608 <div class="row" style="margin-top: 40px;">
609 <div class="col-md-6">
610 <a href="https://www.sendinblue.com/users/login/" target="_blank"><i><?php esc_attr_e( 'Have an account?', 'sib_lang' ); ?></i></a>
611 </div>
612 <div class="col-md-6">
613 <a href="https://www.sendinblue.com/users/signup/" target="_blank" class="btn btn-default"><i class="fa fa-angle-double-right"></i>&nbsp;<?php esc_attr_e( 'Free Subscribe Now', 'sib_lang' ); ?>&nbsp;<i class="fa fa-angle-double-left"></i></a>
614 </div>
615 </div>
616 </div>
617
618 </div><!-- /.modal-content -->
619 </div><!-- /.modal-dialog -->
620 </div><!-- /.modal -->
621 <button id="sib-disable-popup" class="btn btn-primary" data-toggle="modal" data-target=".sib-disable-modal" style="display: none;">sss</button>
622 <script>
623 jQuery(document).ready(function() {
624 jQuery('.sib-disable-modal').modal();
625
626 jQuery('.sib-disable-modal').on('hidden.bs.modal', function() {
627 window.location.href = '<?php echo esc_url( add_query_arg( 'page', 'sib_page_home', admin_url( 'admin.php' ) ) ); ?>';
628 });
629 });
630
631 </script>
632
633 <?php
634 }
635
636 /** Print user sync popup */
637 static function print_sync_popup() {
638 ?>
639 <div class="modal fade sib-sync-modal">
640 <div class="modal-dialog">
641 <div class="modal-content">
642 <div class="modal-header">
643 <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>
644 <h4 class="modal-title"><?php esc_attr_e( 'Customers Synchronisation','sib_lang' ); ?></h4>
645 </div>
646 <div class="modal-body sync-modal-body" style="padding: 10px;">
647 <div id="sync-failure" class="sib_alert alert alert-danger" style="margin-bottom: 0px;display: none;"></div>
648 <form id="sib-sync-form">
649 <!-- roles -->
650 <div class="row sync-row" style="margin-top: 0;">
651 <b><p><?php esc_attr_e( 'Roles to sync', 'sib_lang' ); ?></p></b>
652 <?php foreach ( wp_roles()->roles as $role_name => $role_info ) : ?>
653 <div class="col-md-6">
654 <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 echo esc_attr( $role_info['name'] ); ?></label></span>
655 </div>
656 <?php endforeach; ?>
657 </div>
658 <!-- lists -->
659 <?php $lists = SIB_API_Manager::get_lists(); ?>
660 <div class="row sync-row">
661 <b><p><?php esc_attr_e( 'Sync Lists', 'sib_lang' ); ?></p></b>
662 <div class="col-md-6">
663 <p><?php esc_attr_e( 'Choose the Sendinblue list in which you want to add your existing customers:', 'sib_lang' ); ?></p>
664 </div>
665 <div class="col-md-6">
666 <select data-placeholder="Please select the list" id="sib_select_list" name="list_id" multiple="true">
667 <?php foreach ( $lists as $list ) : ?>
668 <option value="<?php echo esc_attr( $list['id'] ); ?>"><?php echo esc_attr( $list['name'] ); ?></option>
669 <?php endforeach; ?>
670 </select>
671 </div>
672 </div>
673 <!-- Match Attributes -->
674 <?php
675 // available WordPress attributes.
676 $wpAttrs = array(
677 'first_name' => __( 'First Name','sib_lang' ),
678 'last_name' => __( 'Last Name','sib_lang' ),
679 'user_url' => __( 'Website URL','sib_lang' ),
680 'roles' => __( 'User Role','sib_lang' ),
681 );
682 // available sendinblue attributes.
683 $sibAllAttrs = SIB_API_Manager::get_attributes();
684 $sibAttrs = $sibAllAttrs['attributes']['normal_attributes'];
685 ?>
686 <div class="row sync-row" id="sync-attr-area">
687 <b><p><?php esc_attr_e( 'Match Attributes', 'sib_lang' ); ?></p></b>
688 <div class="col-md-11" style="padding: 5px;border-bottom: dotted 1px #dedede;">
689 <div class="col-md-6">
690 <p><?php esc_attr_e( 'WordPress Users Attributes', 'sib_lang' ); ?></p>
691 </div>
692 <div class="col-md-6">
693 <p><?php esc_attr_e( 'SendinBlue Contact Attributes', 'sib_lang' ); ?></p>
694 </div>
695 </div>
696
697 <div class="sync-attr-line">
698 <div class="col-md-11 sync-attr" style="padding: 5px;border-bottom: dotted 1px #dedede;">
699 <div class="col-md-5">
700 <select class="sync-wp-attr" name="" style="width: 100%;">
701 <?php foreach ( $wpAttrs as $id => $label ) : ?>
702 <option value="<?php echo esc_attr( $id ); ?>"><?php echo esc_attr( $label ); ?></option>
703 <?php endforeach; ?>
704 </select>
705 </div>
706 <div class="col-md-1" style="padding-left: 10px;padding-top: 3px;"><span class="dashicons dashicons-leftright"></span></div>
707 <div class="col-md-5">
708 <select class="sync-sib-attr" name="" style="width: 100%;">
709 <?php foreach ( $sibAttrs as $attr ) : ?>
710 <option value="<?php echo esc_attr( $attr['name'] ); ?>"><?php echo esc_attr( $attr['name'] ); ?></option>
711 <?php endforeach; ?>
712 </select>
713 </div>
714 <div class="col-md-1" style="padding-top: 3px;">
715 <a href="javascript:void(0)" class="sync-attr-dismiss" style="display: none;"><span class="dashicons dashicons-dismiss"></span></a>
716 </div>
717 <input type="hidden" class="sync-match" name="<?php echo esc_attr( $sibAttrs[0]['name'] ); ?>" value="first_name">
718 </div>
719 </div>
720 <div class="col-md-1" style="padding-top: 9px;">
721 <a href="javascript:void(0)" class="sync-attr-plus"><span class="dashicons dashicons-plus-alt "></span></a>
722 </div>
723 </div>
724 <!-- Apply button -->
725 <div class="row" style="">
726 <a href="javascript:void(0)" id="sib_sync_users_btn" class="btn btn-primary" style="float: right;"><?php esc_attr_e( 'Apply', 'sib_lang' ); ?></a>
727 </div>
728 </form>
729 </div>
730 </div><!-- /.modal-content -->
731 </div><!-- /.modal-dialog -->
732 </div><!-- /.modal -->
733 <?php
734 }
735
736 /** Ajax module for validation (Home - welcome) */
737 public static function ajax_validation_process() {
738 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
739 $access_key = isset( $_POST['access_key'] ) ? sanitize_text_field( wp_unslash( $_POST['access_key'] ) ) : '';
740 try {
741 $mailin = new Mailin( SIB_Manager::SENDINBLUE_API_URL, $access_key );
742 } catch ( Exception $e ) {
743 if ( $e->getMessage() == 'Mailin requires CURL module' ) {
744 wp_send_json( 'curl_no_installed' );
745 } else {
746 wp_send_json( 'curl_error' );
747 }
748 }
749
750 $response = $mailin->get_access_tokens();
751 if ( is_array( $response ) ) {
752 if ( 'success' == $response['code'] ) {
753
754 // store api info.
755 $settings = array(
756 'access_key' => $access_key,
757 );
758 update_option( SIB_Manager::MAIN_OPTION_NAME, $settings );
759
760 SIB_Manager::$access_key = $access_key;
761
762 $access_token = $response['data']['access_token'];
763 $token_settings = array(
764 'access_token' => $access_token,
765 );
766 update_option( SIB_Manager::ACCESS_TOKEN_OPTION_NAME, $token_settings );
767
768 // get default language at SendinBlue.
769 $mailin->partnerWordpress();
770
771 // create tables for users and forms.
772 SIB_Model_Users::createTable();
773 SIB_Forms::createTable(); // create default form also
774 // If the client don't have attributes regarding Double OptIn then we will create these.
775 SIB_API_Manager::create_default_dopt();
776
777 wp_send_json( 'success' );
778 } else {
779 wp_send_json( $response['code'] );
780 }
781 } else {
782 wp_send_json( 'fail' );
783 }
784 }
785
786 /** Ajax module to change activate marketing automation option */
787 public static function ajax_validate_ma() {
788 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
789 $main_settings = get_option( SIB_Manager::MAIN_OPTION_NAME );
790 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
791 $ma_key = $main_settings['ma_key'];
792 if ( '' != $ma_key ) {
793 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
794 $home_settings['activate_ma'] = $option_val;
795 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
796 wp_send_json( $option_val );
797 } else {
798 $home_settings['activate_ma'] = 'no';
799 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
800 wp_send_json( 'disabled' );
801 }
802 }
803
804 /** Ajax module to change activate email option */
805 public static function ajax_activate_email_change() {
806 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
807 $option_val = isset( $_POST['option_val'] ) ? sanitize_text_field( wp_unslash( $_POST['option_val'] ) ) : 'no';
808 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
809 $home_settings['activate_email'] = $option_val;
810 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
811 wp_send_json( $option_val );
812 }
813
814 /** Ajax module to change sender detail */
815 public static function ajax_sender_change() {
816 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
817 $sender_id = isset( $_POST['sender'] ) ? sanitize_text_field( wp_unslash( $_POST['sender'] ) ) : ''; // sender id.
818 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
819 $home_settings['sender'] = $sender_id;
820 $senders = SIB_API_Manager::get_sender_lists();
821 foreach ( $senders as $sender ) {
822 if ( $sender['id'] == $sender_id ) {
823 $home_settings['from_name'] = $sender['from_name'];
824 $home_settings['from_email'] = $sender['from_email'];
825 }
826 }
827 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
828 wp_send_json( 'success' );
829 }
830
831 /** Ajax module for send a test email */
832 public static function ajax_send_email() {
833 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
834 $to = array(
835 $_POST['email'] => '',
836 );
837
838 $subject = __( '[SendinBlue SMTP] test email', 'sib_lang' );
839 // Get sender info.
840 $home_settings = get_option( SIB_Manager::HOME_OPTION_NAME );
841 if ( isset( $home_settings['sender'] ) ) {
842 $fromname = $home_settings['from_name'];
843 $from_email = $home_settings['from_email'];
844 } else {
845 $from_email = __( 'no-reply@sendinblue.com', 'sib_lang' );
846 $fromname = __( 'SendinBlue', 'sib_lang' );
847 }
848
849 $from = array( $from_email, $fromname );
850 $email_templates = SIB_API_Manager::get_email_template( 'test' );
851
852 $html = $email_templates['html_content'];
853
854 $html = str_replace( '{title}', $subject, $html );
855
856 $mailin = new Mailin( SIB_Manager::SENDINBLUE_API_URL, SIB_Manager::$access_key );
857
858 $headers = array(
859 'Content-Type' => 'text/html;charset=iso-8859-1',
860 'X-Mailin-tag' => 'Wordpress Mailin Test',
861 );
862 $data = array(
863 'to' => $to,
864 'subject' => $subject,
865 'from' => $from,
866 'html' => $html,
867 'headers' => $headers,
868 );
869 $mailin->send_email( $data );
870
871 wp_send_json( 'success' );
872 }
873
874 /** Ajax module for remove all transient value */
875 public static function ajax_remove_cache() {
876 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
877 SIB_API_Manager::remove_transients();
878 wp_send_json( 'success' );
879 }
880
881 /** Ajax module for sync wp users to contact list */
882 public static function ajax_sync_users() {
883 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
884 $postData = isset( $_POST['data'] ) ? $_POST['data'] : array();
885 if ( ! isset( $postData['sync_role'] ) ) {
886 wp_send_json(
887 array(
888 'code' => 'empty_role',
889 'message' => __( 'Please select a user role.','sib_lang' ),
890 )
891 );}
892 if ( isset( $postData['errAttr'] ) ) {
893 wp_send_json(
894 array(
895 'code' => 'attr_duplicated',
896 'message' => sprintf( esc_attr__( 'The attribute %s is duplicated. You can select one at a time.','sib_lang' ), '<b>' . $postData['errAttr'] . '</b>' ),
897 )
898 );}
899
900 $roles = (array) $postData['sync_role']; // array or string.
901 $listIDs = (array) $postData['list_id'];
902
903 unset( $postData['sync_role'] );
904 unset( $postData['list_id'] );
905
906 $usersData = 'EMAIL';
907 foreach ( $postData as $attrSibName => $attrWP ) {
908 $usersData .= ';' . $attrSibName;
909 }
910
911 // sync users to sendinblue.
912 // create body data like csv.
913 // NAME;SURNAME;EMAIL\nName1;Surname1;example1@example.net\nName2;Surname2;example2@example.net.
914 $contentData = '';
915 foreach ( $roles as $role ) {
916 $users = get_users(
917 array(
918 'role' => $role,
919 )
920 );
921 if ( empty( $users ) ) {
922 continue;
923 }
924 foreach ( $users as $user ) {
925 $userId = $user->ID;
926 $user_info = get_userdata( $userId );
927 $userData = $user_info->user_email;
928 foreach ( $postData as $attrSibName => $attrWP ) {
929 if ( $attrWP == 'roles' )
930 {
931 $userData .= ';' . implode( ', ', $user_info->$attrWP ) ;
932 }
933 else {
934 $userData .= ';' . $user_info->$attrWP;
935 }
936
937 }
938 $contentData .= "\n" . $userData;
939 }
940 }
941 if ( '' == $contentData ) {
942 wp_send_json(
943 array(
944 'code' => 'empty_users',
945 'message' => __( 'There is not any user in the roles.','sib_lang' ),
946 )
947 );}
948
949 $usersData .= $contentData;
950 $result = SIB_API_Manager::sync_users( $usersData, $listIDs );
951 $currentUsers = count_users();
952 if ( 'success' == $result['code'] ) {
953 update_option( 'sib_sync_users', $currentUsers );
954 }
955 wp_send_json( $result );
956 }
957
958 /** Logout process */
959 function logout() {
960 $setting = array();
961 update_option( SIB_Manager::MAIN_OPTION_NAME, $setting );
962
963 $home_settings = array(
964 'activate_email' => 'no',
965 'activate_ma' => 'no',
966 );
967 update_option( SIB_Manager::HOME_OPTION_NAME, $home_settings );
968
969 // remove sync users option.
970 delete_option( 'sib_sync_users' );
971 // remove all transients.
972 SIB_API_Manager::remove_transients();
973
974 // remove all forms.
975 SIB_Forms::removeAllForms();
976 SIB_Forms_Lang::remove_all_trans();
977
978 wp_safe_redirect( add_query_arg( 'page', self::PAGE_ID, admin_url( 'admin.php' ) ) );
979 exit();
980 }
981
982 }
983
984 }
985