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