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