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