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