PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.1.41
Brevo – Email, SMS, Web Push, Chat, and more. v3.1.41
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 4 years ago page-home.php 4 years ago page-scenarios.php 4 years ago page-statistics.php 4 years ago
page-form.php
1109 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 <?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' ) ); ?>
342 </div>
343 <div class="small-content2" style="margin-top: 20px;"
344 id="sib_field_html_area">
345 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
346 <textarea class="col-md-12" style="height: 140px;"
347 id="sib_field_html"></textarea>
348 </div>
349 </div>
350 </div>
351 <!---- multi list per interest ----->
352 <div id="sib-multi-lists" class="card form-field"
353 style="padding-bottom: 20px;">
354
355 <div class="small-content2"
356 style="margin-top: 15px">
357 <b><?php esc_attr_e( 'Add Multi-List Subscription', 'mailin' ); ?></b>&nbsp;
358 <?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' ) ); ?>
359 </div>
360 <div id="sib_sel_multi_list_area" class="small-content2"
361 style="margin-top: 20px;">
362 <input type="hidden" id="sib_selected_multi_list_id" value="">
363 <select data-placeholder="<?php esc_attr_e( 'Please select the lists', 'mailin' ); ?>" id="sib_select_multi_list"
364 class="col-md-12 chosen-select" name="multi_list_ids[]" multiple=""
365 tabindex="-1"></select>
366 </div>
367 <div id="sib_multi_list_field" style="display: none;">
368 <div style="margin-top: 30px;">
369 <div class="sib-attr-normal sib-attr-category small-content2"
370 style="margin-top: 10px;" id="sib_multi_field_label_area">
371 <?php esc_attr_e( 'Label', 'mailin' ); ?>
372 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small>
373 <input type="text" class="col-md-12 sib_field_changes" id="sib_multi_field_label">
374 </div>
375 </div>
376 <div style="margin-top: 20px;">
377 <div class="sib-attr-normal sib-attr-category small-content2" style="margin-top: 5px;" id="sib_multi_field_required_area">
378 <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' ); ?>
379 </label>
380 </div>
381 </div>
382 <div class="small-content2" style="margin-top: 20px;"
383 id="sib_multi_field_add_area">
384 <button type="button" id="sib_multi_lists_add_form_btn"
385 class="btn btn-primary sib-add-to-form"><span
386 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
387 </button>&nbsp;&nbsp;
388 <?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' ) ); ?>
389 </div>
390 <div class="small-content2" style="margin-top: 20px;"
391 id="sib_field_html_area">
392 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
393 <textarea class="col-md-12" style="height: 140px;"
394 id="sib_multi_field_html"></textarea>
395 </div>
396 </div>
397 </div>
398
399 <div id="sib-gdpr-block" class="card form-field" style="padding-bottom: 20px;">
400 <div class="small-content2"
401 style="margin-top: 15px;margin-bottom: 15px;">
402 <b><?php esc_attr_e( 'Compliance Note', 'mailin' ); ?></b>&nbsp;
403 <?php SIB_Page_Home::get_narration_script( __( 'Add compliance note', 'mailin' ), __( 'Create GDPR-compliant subscription forms for collecting email addresses.', 'mailin' ) ); ?>
404 </div>
405 <div class="small-content2" style="margin-top: 0px;">
406 <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>
407 <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>
408 </div>
409 <div class="small-content2 sib-gdpr-block-area" style="display: none;">
410 <textarea id="sib_gdpr_text" class="col-md-12" rows="5"><?php echo trim( $this->defaultComplianceNote ); ?></textarea>
411 <label id="set_gdpr_default"><?php esc_attr_e('Reset to Default', 'mailin');?>&nbsp;<i class="fa fa-refresh"></i></label>
412 </div>
413 <div class="small-content2 sib-gdpr-block-btn" style="display: none;">
414 <button type="button" id="sib_add_compliance_note"
415 class="btn btn-primary sib-add-to-form"><span
416 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
417 </button>&nbsp;&nbsp;
418 <?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' ) ); ?>
419 </div>
420 </div>
421
422 <!---- end block ------>
423 <div id="sib_form_captcha" class="card form-field"
424 style="padding-bottom: 20px;">
425 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
426 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
427 <b><?php esc_attr_e( 'Add Captcha', 'mailin' ); ?></b>&nbsp;
428 <?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' ) ); ?>
429 </div>
430 <div class="small-content2" style="margin-top: 0px;">
431 <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>
432 <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>
433 </div>
434 <div class="small-content2 sib-captcha-key"
435 <?php
436 if ( '1' !== $gCaptcha ) {
437 echo("style='display: none;'");}
438 ?>
439 >
440 <i><?php esc_attr_e( 'Site Key', 'mailin' ); ?></i>&nbsp;
441 <input type="text" class="col-md-12" id="sib_captcha_site" name="sib_captcha_site" value="<?php
442 if ( isset( $formData['gCaptcha_site'] ) && ! empty( $formData['gCaptcha_site'] ) ) {
443 echo esc_attr( $formData['gCaptcha_site'] );
444 } else {
445 echo '';
446 }
447 ?>">
448 </div>
449 <div class="small-content2 sib-captcha-key"
450 <?php
451 if ( '1' !== $gCaptcha ) {
452 echo("style='display: none;'");}
453 ?>
454 >
455 <i><?php esc_attr_e( 'Secret Key', 'mailin' ); ?></i>&nbsp;
456 <input type="text" class="col-md-12" id="sib_captcha_secret" name="sib_captcha_secret" value="<?php
457 if ( isset( $formData['gCaptcha_secret'] ) && ! empty( $formData['gCaptcha_secret'] ) ) {
458 echo esc_attr( $formData['gCaptcha_secret'] );
459 } else {
460 echo '';
461 }
462 ?>">
463 </div>
464 <div class="small-content2 sib-captcha-key"
465 <?php
466 if ( '1' !== $gCaptcha ) {
467 echo("style='display: none;'");}
468 ?>
469 >
470 <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>
471 <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>
472 </div>
473 <div class="small-content2 sib-captcha-key"
474 <?php
475 if ( '1' !== $gCaptcha ) {
476 echo("style='display: none;'");}
477 ?>
478 >
479 <button type="button" id="sib_add_captcha_btn"
480 class="btn btn-primary sib-add-to-form"><span
481 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
482 </button>&nbsp;&nbsp;
483 <?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' ) ); ?>
484 </div>
485 </div>
486 <div id="sib_form_terms" class="card form-field"
487 style="padding-bottom: 20px;">
488 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
489 <!-- for terms -->
490 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
491 <b><?php esc_attr_e( 'Add a Term acceptance checkbox', 'mailin' ); ?></b>&nbsp;
492 <?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' ) ); ?>
493 </div>
494 <div class="small-content2" style="margin-top: 0px;">
495 <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>
496 <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>
497 </div>
498 <div class="small-content2 sib-terms-url"
499 <?php
500 if ( '1' !== $formData['termAccept'] ) {
501 echo("style='display: none;'");}
502 ?>
503 >
504 <i><?php esc_attr_e( 'URL to terms and conditions', 'mailin' ); ?></i>&nbsp;
505 <input type="text" class="col-md-12" id="sib_terms_url" name="sib_terms_url" value="<?php
506 if ( isset( $formData['termsURL'] ) && ! empty( $formData['termsURL'] ) ) {
507 echo esc_attr( $formData['termsURL'] );
508 } else {
509 echo '';
510 }
511 ?>">
512 </div>
513 <div class="small-content2 sib-terms-url"
514 <?php
515 if ( '1' !== $formData['termAccept'] ) {
516 echo("style='display: none;'");}
517 ?>
518 >
519 <button type="button" id="sib_add_termsUrl_btn"
520 class="btn btn-primary sib-add-to-form"><span
521 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
522 </button>&nbsp;&nbsp;
523 <?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' ) ); ?>
524 </div>
525
526 </div>
527 <!-- use css of custom or theme -->
528 <div class="card form-field">
529 <div class="small-content2" style="margin-top: 15px;margin-bottom: 10px;">
530 <b><?php esc_attr_e( 'Form Style', 'mailin' ); ?>&nbsp;</b>
531 <?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' ) ); ?>
532 </div>
533 <div id="sib_form_css_area" class="small-content2" style="margin-bottom: 15px;">
534 <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' ); ?>
535 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
536 <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' ); ?>
537 </label>
538 <textarea class="widefat" cols="60" rows="10" id="sibcssmarkup" style="margin-top: 10px; font-size: 13px; display: <?php echo '0' == $formData['dependTheme'] ? 'block' : 'none'; ?>;"
539 name="sib_form_css"><?php echo esc_textarea( $formData['css'] ); ?></textarea>
540
541 </div>
542
543 </div>
544 </div>
545 <div class="col-md-6">
546 <!-- hidden fields for attributes -->
547 <input type="hidden" id="sib_hidden_email" data-type="email" data-name="email"
548 data-text="<?php esc_attr_e( 'Email Address', 'mailin' ); ?>">
549 <input type="hidden" id="sib_hidden_submit" data-type="submit"
550 data-name="submit" data-text="<?php esc_attr_e( 'Subscribe', 'mailin' ); ?>">
551 <input type="hidden" id="sib_hidden_message_1"
552 value="<?php esc_attr_e( 'Select Sendinblue Attribute', 'mailin' ); ?>">
553 <input type="hidden" id="sib_hidden_message_2"
554 value="<?php esc_attr_e( 'Sendinblue merge fields : Normal', 'mailin' ); ?>">
555 <input type="hidden" id="sib_hidden_message_3"
556 value="<?php esc_attr_e( 'Sendinblue merge fields : Category', 'mailin' ); ?>">
557 <input type="hidden" id="sib_hidden_message_4"
558 value="<?php esc_attr_e( 'Other', 'mailin' ); ?>">
559 <input type="hidden" id="sib_hidden_message_5"
560 value="<?php esc_attr_e( 'Submit Button', 'mailin' ); ?>">
561
562 <!-- preview field -->
563
564 <div class="card form-field">
565 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
566 <b><?php esc_attr_e( 'Preview', 'mailin' ); ?>&nbsp;
567 <i id="sib-preview-form-refresh" class="fa fa-refresh" style="cursor:pointer;font-weight: bold;" aria-hidden="true"></i>
568 </b>
569 </div>
570 <iframe id="sib-preview-form"
571 src="<?php echo esc_url( site_url() . '/?sib_form=' . esc_attr( $this->formID ) ); ?>"
572 width="300px" height="428"></iframe>
573 </div>
574 </div>
575 </div>
576 <div class="sib-small-content" style="margin-top: 30px;">
577 <div class="col-md-3">
578 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
579 </div>
580 </div>
581 </div>
582 </div> <!-- End Subscription form-->
583
584 <!-- Sign up Process -->
585
586 <div class="card sib-small-content">
587
588 <!-- Adding security through hidden referrer field -->
589 <div class="card-header">
590 <strong><?php esc_attr_e( 'Sign up process', 'mailin' ); ?></strong>&nbsp;<i
591 id="sib_setting_signup_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i>
592 </div>
593 <div id="sib_setting_signup_body" class="card-body">
594 <div id="sib_form_alert_message" class="alert alert-danger alert-dismissable fade in"
595 role="alert" style="display: none;">
596 <span id="sib_disclaim_smtp"
597 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.sendinblue.com/" target="_blank">Click here</a> to send your emails through Sendinblue in order to improve your deliverability and get statistics', 'mailin' ); ?></span>
598 <span id="sib_disclaim_do_template"
599 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>
600 <span id="sib_disclaim_confirm_template"
601 style="display: none;"><?php _e( 'You cannot select a template with the tag [DOUBLEOPTIN]', 'mailin' ); ?></span>
602 </div>
603
604 <!-- Linked List -->
605 <div class="row sib-small-content">
606 <span class="col-md-3">
607 <?php esc_attr_e( 'Linked List', 'mailin' ); ?>&nbsp;
608 <?php SIB_Page_Home::get_narration_script( __( 'Linked List', 'mailin' ), __( 'Select the list where you want to add your new subscribers', 'mailin' ) ); ?>
609 </span>
610 <div id="sib_select_list_area" class="col-md-4">
611
612 <input type="hidden" id="sib_selected_list_id" value="">
613 <select data-placeholder="Please select the list" id="sib_select_list"
614 class="col-md-12 chosen-select" name="list_id[]" multiple=""
615 tabindex="-1"></select>
616 </div>
617 <div class="col-md-5">
618 <small
619 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>
620 </div>
621
622 </div>
623 <!-- confirmation email -->
624 <div class="row small-content">
625 <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>
626
627 <div class="col-md-4">
628 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
629 id="is_confirm_email_yes"
630 name="is_confirm_email"
631 value="1" <?php checked( $formData['isOpt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
632 </label>
633 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
634 id="is_confirm_email_no"
635 name="is_confirm_email"
636 value="0" <?php checked( $formData['isOpt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
637 </label>
638 </div>
639 <div class="col-md-5">
640 <small
641 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to receive a confirmation email', 'mailin' ); ?></small>
642 </div>
643 </div>
644 <!-- select template id for confirmation email -->
645 <div class="row" id="sib_confirm_template_area">
646 <input type="hidden" id="sib_selected_template_id"
647 value="<?php echo esc_attr( $formData['templateID'] ); ?>">
648 <input type="hidden" id="sib_default_template_name"
649 value="<?php esc_attr_e( 'Default', 'mailin' ); ?>">
650
651 <div class="col-md-3" id="sib_template_id_area">
652 </div>
653 <div class="col-md-4">
654 <a href="https://my.sendinblue.com/camp/lists/template" class="col-md-12"
655 target="_blank"><i
656 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
657 </a>
658 </div>
659 </div>
660 <!-- double optin confirmation email -->
661 <div class="row sib-small-content mt-3">
662 <span
663 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>
664
665 <div class="col-md-4">
666 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
667 id="is_double_optin_yes"
668 name="is_double_optin"
669 value="1" <?php checked( $formData['isDopt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
670 </label>
671 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
672 id="is_double_optin_no"
673 name="is_double_optin"
674 value="0" <?php checked( $formData['isDopt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
675 </label>
676 </div>
677 <div class="col-md-5">
678 <small
679 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to confirm their email address', 'mailin' ); ?></small>
680 </div>
681 </div>
682 <!-- select template id for double optin confirmation email -->
683 <div class="row" id="sib_doubleoptin_template_area">
684 <input type="hidden" id="sib_selected_do_template_id" value="<?php echo esc_attr( $formData['templateID'] ); ?>">
685 <div class="col-md-3" id="sib_doubleoptin_template_id_area">
686 </div>
687 <div class="col-md-4">
688 <a href="https://my.sendinblue.com/camp/lists/template"
689 class="col-md-12" target="_blank"><i
690 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
691 </a>
692 </div>
693 </div>
694 <div class="row sib-small-content mt-3" id="sib_double_redirect_area">
695 <span class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after clicking in the email', 'mailin' ); ?></span>
696
697 <div class="col-md-8">
698 <input type="url" class="col-md-11" name="redirect_url" value="<?php echo esc_attr( $formData['redirectInEmail'] ); ?>">
699 </div>
700 </div>
701 <div class="row sib-small-content mt-3" id="sib_final_confirm_template_area">
702 <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\'.
703 For your information, you cannot select a template with the tag [DOUBLEOPTIN].', 'mailin' ) ) ); ?></span>
704 <div class="row col-md-8">
705 <input type="hidden" id="sib_selected_confirm_template_id" value="<?php echo esc_attr( $formData['confirmID'] );?>">
706 <div class="col-md-5" id="sib_final_confirm_template_id_area">
707 </div>
708 <div class="col-md-4">
709 <a href="https://my.sendinblue.com/camp/lists/template"
710 class="col-md-12" target="_blank"><i
711 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
712 </a>
713 </div>
714 </div>
715 </div>
716
717 <div class="row sib-small-content mt-3">
718 <span
719 class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after subscription', 'mailin' ); ?></span>
720
721 <div class="col-md-4">
722 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
723 id="is_redirect_url_click_yes"
724 name="is_redirect_url_click"
725 value="1" checked>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
726 </label>
727 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
728 id="is_redirect_url_click_no"
729 name="is_redirect_url_click"
730 value="0" <?php checked( $formData['redirectInForm'], '' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
731 </label>
732
733 </div>
734 <div class="col-md-5">
735 <small
736 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>
737 </div>
738 </div>
739 <div class="row" style="margin-top: 10px;
740 <?php
741 if ( '' == $formData['redirectInForm'] ) {
742 echo 'display:none;';
743 }
744 ?>
745 " id="sib_subscrition_redirect_area">
746 <span class="col-md-3"></span>
747
748 <div class="col-md-8">
749 <input type="url" class="col-md-11" name="redirect_url_click"
750 value="<?php echo esc_attr( $formData['redirectInForm'] ); ?>">
751 </div>
752 </div>
753
754 <div class="row sib-small-content" style="margin-top: 30px;">
755 <div class="col-md-3">
756 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
757 </div>
758 </div>
759
760 </div>
761 </div><!-- End Sign up process form-->
762
763 <!-- Confirmation message form -->
764 <div class="card sib-small-content">
765 <div class="card-header">
766 <strong><?php esc_attr_e( 'Confirmation message', 'mailin' ); ?></strong>
767 </div>
768 <div class="card-body">
769 <div class="row sib-small-content mt-3">
770 <!-- <span class="col-md-3"></span> -->
771 <label for="inputEmail3" class="col-md-3"><?php esc_attr_e( 'Success message', 'mailin' ); ?></label>
772 <div class="col-md-8">
773 <input type="text" class="col-md-11" name="alert_success_message"
774 value="<?php echo esc_attr( $formData['successMsg'] ); ?>" required>&nbsp;
775 <?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' ) ) ); ?>
776 </div>
777 </div>
778 <div class="row sib-small-content mt-3">
779 <span class="col-md-3"><?php esc_attr_e( 'General error message', 'mailin' ); ?></span>
780
781 <div class="col-md-8">
782 <input type="text" class="col-md-11" name="alert_error_message"
783 value="<?php echo esc_attr( $formData['errorMsg'] ); ?>" required>&nbsp;
784 <?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' ) ) ); ?>
785 </div>
786 </div>
787 <!--
788 <div class="row sib-small-content mt-3">
789 <span class="col-md-3"><?php esc_attr_e( 'Existing subscribers', 'mailin' ); ?></span>
790
791 <div class="col-md-8">
792 <input type="text" class="col-md-11" name="alert_exist_subscriber"
793 value="<?php echo esc_attr( $formData['existMsg'] ); ?>" required>&nbsp;
794 <?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' ) ) ); ?>
795 </div>
796 </div>
797 -->
798 <div class="row sib-small-content mt-3">
799 <span class="col-md-3"><?php esc_attr_e( 'Invalid email address', 'mailin' ); ?></span>
800
801 <div class="col-md-8">
802 <input type="text" class="col-md-11" name="alert_invalid_email"
803 value="<?php echo esc_attr( $formData['invalidMsg'] ); ?>" required>&nbsp;
804 <?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' ) ) ); ?>
805 </div>
806 </div>
807 <div class="row sib-small-content mt-3">
808 <span class="col-md-3"><?php esc_attr_e( 'Required Field', 'mailin' ); ?></span>
809
810 <div class="col-md-8">
811 <input type="text" class="col-md-11" name="alert_required_message"
812 value="<?php echo esc_attr( $formData['requiredMsg'] ); ?>" required>&nbsp;
813 <?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' ) ) ); ?>
814 </div>
815 </div>
816 <div class="row sib-small-content" style="margin-top: 30px;">
817 <div class="col-md-3">
818 <button class="btn btn-primary"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
819 </div>
820 </div>
821 </div>
822 </div> <!-- End Confirmation message form-->
823 </form>
824 </div>
825 <script>
826 jQuery(document).ready(function () {
827 jQuery('#sib_add_to_form_btn').click(function () {
828 //var field_html = jQuery('#sib_field_html').html();
829
830 // tinyMCE.activeEditor.selection.setContent(field_html);
831
832 return false;
833 });
834 });
835 </script>
836 <?php
837 } else {
838 // If empty?
839 ?>
840 <div id="main-content" class="sib-content">
841 <div class="card sib-small-content">
842 <div class="card-header">
843 <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong>
844 </div>
845 <div style="padding: 24px 32px; margin-bottom: 12px;">
846 <?php esc_attr_e( 'Sorry, you selected invalid form ID. Please check again if the ID is right', 'mailin' ); ?>
847 </div>
848 </div>
849 </div>
850 <?php
851 }
852 }
853
854 /** Generate welcome page */
855 function generate_welcome_page() {
856 ?>
857 <div id="main-content" class="row">
858 <img class="small-content" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/background/setting.png' ); ?>" style="width: 100%;">
859 </div>
860 <?php
861 SIB_Page_Home::print_disable_popup();
862 }
863
864 /** Save subscription form setting */
865 public static function save_setting_subscription() {
866 // Check user role.
867 if ( ! current_user_can( 'manage_options' ) ) {
868 wp_die( 'Not allowed' );
869 }
870
871 // Check secret through hidden referrer field.
872 check_admin_referer( 'sib_setting_subscription' );
873
874 //Handling of backslash added by WP because magic quotes are enabled by default
875 array_walk_recursive( $_POST, function(&$value) {
876 $value = stripslashes($value);
877 });
878
879 // Subscription form.
880 $formID = isset( $_POST['sib_form_id'] ) ? sanitize_text_field( $_POST['sib_form_id'] ) : '';
881 $form_name = isset( $_POST['sib_form_name'] ) ? sanitize_text_field( $_POST['sib_form_name'] ) : '';
882 // phpcs:disable
883 $form_html = isset( $_POST['sib_form_html'] ) ? wp_kses($_POST['sib_form_html'], SIB_Manager::wordpress_allowed_attributes()) : '';
884 $list_ids = '';
885
886 if (!empty($_POST['list_id']) && is_array($_POST['list_id'])) {
887 $list_ids = array_filter($_POST['list_id'], 'intval');
888 $list_ids = maybe_serialize($list_ids);
889 }
890
891 // phpcs:enable
892 $dependTheme = isset( $_POST['sib_css_type'] ) ? sanitize_text_field( $_POST['sib_css_type'] ) : '';
893 $customCss = isset( $_POST['sib_form_css'] ) ? sanitize_text_field( $_POST['sib_form_css'] ) : '';
894 $gCaptcha = isset( $_POST['sib_add_captcha'] ) ? sanitize_text_field( $_POST['sib_add_captcha'] ) : '0';
895 $gCaptchaSecret = isset( $_POST['sib_captcha_secret'] ) ? sanitize_text_field( $_POST['sib_captcha_secret'] ) : '';
896 $gCaptchaSite = isset( $_POST['sib_captcha_site'] ) ? sanitize_text_field( $_POST['sib_captcha_site'] ) : '';
897 $termAccept = isset( $_POST['sib_add_terms'] ) ? sanitize_text_field( $_POST['sib_add_terms'] ) : '0';
898 $termURL = isset( $_POST['sib_terms_url'] ) ? sanitize_text_field( $_POST['sib_terms_url'] ) : '';
899 $gCaptchaType = isset( $_POST['sib_recaptcha_type'] ) ? sanitize_text_field( $_POST['sib_recaptcha_type'] ) : '0';
900 if ( $gCaptcha != '0' ) {
901 if ( $gCaptchaType == '0' ) {
902 $gCaptcha = '3'; // google recaptcha.
903 }
904 elseif ( $gCaptchaType == '1' ) {
905 $gCaptcha = '2'; // google invisible recaptcha.
906 }
907 }
908 // for wpml plugins.
909 $pid = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : '';
910 $lang = isset( $_POST['lang'] ) ? sanitize_text_field( $_POST['lang'] ) : '';
911 // sign up process.
912 $templateID = '-1';
913 $confirmID = '-1';
914 $redirectInForm = '';
915
916 $isOpt = isset( $_POST['is_confirm_email'] ) ? sanitize_text_field( $_POST['is_confirm_email'] ) : false;
917 if ( $isOpt ) {
918 $templateID = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '-1';
919 }
920 $isDopt = isset( $_POST['is_double_optin'] ) ? sanitize_text_field( $_POST['is_double_optin'] ) : false;
921 if ( $isDopt ) {
922 $templateID = isset( $_POST['doubleoptin_template_id'] ) ? sanitize_text_field( $_POST['doubleoptin_template_id'] ) : '-1';
923 $confirmID = isset( $_POST['confirm_template_id'] ) ? sanitize_text_field( $_POST['confirm_template_id'] ) : '-1';
924 }
925 $redirectInEmail = isset( $_POST['redirect_url'] ) ? sanitize_text_field( $_POST['redirect_url'] ) : '';
926 $isRedirectInForm = isset( $_POST['is_redirect_url_click'] ) ? sanitize_text_field( $_POST['is_redirect_url_click'] ) : false;
927 if ( $isRedirectInForm ) {
928 $redirectInForm = isset( $_POST['redirect_url_click'] ) ? sanitize_text_field( $_POST['redirect_url_click'] ) : '';
929 }
930
931 // get available attributes list.
932 $attributes = SIB_API_Manager::get_attributes();
933 $attributes = array_merge( $attributes['attributes']['normal_attributes'],$attributes['attributes']['category_attributes'] );
934 $available_attrs = array( 'email' );
935 if ( isset( $attributes ) && is_array( $attributes ) ) {
936 foreach ( $attributes as $attribute ) {
937 $pos = strpos( $form_html, 'sib-' . $attribute['name'] . '-area' );
938 if ( false !== $pos ) {
939 $available_attrs[] = $attribute['name'];
940 }
941 }
942 }
943 $successMsg = isset( $_POST['alert_success_message'] ) ? sanitize_text_field( esc_attr ($_POST['alert_success_message'] ) ) : '';
944 $errorMsg = isset( $_POST['alert_error_message'] ) ? sanitize_text_field( esc_attr( $_POST['alert_error_message'] ) ) : '';
945 $existMsg = isset( $_POST['alert_exist_subscriber'] ) ? sanitize_text_field( esc_attr( $_POST['alert_exist_subscriber'] ) ) : '';
946 $invalidMsg = isset( $_POST['alert_invalid_email'] ) ? sanitize_text_field( esc_attr( $_POST['alert_invalid_email'] ) ) : '';
947 $requiredMsg = isset( $_POST['alert_required_message']) ? sanitize_text_field( esc_attr($_POST['alert_required_message'])) : '';
948 $formData = array(
949 'title' => $form_name,
950 'html' => $form_html,
951 'css' => $customCss,
952 'listID' => $list_ids,
953 'dependTheme' => $dependTheme,
954 'isOpt' => $isOpt,
955 'isDopt' => $isDopt,
956 'templateID' => $templateID,
957 'confirmID' => $confirmID,
958 'redirectInEmail' => $redirectInEmail,
959 'redirectInForm' => $redirectInForm,
960 'successMsg' => $successMsg,
961 'errorMsg' => $errorMsg,
962 'existMsg' => $existMsg,
963 'invalidMsg' => $invalidMsg,
964 'requiredMsg' => $requiredMsg,
965 'attributes' => implode( ',', $available_attrs ),
966 'gcaptcha' => $gCaptcha,
967 'gcaptcha_secret' => $gCaptchaSecret,
968 'gcaptcha_site' => $gCaptchaSite,
969 'termAccept' => $termAccept,
970 'termsURL' => $termURL,
971 );
972 if ( 'new' === $formID ) {
973 $formID = SIB_Forms::addForm( $formData );
974 if ( '' !== $pid ) {
975 $transID = SIB_Forms_Lang::add_form_ID( $formID, $pid, $lang );
976 }
977 } else {
978 SIB_Forms::updateForm( $formID, $formData );
979 }
980 if ( '' !== $pid ) {
981 wp_safe_redirect(
982 add_query_arg(
983 array(
984 'page' => self::PAGE_ID,
985 'action' => 'edit',
986 'id' => $formID,
987 'pid' => $pid,
988 'lang' => $lang,
989 ), admin_url( 'admin.php' )
990 )
991 );
992 exit();
993 } else {
994 wp_safe_redirect(
995 add_query_arg(
996 array(
997 'page' => self::PAGE_ID,
998 'action' => 'edit',
999 'id' => $formID,
1000 ), admin_url( 'admin.php' )
1001 )
1002 );
1003 exit();
1004 }
1005 }
1006
1007 /** Ajax process when change template id */
1008 public static function ajax_change_template() {
1009 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1010 $template_id = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '';
1011 $mailin = new SendinblueApiClient( );
1012 $data = array(
1013 'id' => $template_id,
1014 );
1015 $response = $mailin->getEmailTemplate( $data["id"] );
1016
1017 $ret_email = '-1';
1018 if ( $mailin->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK) {
1019 $from_email = $response[0]['sender']['email'];
1020 if ( '[DEFAULT_FROM_EMAIL]' == $from_email ) {
1021 $ret_email = '-1';
1022 } else {
1023 $ret_email = $from_email;
1024 }
1025 }
1026 wp_send_json( $ret_email );
1027 }
1028
1029 /**
1030 * Ajax module to get all lists.
1031 */
1032 public static function ajax_get_lists() {
1033 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1034 $lists = SIB_API_Manager::get_lists();
1035 $frmID = isset( $_POST['frmid'] ) ? sanitize_text_field( $_POST['frmid'] ) : '';
1036 $formData = SIB_Forms::getForm( $frmID );
1037 $result = array(
1038 'lists' => $lists,
1039 'selected' => $formData['listID'],
1040 );
1041 wp_send_json( $result );
1042 }
1043
1044 /**
1045 * Ajax module to get all templates.
1046 */
1047 public static function ajax_get_templates() {
1048 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1049 $templates = SIB_API_Manager::get_templates();
1050 $result = array(
1051 'templates' => $templates,
1052 );
1053 wp_send_json( $result );
1054 }
1055
1056 /**
1057 * Ajax module to get all attributes.
1058 */
1059 public static function ajax_get_attributes() {
1060 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1061 $attrs = SIB_API_Manager::get_attributes();
1062 $result = array(
1063 'attrs' => $attrs,
1064 );
1065 wp_send_json( $result );
1066 }
1067
1068 /**
1069 * Ajax module to update form html for preview
1070 */
1071 public static function ajax_update_html() {
1072 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1073 $gCaptchaType = isset( $_POST['gCaptchaType']) ? sanitize_text_field($_POST['gCaptchaType']) : '1';
1074 $gCaptcha = isset( $_POST['gCaptcha'] ) ? sanitize_text_field($_POST['gCaptcha']) : '0';
1075 if ( $gCaptcha != '0' ) {
1076 if( $gCaptchaType == '1' ) {
1077 $gCaptcha = '2';
1078 }
1079 elseif ( $gCaptchaType == '0' ) {
1080 $gCaptcha = '3';
1081 }
1082 }
1083 $formData = array(
1084 'html' => isset( $_POST['frmData'] ) ? wp_kses($_POST['frmData'], SIB_Manager::wordpress_allowed_attributes()) : '',// phpcs:ignore
1085 'css' => isset( $_POST['frmCss'] ) ? sanitize_text_field($_POST['frmCss']) : '',
1086 'dependTheme' => isset( $_POST['isDepend'] ) ? sanitize_text_field($_POST['isDepend']) : '',
1087 'gCaptcha' => $gCaptcha,
1088 'gCaptcha_site' => isset( $_POST['gCaptchaSite'] ) ? sanitize_text_field($_POST['gCaptchaSite']) : ''
1089 );
1090
1091 update_option( SIB_Manager::PREVIEW_OPTION_NAME, $formData );
1092 die;
1093 }
1094
1095 /**
1096 * Ajax module to copy content from origin form for translation
1097 */
1098 public static function ajax_copy_origin_form() {
1099 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1100 $pID = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : 1;
1101 $formData = SIB_Forms::getForm( $pID );
1102 // phpcs:ignore
1103 $html = $formData['html'];
1104
1105 wp_send_json( $html );
1106 }
1107 }
1108 }
1109