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