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