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