PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.1.60
Brevo – Email, SMS, Web Push, Chat, and more. v3.1.60
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-form.php
mailin / page Last commit date
index.php 11 years ago page-form.php 3 years ago page-home.php 3 years ago page-scenarios.php 3 years ago page-statistics.php 4 years ago
page-form.php
1113 lines
1 <?php
2 /**
3 * Admin page : dashboard
4 *
5 * @package SIB_Page_Form
6 */
7
8 if ( ! class_exists( 'SIB_Page_Form' ) ) {
9 /**
10 * Page class that handles backend page <i>dashboard ( for admin )</i> with form generation and processing
11 *
12 * @package SIB_Page_Form
13 */
14 class SIB_Page_Form {
15 /** Page slug */
16 const PAGE_ID = 'sib_page_form';
17
18 /**
19 * Page hook
20 *
21 * @var false|string
22 */
23 protected $page_hook;
24
25 /**
26 * Page tabs
27 *
28 * @var mixed
29 */
30 protected $tabs;
31
32 /**
33 * Form ID
34 *
35 * @var string
36 */
37 public $formID;
38
39 /**
40 * Default compliant Note
41 *
42 * @var string
43 */
44 public $defaultComplianceNote;
45
46 /**
47 * Constructs new page object and adds entry to WordPress admin menu
48 */
49 function __construct() {
50 $title = get_bloginfo('name');
51 $this->defaultComplianceNote = sprintf( esc_attr('Your e-mail address is only used to send you our newsletter and information about the activities of %s. You can always use the unsubscribe link included in the newsletter.', 'mailin'), $title);
52 $this->page_hook = add_submenu_page( SIB_Page_Home::PAGE_ID, __( 'Forms', 'mailin' ), __( 'Forms', 'mailin' ), 'manage_options', self::PAGE_ID, array( &$this, 'generate' ) );
53 add_action( 'admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ) );
54 add_action( 'admin_print_styles-' . $this->page_hook, array( $this, 'enqueue_styles' ) );
55 add_action( 'load-' . $this->page_hook, array( &$this, 'init' ) );
56 }
57
58 /**
59 * Init Process
60 */
61 function Init() {
62 SIB_Manager::is_done_validation();
63 $this->forms = new SIB_Forms_List();
64 $this->forms->prepare_items();
65 }
66
67 /**
68 * Enqueue scripts of plugin
69 */
70 function enqueue_scripts() {
71 wp_enqueue_script( 'sib-admin-js' );
72 wp_enqueue_script( 'sib-bootstrap-js' );
73 wp_enqueue_script( 'sib-chosen-js' );
74
75 wp_localize_script(
76 'sib-admin-js', 'ajax_sib_object',
77 array(
78 'ajax_url' => admin_url( 'admin-ajax.php' ),
79 'ajax_nonce' => wp_create_nonce( 'ajax_sib_admin_nonce' ),
80 'compliance_note' => $this->defaultComplianceNote
81 )
82 );
83 wp_localize_script( 'sib-admin-js', 'sib_img_url', array(SIB_Manager::$plugin_url.'/img/flags/') );
84 }
85
86 /**
87 * Enqueue style sheets of plugin
88 */
89 function enqueue_styles() {
90 wp_enqueue_style( 'sib-admin-css' );
91 wp_enqueue_style( 'sib-bootstrap-css' );
92 wp_enqueue_style( 'sib-chosen-css' );
93 wp_enqueue_style( 'sib-fontawesome-css' );
94 wp_enqueue_style( 'thickbox' );
95 }
96
97 /** Generate page script */
98 function generate() {
99 ?>
100 <div id="wrap" class="wrap box-border-box container-fluid">
101 <h1><img id="logo-img" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/logo.png' ); ?>">
102 <?php
103 $return_btn = 'none';
104 if (isset( $_GET['id'] ) ) {
105 $return_btn = 'inline-block';
106 }
107 ?>
108 <a href="<?php echo esc_url( add_query_arg( 'page', self::PAGE_ID, admin_url( 'admin.php' ) ) ); ?>" class="button" style="margin-top: 6px; display: <?php echo esc_attr( $return_btn ); ?>;"><?php esc_attr_e( 'Back to form\'s list' ,'mailin' ); ?></a>
109 </h1>
110 <div class="row">
111 <div id="wrap-left" class="box-border-box col-md-9 ">
112 <input type="hidden" class="sib-dateformat" value="<?php echo esc_attr( 'yyyy-mm-dd' ); ?>">
113 <?php
114 if ( SIB_Manager::is_api_key_set() ) {
115 if ( ( isset( $_GET['action'] ) && 'edit' === sanitize_text_field($_GET['action'] )) || ( isset( $_GET['action'] ) && 'duplicate' === sanitize_text_field($_GET['action'] )) ) {
116 $this->formID = isset( $_GET['id'] ) ? sanitize_text_field( $_GET['id'] ) : 'new';
117 $this->generate_form_edit();
118 } else {
119 $this->generate_forms_page();
120 }
121 } else {
122 $this->generate_welcome_page();
123 }
124 ?>
125 </div>
126 <div id="wrap-right-side" class="box-border-box col-md-3">
127 <?php
128
129 SIB_Page_Home::generate_side_bar();
130 ?>
131 </div>
132 </div>
133 </div>
134 <div id="sib_modal" class="modal fade" role="dialog">
135 <div class="modal-dialog">
136 <div class="modal-content">
137 <div class="modal-header">
138 <button type="button" class="close" data-dismiss="modal">&times;</button>
139 <h4><?php esc_attr_e( 'You are about to change the language', 'mailin' ); ?></h4>
140 </div>
141 <div class="modal-body">
142 <p><?php esc_attr_e( "Please make sure that you've saved all the changes. We will have to reload the page.", 'mailin' ); ?></p>
143 <p><?php esc_attr_e( 'Do you want to continue?', 'mailin' ); ?></p>
144 </div>
145 <div class="modal-footer">
146 <button type="button" class="btn btn-default" id="sib_modal_ok"><?php esc_attr_e( 'Ok', 'mailin' ); ?></button>
147 <button type="button" class="btn btn-default" id="sib_modal_cancel"><?php esc_attr_e( 'Cancel', 'mailin' ); ?></button>
148 </div>
149 </div>
150 </div>
151 </div>
152 <?php
153 }
154 /** Generate forms page */
155 function generate_forms_page() {
156 ?>
157 <div id="main-content" class="sib-content">
158 <div class="card sib-small-content">
159 <div class="card-header"><strong><?php esc_attr_e( 'Forms', 'mailin' ); ?></strong></div>
160
161 <form method="post" class="sib-forms-wrapper" style="padding:20px;min-height: 500px;">
162 <i style="font-size: 13px;"><?php esc_attr_e( "Note: Forms created in Sendinblue plugin for WordPress won't be displayed in Forms section in Sendinblue application", 'mailin' ); ?></i>
163 <?php
164 $this->forms->display();
165 ?>
166 </form>
167 </div>
168 </div>
169 <?php
170 }
171 /** Generate form edit page */
172 function generate_form_edit() {
173 $is_activated_smtp = SIB_API_Manager::get_smtp_status() == 'disabled' ? 0 : 1;
174 $formData = SIB_Forms::getForm( $this->formID );
175 $invisibleCaptcha = '1';
176 if ( ! empty( $formData ) ) {
177 if ( isset( $_GET['action'] ) && 'duplicate' === sanitize_text_field($_GET['action']) ) {
178 $this->formID = 'new';
179 $formData['title'] = '';
180 }
181 if ( 'new' === $this->formID && isset( $_GET['pid'] ) ) {
182 $parent_formData = SIB_Forms::getForm( sanitize_text_field( $_GET['pid'] ) );
183 $formData['title'] = $parent_formData['title'];
184 }
185 if ( ! isset( $formData['gCaptcha'] ) ) {
186 $gCaptcha = '0';
187 }
188 else {
189 if( '0' == $formData['gCaptcha'] ) {
190 $gCaptcha = '0';
191 }
192 else {
193 $gCaptcha = '1';
194 }
195 if ( '3' == $formData['gCaptcha'] ) {
196 $invisibleCaptcha = '0';
197 }
198 else {
199 $invisibleCaptcha = '1';
200 }
201 }
202 if ( ! isset( $formData['termAccept'] ) ) {
203 $formData['termAccept'] = '0';
204 }
205
206 ?>
207 <div id="main-content" class="sib-content">
208 <form action="admin.php" class="" method="post" role="form">
209 <input type="hidden" name="action" value="sib_setting_subscription">
210 <input type="hidden" name="sib_form_id" value="<?php echo esc_attr( $this->formID ) ; ?>">
211 <input type="hidden" id="is_smtp_activated" value="<?php echo esc_attr( $is_activated_smtp ) ; ?>">
212 <?php
213 if ( isset( $_GET['pid'] ) ) {
214 ?>
215 <input type="hidden" name="pid" value="<?php echo esc_attr( $_GET['pid'] ); ?>">
216 <?php
217 $lang = isset( $_GET['lang'] ) ? sanitize_text_field( $_GET['lang'] ) : '';
218 if ( $lang ) { ?>
219 <input type="hidden" name="lang" value="<?php echo esc_attr( $lang ); ?>">
220 <?php
221 }
222 }
223 ?>
224 <?php wp_nonce_field( 'sib_setting_subscription' ); ?>
225 <!-- Subscription form -->
226 <div class="card sib-small-content">
227 <div class="card-header">
228 <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong>&nbsp;<i
229 id="sib_setting_form_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i>
230 </div>
231 <div id="sib_setting_form_body" class="card-body">
232 <div class="row <!--small-content-->">
233 <div style="margin: 12px 0 34px 0px;">
234 <b><?php esc_attr_e( 'Form Name : ', 'mailin' ); ?></b>&nbsp; <input type="text"
235 name="sib_form_name"
236 value="<?php echo esc_attr( $formData['title'] ); ?>"
237 style="width: 60%;"
238 required="required"/>
239 </div>
240 <div class="col-md-6">
241
242 <?php
243 if ( function_exists( 'wp_editor' ) ) {
244 // phpcs:ignore
245 wp_editor(
246 esc_html(stripcslashes($formData['html'])), 'sibformmarkup', array(
247 'tinymce' => false,
248 'media_buttons' => true,
249 'textarea_name' => 'sib_form_html',
250 'textarea_rows' => 15,
251 )
252 );
253 } else {
254 ?>
255 <textarea class="widefat" cols="160" rows="20" id="sibformmarkup"
256 name="sib_form_html"><?php
257 // phpcs:ignore
258 echo esc_html( $formData['html'] ); ?></textarea>
259 <?php
260 }
261 ?>
262 <br>
263
264 <p>
265 <?php
266 esc_attr_e( 'Use the shortcode', 'mailin' );
267 if ( isset( $_GET['pid'] ) ) {
268 $id = sanitize_text_field( $_GET['pid'] );
269 } else {
270 $id = 'new' !== $this->formID ? $this->formID : '';
271 }
272 ?>
273 <i style="background-color: #eee;padding: 3px;">[sibwp_form
274 id=<?php echo esc_attr( $id ); ?>]</i>
275 <?php
276 esc_attr_e( 'inside a post, page or text widget to display your sign-up form.', 'mailin' );
277 ?>
278 <b><?php esc_attr_e( 'Do not copy and paste the above form mark up, that will not work', 'mailin' ); ?></b>
279 </p>
280 <div id="sib-field-form" class="card form-field"
281 style="padding-bottom: 20px;">
282
283 <div class="small-content2"
284 style="margin-top: 15px;">
285 <b><?php esc_attr_e( 'Add a new Field', 'mailin' ); ?></b>&nbsp;
286 <?php SIB_Page_Home::get_narration_script( __( 'Add a New Field', 'mailin' ), __( 'Choose an attribute and add it to the subscription form of your Website', 'mailin' ) ); ?>
287 </div>
288 <div id="sib_sel_attribute_area" class="small-content2"
289 style="margin-top: 20px;">
290 </div>
291 <div id="sib-field-content">
292 <div style="margin-top: 30px;">
293 <div class="sib-attr-normal sib-attr-category small-content2"
294 style="margin-top: 10px;" id="sib_field_label_area">
295 <?php esc_attr_e( 'Label', 'mailin' ); ?>
296 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small>
297 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_label">
298 </div>
299 <div class="sib-attr-normal small-content2"
300 style="margin-top: 10px;" id="sib_field_placeholder_area">
301 <span><?php esc_attr_e( 'Place holder', 'mailin' ); ?>
302 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)
303 </small> </span>
304 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_placeholder">
305 </div>
306 <div class="sib-attr-normal small-content2"
307 style="margin-top: 10px;" id="sib_field_initial_area">
308 <span><?php esc_attr_e( 'Initial value', 'mailin' ); ?>
309 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)
310 </small> </span>
311 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_initial">
312 </div>
313 <div class="sib-attr-other small-content2"
314 style="margin-top: 10px;" id="sib_field_button_text_area">
315 <span><?php esc_attr_e( 'Button Text', 'mailin' ); ?></span>
316 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_button_text">
317 </div>
318 </div>
319 <div style="margin-top: 20px;">
320
321 <div class="sib-attr-normal sib-attr-category small-content2" style="margin-top: 5px;" id="sib_field_required_area">
322 <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_field_required">&nbsp;&nbsp;<?php esc_attr_e( 'Required field ?', 'mailin' ); ?>
323 </label>
324 </div>
325 <div class="sib-attr-category small-content2"
326 style="margin-top: 5px;" id="sib_field_type_area">
327 <label style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type" value="select"
328 checked>&nbsp;<?php esc_attr_e( 'Drop-down List', 'mailin' ); ?>
329 </label>&nbsp;&nbsp;
330 <label style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type"
331 value="radio">&nbsp;<?php esc_attr_e( 'Radio List', 'mailin' ); ?>
332 </label>
333 </div>
334 </div>
335 <div class="small-content2" style="margin-top: 20px;"
336 id="sib_field_add_area">
337 <button type="button" id="sib_add_to_form_btn"
338 class="btn btn-primary sib-add-to-form"><span
339 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
340 </button>&nbsp;&nbsp;
341 <div style="display:none">
342 <input id="getDomain" value="<?php
343 echo plugins_url('mailin/img/flags/') ?>"></input>
344 </div>
345 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
346 </div>
347 <div class="small-content2" style="margin-top: 20px;"
348 id="sib_field_html_area">
349 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
350 <textarea class="col-md-12" style="height: 140px;"
351 id="sib_field_html"></textarea>
352 </div>
353 </div>
354 </div>
355 <!---- multi list per interest ----->
356 <div id="sib-multi-lists" class="card form-field"
357 style="padding-bottom: 20px;">
358
359 <div class="small-content2"
360 style="margin-top: 15px">
361 <b><?php esc_attr_e( 'Add Multi-List Subscription', 'mailin' ); ?></b>&nbsp;
362 <?php SIB_Page_Home::get_narration_script( __( 'Add Multi-List Subscription', 'mailin' ), __( 'Enable your contacts to subscribe to content based on specific interests or preferences. Create a contact list for each interest and allow them to subscribe using this field', 'mailin' ) ); ?>
363 </div>
364 <div id="sib_sel_multi_list_area" class="small-content2"
365 style="margin-top: 20px;">
366 <input type="hidden" id="sib_selected_multi_list_id" value="">
367 <select data-placeholder="<?php esc_attr_e( 'Please select the lists', 'mailin' ); ?>" id="sib_select_multi_list"
368 class="col-md-12 chosen-select" name="multi_list_ids[]" multiple=""
369 tabindex="-1"></select>
370 </div>
371 <div id="sib_multi_list_field" style="display: none;">
372 <div style="margin-top: 30px;">
373 <div class="sib-attr-normal sib-attr-category small-content2"
374 style="margin-top: 10px;" id="sib_multi_field_label_area">
375 <?php esc_attr_e( 'Label', 'mailin' ); ?>
376 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small>
377 <input type="text" class="col-md-12 sib_field_changes" id="sib_multi_field_label">
378 </div>
379 </div>
380 <div style="margin-top: 20px;">
381 <div class="sib-attr-normal sib-attr-category small-content2" style="margin-top: 5px;" id="sib_multi_field_required_area">
382 <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_multi_field_required">&nbsp;&nbsp;<?php esc_attr_e( 'Required field ?', 'mailin' ); ?>
383 </label>
384 </div>
385 </div>
386 <div class="small-content2" style="margin-top: 20px;"
387 id="sib_multi_field_add_area">
388 <button type="button" id="sib_multi_lists_add_form_btn"
389 class="btn btn-primary sib-add-to-form"><span
390 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
391 </button>&nbsp;&nbsp;
392 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
393 </div>
394 <div class="small-content2" style="margin-top: 20px;"
395 id="sib_field_html_area">
396 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
397 <textarea class="col-md-12" style="height: 140px;"
398 id="sib_multi_field_html"></textarea>
399 </div>
400 </div>
401 </div>
402
403 <div id="sib-gdpr-block" class="card form-field" style="padding-bottom: 20px;">
404 <div class="small-content2"
405 style="margin-top: 15px;margin-bottom: 15px;">
406 <b><?php esc_attr_e( 'Compliance Note', 'mailin' ); ?></b>&nbsp;
407 <?php SIB_Page_Home::get_narration_script( __( 'Add compliance note', 'mailin' ), __( 'Create GDPR-compliant subscription forms for collecting email addresses.', 'mailin' ) ); ?>
408 </div>
409 <div class="small-content2" style="margin-top: 0px;">
410 <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="1" ><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin');?></label>
411 <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="0" checked><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin');?></label>
412 </div>
413 <div class="small-content2 sib-gdpr-block-area" style="display: none;">
414 <textarea id="sib_gdpr_text" class="col-md-12" rows="5"><?php echo trim( $this->defaultComplianceNote ); ?></textarea>
415 <label id="set_gdpr_default"><?php esc_attr_e('Reset to Default', 'mailin');?>&nbsp;<i class="fa fa-refresh"></i></label>
416 </div>
417 <div class="small-content2 sib-gdpr-block-btn" style="display: none;">
418 <button type="button" id="sib_add_compliance_note"
419 class="btn btn-primary sib-add-to-form"><span
420 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
421 </button>&nbsp;&nbsp;
422 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
423 </div>
424 </div>
425
426 <!---- end block ------>
427 <div id="sib_form_captcha" class="card form-field"
428 style="padding-bottom: 20px;">
429 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
430 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
431 <b><?php esc_attr_e( 'Add Captcha', 'mailin' ); ?></b>&nbsp;
432 <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'We are using Google reCaptcha for this form. To use Google reCaptcha on this form, you should input site key and secret key.' , 'mailin' ) ); ?>
433 </div>
434 <div class="small-content2" style="margin-top: 0px;">
435 <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="1" <?php checked( $gCaptcha, '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
436 <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="0" <?php checked( $gCaptcha, '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?></label>
437 </div>
438 <div class="small-content2 sib-captcha-key"
439 <?php
440 if ( '1' !== $gCaptcha ) {
441 echo("style='display: none;'");}
442 ?>
443 >
444 <i><?php esc_attr_e( 'Site Key', 'mailin' ); ?></i>&nbsp;
445 <input type="text" class="col-md-12" id="sib_captcha_site" name="sib_captcha_site" value="<?php
446 if ( isset( $formData['gCaptcha_site'] ) && ! empty( $formData['gCaptcha_site'] ) ) {
447 echo esc_attr( $formData['gCaptcha_site'] );
448 } else {
449 echo '';
450 }
451 ?>">
452 </div>
453 <div class="small-content2 sib-captcha-key"
454 <?php
455 if ( '1' !== $gCaptcha ) {
456 echo("style='display: none;'");}
457 ?>
458 >
459 <i><?php esc_attr_e( 'Secret Key', 'mailin' ); ?></i>&nbsp;
460 <input type="text" class="col-md-12" id="sib_captcha_secret" name="sib_captcha_secret" value="<?php
461 if ( isset( $formData['gCaptcha_secret'] ) && ! empty( $formData['gCaptcha_secret'] ) ) {
462 echo esc_attr( $formData['gCaptcha_secret'] );
463 } else {
464 echo '';
465 }
466 ?>">
467 </div>
468 <div class="small-content2 sib-captcha-key"
469 <?php
470 if ( '1' !== $gCaptcha ) {
471 echo("style='display: none;'");}
472 ?>
473 >
474 <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="0" <?php checked( $invisibleCaptcha, '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Google Captcha', 'mailin');?></label>
475 <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="1" <?php checked( $invisibleCaptcha, '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Google Invisible Captcha', 'mailin');?></label>
476 </div>
477 <div class="small-content2 sib-captcha-key"
478 <?php
479 if ( '1' !== $gCaptcha ) {
480 echo("style='display: none;'");}
481 ?>
482 >
483 <button type="button" id="sib_add_captcha_btn"
484 class="btn btn-primary sib-add-to-form"><span
485 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
486 </button>&nbsp;&nbsp;
487 <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
488 </div>
489 </div>
490 <div id="sib_form_terms" class="card form-field"
491 style="padding-bottom: 20px;">
492 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
493 <!-- for terms -->
494 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
495 <b><?php esc_attr_e( 'Add a Term acceptance checkbox', 'mailin' ); ?></b>&nbsp;
496 <?php SIB_Page_Home::get_narration_script( __( 'Add a Term acceptance checkbox', 'mailin' ), __( 'If the terms and condition checkbox is added to the form, the field will be mandatory for subscription.' , 'mailin' ) ); ?>
497 </div>
498 <div class="small-content2" style="margin-top: 0px;">
499 <input type="radio" name="sib_add_terms" class="sib-add-terms" value="1" <?php checked( $formData['termAccept'], '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin');?></label>
500 <input type="radio" name="sib_add_terms" class="sib-add-terms" value="0" <?php checked( $formData['termAccept'], '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin');?></label>
501 </div>
502 <div class="small-content2 sib-terms-url"
503 <?php
504 if ( '1' !== $formData['termAccept'] ) {
505 echo("style='display: none;'");}
506 ?>
507 >
508 <i><?php esc_attr_e( 'URL to terms and conditions', 'mailin' ); ?></i>&nbsp;
509 <input type="text" class="col-md-12" id="sib_terms_url" name="sib_terms_url" value="<?php
510 if ( isset( $formData['termsURL'] ) && ! empty( $formData['termsURL'] ) ) {
511 echo esc_attr( $formData['termsURL'] );
512 } else {
513 echo '';
514 }
515 ?>">
516 </div>
517 <div class="small-content2 sib-terms-url"
518 <?php
519 if ( '1' !== $formData['termAccept'] ) {
520 echo("style='display: none;'");}
521 ?>
522 >
523 <button type="button" id="sib_add_termsUrl_btn"
524 class="btn btn-primary sib-add-to-form"><span
525 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
526 </button>&nbsp;&nbsp;
527 <?php SIB_Page_Home::get_narration_script( __( 'Add Terms URL', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
528 </div>
529
530 </div>
531 <!-- use css of custom or theme -->
532 <div class="card form-field">
533 <div class="small-content2" style="margin-top: 15px;margin-bottom: 10px;">
534 <b><?php esc_attr_e( 'Form Style', 'mailin' ); ?>&nbsp;</b>
535 <?php SIB_Page_Home::get_narration_script( __( 'Form Style', 'mailin' ), __( 'Select the style you favorite. Your custom css will be applied to form only.', 'mailin' ) ); ?>
536 </div>
537 <div id="sib_form_css_area" class="small-content2" style="margin-bottom: 15px;">
538 <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="1" <?php checked( $formData['dependTheme'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Current Theme', 'mailin' ); ?>
539 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
540 <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="0" <?php checked( $formData['dependTheme'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'Custom style', 'mailin' ); ?>
541 </label>
542 <textarea class="widefat" cols="60" rows="10" id="sibcssmarkup" style="margin-top: 10px; font-size: 13px; display: <?php echo '0' == $formData['dependTheme'] ? 'block' : 'none'; ?>;"
543 name="sib_form_css"><?php echo esc_textarea( $formData['css'] ); ?></textarea>
544
545 </div>
546
547 </div>
548 </div>
549 <div class="col-md-6">
550 <!-- hidden fields for attributes -->
551 <input type="hidden" id="sib_hidden_email" data-type="email" data-name="email"
552 data-text="<?php esc_attr_e( 'Email Address', 'mailin' ); ?>">
553 <input type="hidden" id="sib_hidden_submit" data-type="submit"
554 data-name="submit" data-text="<?php esc_attr_e( 'Subscribe', 'mailin' ); ?>">
555 <input type="hidden" id="sib_hidden_message_1"
556 value="<?php esc_attr_e( 'Select Sendinblue Attribute', 'mailin' ); ?>">
557 <input type="hidden" id="sib_hidden_message_2"
558 value="<?php esc_attr_e( 'Sendinblue merge fields : Normal', 'mailin' ); ?>">
559 <input type="hidden" id="sib_hidden_message_3"
560 value="<?php esc_attr_e( 'Sendinblue merge fields : Category', 'mailin' ); ?>">
561 <input type="hidden" id="sib_hidden_message_4"
562 value="<?php esc_attr_e( 'Other', 'mailin' ); ?>">
563 <input type="hidden" id="sib_hidden_message_5"
564 value="<?php esc_attr_e( 'Submit Button', 'mailin' ); ?>">
565
566 <!-- preview field -->
567
568 <div class="card form-field">
569 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
570 <b><?php esc_attr_e( 'Preview', 'mailin' ); ?>&nbsp;
571 <i id="sib-preview-form-refresh" class="fa fa-refresh" style="cursor:pointer;font-weight: bold;" aria-hidden="true"></i>
572 </b>
573 </div>
574 <iframe id="sib-preview-form"
575 src="<?php echo esc_url( site_url() . '/?sib_form=' . esc_attr( $this->formID ) ); ?>"
576 width="300px" height="428"></iframe>
577 </div>
578 </div>
579 </div>
580 <div class="sib-small-content" style="margin-top: 30px;">
581 <div class="col-md-3">
582 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
583 </div>
584 </div>
585 </div>
586 </div> <!-- End Subscription form-->
587
588 <!-- Sign up Process -->
589
590 <div class="card sib-small-content">
591
592 <!-- Adding security through hidden referrer field -->
593 <div class="card-header">
594 <strong><?php esc_attr_e( 'Sign up process', 'mailin' ); ?></strong>&nbsp;<i
595 id="sib_setting_signup_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i>
596 </div>
597 <div id="sib_setting_signup_body" class="card-body">
598 <div id="sib_form_alert_message" class="alert alert-danger alert-dismissable fade in"
599 role="alert" style="display: none;">
600 <span id="sib_disclaim_smtp"
601 style="display: none;"><?php _e( 'Confirmation emails will be sent through your own email server, but you have no guarantees on their deliverability. <br/> <a href="https://app-smtp.brevo.com/" target="_blank">Click here</a> to send your emails through Sendinblue in order to improve your deliverability and get statistics', 'mailin' ); ?></span>
602 <span id="sib_disclaim_do_template"
603 style="display: none;"><?php _e( 'The template you selected does not include a link [DOUBLEOPTIN] to allow subscribers to confirm their subscription. <br/> Please edit the template to include a link with [DOUBLEOPTIN] as URL.', 'mailin' ); ?></span>
604 <span id="sib_disclaim_confirm_template"
605 style="display: none;"><?php _e( 'You cannot select a template with the tag [DOUBLEOPTIN]', 'mailin' ); ?></span>
606 </div>
607
608 <!-- Linked List -->
609 <div class="row sib-small-content">
610 <span class="col-md-3">
611 <?php esc_attr_e( 'Linked List', 'mailin' ); ?>&nbsp;
612 <?php SIB_Page_Home::get_narration_script( __( 'Linked List', 'mailin' ), __( 'Select the list where you want to add your new subscribers', 'mailin' ) ); ?>
613 </span>
614 <div id="sib_select_list_area" class="col-md-4">
615
616 <input type="hidden" id="sib_selected_list_id" value="">
617 <select data-placeholder="Please select the list" id="sib_select_list"
618 class="col-md-12 chosen-select" name="list_id[]" multiple=""
619 tabindex="-1"></select>
620 </div>
621 <div class="col-md-5">
622 <small
623 style="font-style: italic;"><?php esc_attr_e( 'You can use Marketing Automation to create specific workflow when a user is added to the list.', 'mailin' ); ?></small>
624 </div>
625
626 </div>
627 <!-- confirmation email -->
628 <div class="row small-content">
629 <span class="col-md-3"><?php esc_attr_e( 'Send a confirmation email', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Confirmation message', 'mailin' ), __( 'You can choose to send a confirmation email. You will be able to set up the template that will be sent to your new suscribers', 'mailin' ) ) ); ?></span>
630
631 <div class="col-md-4">
632 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
633 id="is_confirm_email_yes"
634 name="is_confirm_email"
635 value="1" <?php checked( $formData['isOpt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
636 </label>
637 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
638 id="is_confirm_email_no"
639 name="is_confirm_email"
640 value="0" <?php checked( $formData['isOpt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
641 </label>
642 </div>
643 <div class="col-md-5">
644 <small
645 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to receive a confirmation email', 'mailin' ); ?></small>
646 </div>
647 </div>
648 <!-- select template id for confirmation email -->
649 <div class="row" id="sib_confirm_template_area">
650 <input type="hidden" id="sib_selected_template_id"
651 value="<?php echo esc_attr( $formData['templateID'] ); ?>">
652 <input type="hidden" id="sib_default_template_name"
653 value="<?php esc_attr_e( 'Default', 'mailin' ); ?>">
654
655 <div class="col-md-3" id="sib_template_id_area">
656 </div>
657 <div class="col-md-4">
658 <a href="https://my.brevo.com/camp/lists/template" class="col-md-12"
659 target="_blank"><i
660 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
661 </a>
662 </div>
663 </div>
664 <!-- double optin confirmation email -->
665 <div class="row sib-small-content mt-3">
666 <span
667 class="col-md-3"><?php esc_attr_e( 'Double Opt-In', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Double Opt-In', 'mailin' ), __( 'Your subscribers will receive an email inviting them to confirm their subscription. Be careful, your subscribers are not saved in your list before confirming their subscription.', 'mailin' ) ) ); ?></span>
668
669 <div class="col-md-4">
670 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
671 id="is_double_optin_yes"
672 name="is_double_optin"
673 value="1" <?php checked( $formData['isDopt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
674 </label>
675 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
676 id="is_double_optin_no"
677 name="is_double_optin"
678 value="0" <?php checked( $formData['isDopt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
679 </label>
680 </div>
681 <div class="col-md-5">
682 <small
683 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to confirm their email address', 'mailin' ); ?></small>
684 </div>
685 </div>
686 <!-- select template id for double optin confirmation email -->
687 <div class="row" id="sib_doubleoptin_template_area">
688 <input type="hidden" id="sib_selected_do_template_id" value="<?php echo esc_attr( $formData['templateID'] ); ?>">
689 <div class="col-md-3" id="sib_doubleoptin_template_id_area">
690 </div>
691 <div class="col-md-4">
692 <a href="https://my.brevo.com/camp/lists/template"
693 class="col-md-12" target="_blank"><i
694 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
695 </a>
696 </div>
697 </div>
698 <div class="row sib-small-content mt-3" id="sib_double_redirect_area">
699 <span class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after clicking in the email', 'mailin' ); ?></span>
700
701 <div class="col-md-8">
702 <input type="url" class="col-md-11" name="redirect_url" value="<?php echo esc_attr( $formData['redirectInEmail'] ); ?>">
703 </div>
704 </div>
705 <div class="row sib-small-content mt-3" id="sib_final_confirm_template_area">
706 <span class="col-md-3"><?php esc_attr_e( 'Select final confirmation email template', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Final confirmation', 'mailin' ), __( 'This is the final confirmation email your contacts will receive once they click on the double opt-in confirmation link. You can select one of the default templates we have created for you, e.g. \'Default template - Final confirmation\'.
707 For your information, you cannot select a template with the tag [DOUBLEOPTIN].', 'mailin' ) ) ); ?></span>
708 <div class="row col-md-8">
709 <input type="hidden" id="sib_selected_confirm_template_id" value="<?php echo esc_attr( $formData['confirmID'] );?>">
710 <div class="col-md-5" id="sib_final_confirm_template_id_area">
711 </div>
712 <div class="col-md-4">
713 <a href="https://my.brevo.com/camp/lists/template"
714 class="col-md-12" target="_blank"><i
715 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
716 </a>
717 </div>
718 </div>
719 </div>
720
721 <div class="row sib-small-content mt-3">
722 <span
723 class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after subscription', 'mailin' ); ?></span>
724
725 <div class="col-md-4">
726 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
727 id="is_redirect_url_click_yes"
728 name="is_redirect_url_click"
729 value="1" checked>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
730 </label>
731 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
732 id="is_redirect_url_click_no"
733 name="is_redirect_url_click"
734 value="0" <?php checked( $formData['redirectInForm'], '' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
735 </label>
736
737 </div>
738 <div class="col-md-5">
739 <small
740 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want to redirect your subscribers to a specific page after they fullfill the form', 'mailin' ); ?></small>
741 </div>
742 </div>
743 <div class="row" style="margin-top: 10px;
744 <?php
745 if ( '' == $formData['redirectInForm'] ) {
746 echo 'display:none;';
747 }
748 ?>
749 " id="sib_subscrition_redirect_area">
750 <span class="col-md-3"></span>
751
752 <div class="col-md-8">
753 <input type="url" class="col-md-11" name="redirect_url_click"
754 value="<?php echo esc_attr( $formData['redirectInForm'] ); ?>">
755 </div>
756 </div>
757
758 <div class="row sib-small-content" style="margin-top: 30px;">
759 <div class="col-md-3">
760 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
761 </div>
762 </div>
763
764 </div>
765 </div><!-- End Sign up process form-->
766
767 <!-- Confirmation message form -->
768 <div class="card sib-small-content">
769 <div class="card-header">
770 <strong><?php esc_attr_e( 'Confirmation message', 'mailin' ); ?></strong>
771 </div>
772 <div class="card-body">
773 <div class="row sib-small-content mt-3">
774 <!-- <span class="col-md-3"></span> -->
775 <label for="inputEmail3" class="col-md-3"><?php esc_attr_e( 'Success message', 'mailin' ); ?></label>
776 <div class="col-md-8">
777 <input type="text" class="col-md-11" name="alert_success_message"
778 value="<?php echo esc_attr( $formData['successMsg'] ); ?>" required>&nbsp;
779 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Success message', 'mailin' ), __( 'Set up the success message that will appear when one of your visitors surccessfully signs up', 'mailin' ) ) ); ?>
780 </div>
781 </div>
782 <div class="row sib-small-content mt-3">
783 <span class="col-md-3"><?php esc_attr_e( 'General error message', 'mailin' ); ?></span>
784
785 <div class="col-md-8">
786 <input type="text" class="col-md-11" name="alert_error_message"
787 value="<?php echo esc_attr( $formData['errorMsg'] ); ?>" required>&nbsp;
788 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'General message error', 'mailin' ), __( 'Set up the message that will appear when an error occurs during the subscritpion process', 'mailin' ) ) ); ?>
789 </div>
790 </div>
791 <!--
792 <div class="row sib-small-content mt-3">
793 <span class="col-md-3"><?php esc_attr_e( 'Existing subscribers', 'mailin' ); ?></span>
794
795 <div class="col-md-8">
796 <input type="text" class="col-md-11" name="alert_exist_subscriber"
797 value="<?php echo esc_attr( $formData['existMsg'] ); ?>" required>&nbsp;
798 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Existing Suscribers', 'mailin' ), __( 'Set up the message that will appear when a suscriber is already in your database', 'mailin' ) ) ); ?>
799 </div>
800 </div>
801 -->
802 <div class="row sib-small-content mt-3">
803 <span class="col-md-3"><?php esc_attr_e( 'Invalid email address', 'mailin' ); ?></span>
804
805 <div class="col-md-8">
806 <input type="text" class="col-md-11" name="alert_invalid_email"
807 value="<?php echo esc_attr( $formData['invalidMsg'] ); ?>" required>&nbsp;
808 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Invalid email address', 'mailin' ), __( 'Set up the message that will appear when the email address used to sign up is not valid', 'mailin' ) ) ); ?>
809 </div>
810 </div>
811 <div class="row sib-small-content mt-3">
812 <span class="col-md-3"><?php esc_attr_e( 'Required Field', 'mailin' ); ?></span>
813
814 <div class="col-md-8">
815 <input type="text" class="col-md-11" name="alert_required_message"
816 value="<?php echo esc_attr( $formData['requiredMsg'] ); ?>" required>&nbsp;
817 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Required Field', 'mailin' ), __( 'Set up the message that will appear when the required field is empty', 'mailin' ) ) ); ?>
818 </div>
819 </div>
820 <div class="row sib-small-content" style="margin-top: 30px;">
821 <div class="col-md-3">
822 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
823 </div>
824 </div>
825 </div>
826 </div> <!-- End Confirmation message form-->
827 </form>
828 </div>
829 <script>
830 jQuery(document).ready(function () {
831 jQuery('#sib_add_to_form_btn').click(function () {
832 //var field_html = jQuery('#sib_field_html').html();
833
834 // tinyMCE.activeEditor.selection.setContent(field_html);
835
836 return false;
837 });
838 });
839 </script>
840 <?php
841 } else {
842 // If empty?
843 ?>
844 <div id="main-content" class="sib-content">
845 <div class="card sib-small-content">
846 <div class="card-header">
847 <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong>
848 </div>
849 <div style="padding: 24px 32px; margin-bottom: 12px;">
850 <?php esc_attr_e( 'Sorry, you selected invalid form ID. Please check again if the ID is right', 'mailin' ); ?>
851 </div>
852 </div>
853 </div>
854 <?php
855 }
856 }
857
858 /** Generate welcome page */
859 function generate_welcome_page() {
860 ?>
861 <div id="main-content" class="row">
862 <img class="small-content" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/background/setting.png' ); ?>" style="width: 100%;">
863 </div>
864 <?php
865 SIB_Page_Home::print_disable_popup();
866 }
867
868 /** Save subscription form setting */
869 public static function save_setting_subscription() {
870 // Check user role.
871 if ( ! current_user_can( 'manage_options' ) ) {
872 wp_die( 'Not allowed' );
873 }
874
875 // Check secret through hidden referrer field.
876 check_admin_referer( 'sib_setting_subscription' );
877
878 //Handling of backslash added by WP because magic quotes are enabled by default
879 array_walk_recursive( $_POST, function(&$value) {
880 $value = stripslashes($value);
881 });
882
883 // Subscription form.
884 $formID = isset( $_POST['sib_form_id'] ) ? sanitize_text_field( $_POST['sib_form_id'] ) : '';
885 $form_name = isset( $_POST['sib_form_name'] ) ? sanitize_text_field( $_POST['sib_form_name'] ) : '';
886 // phpcs:disable
887 $form_html = isset( $_POST['sib_form_html'] ) ? wp_kses($_POST['sib_form_html'], SIB_Manager::wordpress_allowed_attributes()) : '';
888 $list_ids = '';
889
890 if (!empty($_POST['list_id']) && is_array($_POST['list_id'])) {
891 $list_ids = array_filter($_POST['list_id'], 'intval');
892 $list_ids = maybe_serialize($list_ids);
893 }
894
895 // phpcs:enable
896 $dependTheme = isset( $_POST['sib_css_type'] ) ? sanitize_text_field( $_POST['sib_css_type'] ) : '';
897 $customCss = isset( $_POST['sib_form_css'] ) ? sanitize_text_field( $_POST['sib_form_css'] ) : '';
898 $gCaptcha = isset( $_POST['sib_add_captcha'] ) ? sanitize_text_field( $_POST['sib_add_captcha'] ) : '0';
899 $gCaptchaSecret = isset( $_POST['sib_captcha_secret'] ) ? sanitize_text_field( $_POST['sib_captcha_secret'] ) : '';
900 $gCaptchaSite = isset( $_POST['sib_captcha_site'] ) ? sanitize_text_field( $_POST['sib_captcha_site'] ) : '';
901 $termAccept = isset( $_POST['sib_add_terms'] ) ? sanitize_text_field( $_POST['sib_add_terms'] ) : '0';
902 $termURL = isset( $_POST['sib_terms_url'] ) ? sanitize_text_field( $_POST['sib_terms_url'] ) : '';
903 $gCaptchaType = isset( $_POST['sib_recaptcha_type'] ) ? sanitize_text_field( $_POST['sib_recaptcha_type'] ) : '0';
904 if ( $gCaptcha != '0' ) {
905 if ( $gCaptchaType == '0' ) {
906 $gCaptcha = '3'; // google recaptcha.
907 }
908 elseif ( $gCaptchaType == '1' ) {
909 $gCaptcha = '2'; // google invisible recaptcha.
910 }
911 }
912 // for wpml plugins.
913 $pid = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : '';
914 $lang = isset( $_POST['lang'] ) ? sanitize_text_field( $_POST['lang'] ) : '';
915 // sign up process.
916 $templateID = '-1';
917 $confirmID = '-1';
918 $redirectInForm = '';
919
920 $isOpt = isset( $_POST['is_confirm_email'] ) ? sanitize_text_field( $_POST['is_confirm_email'] ) : false;
921 if ( $isOpt ) {
922 $templateID = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '-1';
923 }
924 $isDopt = isset( $_POST['is_double_optin'] ) ? sanitize_text_field( $_POST['is_double_optin'] ) : false;
925 if ( $isDopt ) {
926 $templateID = isset( $_POST['doubleoptin_template_id'] ) ? sanitize_text_field( $_POST['doubleoptin_template_id'] ) : '-1';
927 $confirmID = isset( $_POST['confirm_template_id'] ) ? sanitize_text_field( $_POST['confirm_template_id'] ) : '-1';
928 }
929 $redirectInEmail = isset( $_POST['redirect_url'] ) ? sanitize_text_field( $_POST['redirect_url'] ) : '';
930 $isRedirectInForm = isset( $_POST['is_redirect_url_click'] ) ? sanitize_text_field( $_POST['is_redirect_url_click'] ) : false;
931 if ( $isRedirectInForm ) {
932 $redirectInForm = isset( $_POST['redirect_url_click'] ) ? sanitize_text_field( $_POST['redirect_url_click'] ) : '';
933 }
934
935 // get available attributes list.
936 $attributes = SIB_API_Manager::get_attributes();
937 $attributes = array_merge( $attributes['attributes']['normal_attributes'],$attributes['attributes']['category_attributes'] );
938 $available_attrs = array( 'email' );
939 if ( isset( $attributes ) && is_array( $attributes ) ) {
940 foreach ( $attributes as $attribute ) {
941 $pos = strpos( $form_html, 'sib-' . $attribute['name'] . '-area' );
942 if ( false !== $pos ) {
943 $available_attrs[] = $attribute['name'];
944 }
945 }
946 }
947 $successMsg = isset( $_POST['alert_success_message'] ) ? sanitize_text_field( esc_attr ($_POST['alert_success_message'] ) ) : '';
948 $errorMsg = isset( $_POST['alert_error_message'] ) ? sanitize_text_field( esc_attr( $_POST['alert_error_message'] ) ) : '';
949 $existMsg = isset( $_POST['alert_exist_subscriber'] ) ? sanitize_text_field( esc_attr( $_POST['alert_exist_subscriber'] ) ) : '';
950 $invalidMsg = isset( $_POST['alert_invalid_email'] ) ? sanitize_text_field( esc_attr( $_POST['alert_invalid_email'] ) ) : '';
951 $requiredMsg = isset( $_POST['alert_required_message']) ? sanitize_text_field( esc_attr($_POST['alert_required_message'])) : '';
952 $formData = array(
953 'title' => $form_name,
954 'html' => $form_html,
955 'css' => $customCss,
956 'listID' => $list_ids,
957 'dependTheme' => $dependTheme,
958 'isOpt' => $isOpt,
959 'isDopt' => $isDopt,
960 'templateID' => $templateID,
961 'confirmID' => $confirmID,
962 'redirectInEmail' => $redirectInEmail,
963 'redirectInForm' => $redirectInForm,
964 'successMsg' => $successMsg,
965 'errorMsg' => $errorMsg,
966 'existMsg' => $existMsg,
967 'invalidMsg' => $invalidMsg,
968 'requiredMsg' => $requiredMsg,
969 'attributes' => implode( ',', $available_attrs ),
970 'gcaptcha' => $gCaptcha,
971 'gcaptcha_secret' => $gCaptchaSecret,
972 'gcaptcha_site' => $gCaptchaSite,
973 'termAccept' => $termAccept,
974 'termsURL' => $termURL,
975 );
976 if ( 'new' === $formID ) {
977 $formID = SIB_Forms::addForm( $formData );
978 if ( '' !== $pid ) {
979 $transID = SIB_Forms_Lang::add_form_ID( $formID, $pid, $lang );
980 }
981 } else {
982 SIB_Forms::updateForm( $formID, $formData );
983 }
984 if ( '' !== $pid ) {
985 wp_safe_redirect(
986 add_query_arg(
987 array(
988 'page' => self::PAGE_ID,
989 'action' => 'edit',
990 'id' => $formID,
991 'pid' => $pid,
992 'lang' => $lang,
993 ), admin_url( 'admin.php' )
994 )
995 );
996 exit();
997 } else {
998 wp_safe_redirect(
999 add_query_arg(
1000 array(
1001 'page' => self::PAGE_ID,
1002 'action' => 'edit',
1003 'id' => $formID,
1004 ), admin_url( 'admin.php' )
1005 )
1006 );
1007 exit();
1008 }
1009 }
1010
1011 /** Ajax process when change template id */
1012 public static function ajax_change_template() {
1013 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1014 $template_id = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '';
1015 $mailin = new SendinblueApiClient( );
1016 $data = array(
1017 'id' => $template_id,
1018 );
1019 $response = $mailin->getEmailTemplate( $data["id"] );
1020
1021 $ret_email = '-1';
1022 if ( $mailin->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK) {
1023 $from_email = $response[0]['sender']['email'];
1024 if ( '[DEFAULT_FROM_EMAIL]' == $from_email ) {
1025 $ret_email = '-1';
1026 } else {
1027 $ret_email = $from_email;
1028 }
1029 }
1030 wp_send_json( $ret_email );
1031 }
1032
1033 /**
1034 * Ajax module to get all lists.
1035 */
1036 public static function ajax_get_lists() {
1037 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1038 $lists = SIB_API_Manager::get_lists();
1039 $frmID = isset( $_POST['frmid'] ) ? sanitize_text_field( $_POST['frmid'] ) : '';
1040 $formData = SIB_Forms::getForm( $frmID );
1041 $result = array(
1042 'lists' => $lists,
1043 'selected' => $formData['listID'],
1044 );
1045 wp_send_json( $result );
1046 }
1047
1048 /**
1049 * Ajax module to get all templates.
1050 */
1051 public static function ajax_get_templates() {
1052 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1053 $templates = SIB_API_Manager::get_templates();
1054 $result = array(
1055 'templates' => $templates,
1056 );
1057 wp_send_json( $result );
1058 }
1059
1060 /**
1061 * Ajax module to get all attributes.
1062 */
1063 public static function ajax_get_attributes() {
1064 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1065 $attrs = SIB_API_Manager::get_attributes();
1066 $result = array(
1067 'attrs' => $attrs,
1068 );
1069 wp_send_json( $result );
1070 }
1071
1072 /**
1073 * Ajax module to update form html for preview
1074 */
1075 public static function ajax_update_html() {
1076 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1077 $gCaptchaType = isset( $_POST['gCaptchaType']) ? sanitize_text_field($_POST['gCaptchaType']) : '1';
1078 $gCaptcha = isset( $_POST['gCaptcha'] ) ? sanitize_text_field($_POST['gCaptcha']) : '0';
1079 if ( $gCaptcha != '0' ) {
1080 if( $gCaptchaType == '1' ) {
1081 $gCaptcha = '2';
1082 }
1083 elseif ( $gCaptchaType == '0' ) {
1084 $gCaptcha = '3';
1085 }
1086 }
1087 $formData = array(
1088 'html' => isset( $_POST['frmData'] ) ? wp_kses($_POST['frmData'], SIB_Manager::wordpress_allowed_attributes()) : '',// phpcs:ignore
1089 'css' => isset( $_POST['frmCss'] ) ? sanitize_text_field($_POST['frmCss']) : '',
1090 'dependTheme' => isset( $_POST['isDepend'] ) ? sanitize_text_field($_POST['isDepend']) : '',
1091 'gCaptcha' => $gCaptcha,
1092 'gCaptcha_site' => isset( $_POST['gCaptchaSite'] ) ? sanitize_text_field($_POST['gCaptchaSite']) : ''
1093 );
1094
1095 update_option( SIB_Manager::PREVIEW_OPTION_NAME, $formData );
1096 die;
1097 }
1098
1099 /**
1100 * Ajax module to copy content from origin form for translation
1101 */
1102 public static function ajax_copy_origin_form() {
1103 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1104 $pID = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : 1;
1105 $formData = SIB_Forms::getForm( $pID );
1106 // phpcs:ignore
1107 $html = $formData['html'];
1108
1109 wp_send_json( $html );
1110 }
1111 }
1112 }
1113