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