PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.1.68
Brevo – Email, SMS, Web Push, Chat, and more. v3.1.68
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / page / page-form.php
mailin / page Last commit date
index.php 11 years ago page-form.php 2 years ago page-home.php 2 years ago page-scenarios.php 3 years ago page-statistics.php 3 years ago
page-form.php
1111 lines
1 <?php
2 /**
3 * Admin page : dashboard
4 *
5 * @package SIB_Page_Form
6 */
7
8 if ( ! class_exists( 'SIB_Page_Form' ) ) {
9 /**
10 * Page class that handles backend page <i>dashboard ( for admin )</i> with form generation and processing
11 *
12 * @package SIB_Page_Form
13 */
14 class SIB_Page_Form {
15 /** Page slug */
16 const PAGE_ID = 'sib_page_form';
17
18 /**
19 * Page hook
20 *
21 * @var false|string
22 */
23 protected $page_hook;
24
25 /**
26 * Page tabs
27 *
28 * @var mixed
29 */
30 protected $tabs;
31
32 /**
33 * Form ID
34 *
35 * @var string
36 */
37 public $formID;
38
39 /**
40 * Default compliant Note
41 *
42 * @var string
43 */
44 public $defaultComplianceNote;
45
46 /**
47 * Constructs new page object and adds entry to WordPress admin menu
48 */
49 function __construct() {
50 $title = get_bloginfo('name');
51 $this->defaultComplianceNote = sprintf( esc_attr('Your e-mail address is only used to send you our newsletter and information about the activities of %s. You can always use the unsubscribe link included in the newsletter.', 'mailin'), $title);
52 $this->page_hook = add_submenu_page( SIB_Page_Home::PAGE_ID, __( 'Forms', 'mailin' ), __( 'Forms', 'mailin' ), 'manage_options', self::PAGE_ID, array( &$this, 'generate' ) );
53 add_action( 'admin_print_scripts-' . $this->page_hook, array( $this, 'enqueue_scripts' ) );
54 add_action( 'admin_print_styles-' . $this->page_hook, array( $this, 'enqueue_styles' ) );
55 add_action( 'load-' . $this->page_hook, array( &$this, 'init' ) );
56 }
57
58 /**
59 * Init Process
60 */
61 function Init() {
62 SIB_Manager::is_done_validation();
63 $this->forms = new SIB_Forms_List();
64 $this->forms->prepare_items();
65 }
66
67 /**
68 * Enqueue scripts of plugin
69 */
70 function enqueue_scripts() {
71 wp_enqueue_script( 'sib-admin-js' );
72 wp_enqueue_script( 'sib-bootstrap-js' );
73 wp_enqueue_script( 'sib-chosen-js' );
74
75 wp_localize_script(
76 'sib-admin-js', 'ajax_sib_object',
77 array(
78 'ajax_url' => admin_url( 'admin-ajax.php' ),
79 'ajax_nonce' => wp_create_nonce( 'ajax_sib_admin_nonce' ),
80 'compliance_note' => $this->defaultComplianceNote
81 )
82 );
83 wp_localize_script( 'sib-admin-js', 'sib_img_url', array(SIB_Manager::$plugin_url.'/img/flags/') );
84 }
85
86 /**
87 * Enqueue style sheets of plugin
88 */
89 function enqueue_styles() {
90 wp_enqueue_style( 'sib-admin-css' );
91 wp_enqueue_style( 'sib-bootstrap-css' );
92 wp_enqueue_style( 'sib-chosen-css' );
93 wp_enqueue_style( 'sib-fontawesome-css' );
94 wp_enqueue_style( 'thickbox' );
95 }
96
97 /** Generate page script */
98 function generate() {
99 ?>
100 <div id="wrap" class="wrap box-border-box container-fluid">
101 <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" viewBox="0 0 32 32">
102 <circle cx="16" cy="16" r="16" fill="#0B996E"/>
103 <path fill="#fff" d="M21.002 14.54c.99-.97 1.453-2.089 1.453-3.45 0-2.814-2.07-4.69-5.19-4.69H9.6v20h6.18c4.698 0 8.22-2.874 8.22-6.686 0-2.089-1.081-3.964-2.998-5.174Zm-8.62-5.538h4.573c1.545 0 2.565.877 2.565 2.208 0 1.513-1.329 2.663-4.048 3.54-1.854.574-2.688 1.059-2.997 1.634l-.094.001V9.002Zm3.151 14.796h-3.152v-3.085c0-1.362 1.175-2.693 2.813-3.208 1.453-.484 2.657-.969 3.677-1.482 1.36.787 2.194 2.148 2.194 3.57 0 2.42-2.35 4.205-5.532 4.205Z"/>
104 </svg>
105 <svg xmlns="http://www.w3.org/2000/svg" width="80" height="25" fill="currentColor" viewBox="0 0 90 31">
106 <path fill="#0B996E" d="M73.825 19.012c0-4.037 2.55-6.877 6.175-6.877 3.626 0 6.216 2.838 6.216 6.877s-2.59 6.715-6.216 6.715c-3.626 0-6.175-2.799-6.175-6.715Zm-3.785 0c0 5.957 4.144 10.155 9.96 10.155 5.816 0 10-4.198 10-10.155 0-5.957-4.143-10.314-10-10.314s-9.96 4.278-9.96 10.314ZM50.717 8.937l7.81 19.989h3.665l7.81-19.989h-3.945L60.399 24.37h-.08L54.662 8.937h-3.945Zm-15.18 9.354c.239-3.678 2.67-6.156 5.977-6.156 2.867 0 5.02 1.84 5.338 4.598h-6.614c-2.35 0-3.626.28-4.58 1.56h-.12v-.002Zm-3.784.6c0 5.957 4.183 10.274 9.96 10.274 3.904 0 7.33-1.998 8.804-5.158l-3.187-1.6c-1.115 2.08-3.267 3.319-5.618 3.319-2.83 0-5.379-2.16-5.379-4.238 0-1.08.718-1.56 1.753-1.56h12.63v-1.079c0-5.997-3.825-10.155-9.323-10.155-5.497 0-9.641 4.279-9.641 10.195M20.916 28.924h3.586V16.653c0-2.639 1.632-4.518 3.905-4.518.956 0 1.951.32 2.43.758.36-.96.917-1.918 1.753-2.878-.957-.799-2.59-1.32-4.184-1.32-4.382 0-7.49 3.279-7.49 7.956v12.274-.001Zm-17.33-13.23V5.937h5.896c1.992 0 3.307 1.16 3.307 2.919 0 1.998-1.713 3.518-5.218 4.677-2.39.759-3.466 1.399-3.865 2.16h-.12Zm0 9.794v-4.077c0-1.799 1.514-3.558 3.626-4.238 1.873-.64 3.425-1.28 4.74-1.958 1.754 1.04 2.829 2.837 2.829 4.717 0 3.198-3.028 5.556-7.132 5.556H3.586ZM0 28.926h7.968c6.057 0 10.597-3.798 10.597-8.835 0-2.759-1.393-5.237-3.864-6.836 1.275-1.28 1.873-2.76 1.873-4.559 0-3.717-2.67-6.196-6.693-6.196H0v26.426Z"/>
107 </svg>
108 <div class="row">
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>
132 <div id="sib_modal" class="modal fade" role="dialog">
133 <div class="modal-dialog">
134 <div class="modal-content">
135 <div class="modal-header">
136 <button type="button" class="close" data-dismiss="modal">&times;</button>
137 <h4><?php esc_attr_e( 'You are about to change the language', 'mailin' ); ?></h4>
138 </div>
139 <div class="modal-body">
140 <p><?php esc_attr_e( "Please make sure that you've saved all the changes. We will have to reload the page.", 'mailin' ); ?></p>
141 <p><?php esc_attr_e( 'Do you want to continue?', 'mailin' ); ?></p>
142 </div>
143 <div class="modal-footer">
144 <button type="button" class="btn btn-default" id="sib_modal_ok"><?php esc_attr_e( 'Ok', 'mailin' ); ?></button>
145 <button type="button" class="btn btn-default" id="sib_modal_cancel"><?php esc_attr_e( 'Cancel', 'mailin' ); ?></button>
146 </div>
147 </div>
148 </div>
149 </div>
150 <?php
151 }
152 /** Generate forms page */
153 function generate_forms_page() {
154 ?>
155 <div id="main-content" class="sib-content">
156 <div class="card sib-small-content">
157 <div class="card-header"><strong><?php esc_attr_e( 'Forms', 'mailin' ); ?></strong></div>
158
159 <form method="post" class="sib-forms-wrapper" style="padding:20px;min-height: 500px;">
160 <i style="font-size: 13px;"><?php esc_attr_e( "Note: Forms created in Brevo plugin for WordPress won't be displayed in Forms section in Brevo application", 'mailin' ); ?></i>
161 <?php
162 $this->forms->display();
163 ?>
164 </form>
165 </div>
166 </div>
167 <?php
168 }
169 /** Generate form edit page */
170 function generate_form_edit() {
171 $is_activated_smtp = SIB_API_Manager::get_smtp_status() == 'disabled' ? 0 : 1;
172 $formData = SIB_Forms::getForm( $this->formID );
173 $invisibleCaptcha = '1';
174 if ( ! empty( $formData ) ) {
175 if ( isset( $_GET['action'] ) && 'duplicate' === sanitize_text_field($_GET['action']) ) {
176 $this->formID = 'new';
177 $formData['title'] = '';
178 }
179 if ( 'new' === $this->formID && isset( $_GET['pid'] ) ) {
180 $parent_formData = SIB_Forms::getForm( sanitize_text_field( $_GET['pid'] ) );
181 $formData['title'] = $parent_formData['title'];
182 }
183 if ( ! isset( $formData['gCaptcha'] ) ) {
184 $gCaptcha = '0';
185 }
186 else {
187 if( '0' == $formData['gCaptcha'] ) {
188 $gCaptcha = '0';
189 }
190 else {
191 $gCaptcha = '1';
192 }
193 if ( '3' == $formData['gCaptcha'] ) {
194 $invisibleCaptcha = '0';
195 }
196 else {
197 $invisibleCaptcha = '1';
198 }
199 }
200 if ( ! isset( $formData['termAccept'] ) ) {
201 $formData['termAccept'] = '0';
202 }
203
204 ?>
205 <div id="main-content" class="sib-content">
206 <form action="admin.php" class="" method="post" role="form">
207 <input type="hidden" name="action" value="sib_setting_subscription">
208 <input type="hidden" name="sib_form_id" value="<?php echo esc_attr( $this->formID ) ; ?>">
209 <input type="hidden" id="is_smtp_activated" value="<?php echo esc_attr( $is_activated_smtp ) ; ?>">
210 <?php
211 if ( isset( $_GET['pid'] ) ) {
212 ?>
213 <input type="hidden" name="pid" value="<?php echo esc_attr( $_GET['pid'] ); ?>">
214 <?php
215 $lang = isset( $_GET['lang'] ) ? sanitize_text_field( $_GET['lang'] ) : '';
216 if ( $lang ) { ?>
217 <input type="hidden" name="lang" value="<?php echo esc_attr( $lang ); ?>">
218 <?php
219 }
220 }
221 ?>
222 <?php wp_nonce_field( 'sib_setting_subscription' ); ?>
223 <!-- Subscription form -->
224 <div class="card sib-small-content">
225 <div class="card-header">
226 <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong>&nbsp;<i
227 id="sib_setting_form_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i>
228 </div>
229 <div id="sib_setting_form_body" class="card-body">
230 <div class="row <!--small-content-->">
231 <div style="margin: 12px 0 34px 0px;">
232 <b><?php esc_attr_e( 'Form Name : ', 'mailin' ); ?></b>&nbsp; <input type="text"
233 name="sib_form_name"
234 value="<?php echo esc_attr( $formData['title'] ); ?>"
235 style="width: 60%;"
236 required="required"/>
237 </div>
238 <div class="col-md-6">
239
240 <?php
241 if ( function_exists( 'wp_editor' ) ) {
242 // phpcs:ignore
243 wp_editor(
244 esc_html(stripcslashes($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
255 // phpcs:ignore
256 echo esc_html( $formData['html'] ); ?></textarea>
257 <?php
258 }
259 ?>
260 <br>
261
262 <p>
263 <?php
264 esc_attr_e( 'Use the shortcode', 'mailin' );
265 if ( isset( $_GET['pid'] ) ) {
266 $id = sanitize_text_field( $_GET['pid'] );
267 } else {
268 $id = 'new' !== $this->formID ? $this->formID : '';
269 }
270 ?>
271 <i style="background-color: #eee;padding: 3px;">[sibwp_form
272 id=<?php echo esc_attr( $id ); ?>]</i>
273 <?php
274 esc_attr_e( 'inside a post, page or text widget to display your sign-up form.', 'mailin' );
275 ?>
276 <b><?php esc_attr_e( 'Do not copy and paste the above form mark up, that will not work', 'mailin' ); ?></b>
277 </p>
278 <div id="sib-field-form" class="card form-field"
279 style="padding-bottom: 20px;">
280
281 <div class="small-content2"
282 style="margin-top: 15px;">
283 <b><?php esc_attr_e( 'Add a new Field', 'mailin' ); ?></b>&nbsp;
284 <?php SIB_Page_Home::get_narration_script( __( 'Add a New Field', 'mailin' ), __( 'Choose an attribute and add it to the subscription form of your Website', 'mailin' ) ); ?>
285 </div>
286 <div id="sib_sel_attribute_area" class="small-content2"
287 style="margin-top: 20px;">
288 </div>
289 <div id="sib-field-content">
290 <div style="margin-top: 30px;">
291 <div class="sib-attr-normal sib-attr-category small-content2"
292 style="margin-top: 10px;" id="sib_field_label_area">
293 <?php esc_attr_e( 'Label', 'mailin' ); ?>
294 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small>
295 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_label">
296 </div>
297 <div class="sib-attr-normal small-content2"
298 style="margin-top: 10px;" id="sib_field_placeholder_area">
299 <span><?php esc_attr_e( 'Place holder', 'mailin' ); ?>
300 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)
301 </small> </span>
302 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_placeholder">
303 </div>
304 <div class="sib-attr-normal small-content2"
305 style="margin-top: 10px;" id="sib_field_initial_area">
306 <span><?php esc_attr_e( 'Initial value', 'mailin' ); ?>
307 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)
308 </small> </span>
309 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_initial">
310 </div>
311 <div class="sib-attr-other small-content2"
312 style="margin-top: 10px;" id="sib_field_button_text_area">
313 <span><?php esc_attr_e( 'Button Text', 'mailin' ); ?></span>
314 <input type="text" class="col-md-12 sib_field_changes" id="sib_field_button_text">
315 </div>
316 </div>
317 <div style="margin-top: 20px;">
318
319 <div class="sib-attr-normal sib-attr-category small-content2" style="margin-top: 5px;" id="sib_field_required_area">
320 <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_field_required">&nbsp;&nbsp;<?php esc_attr_e( 'Required field ?', 'mailin' ); ?>
321 </label>
322 </div>
323 <div class="sib-attr-category small-content2"
324 style="margin-top: 5px;" id="sib_field_type_area">
325 <label style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type" value="select"
326 checked>&nbsp;<?php esc_attr_e( 'Drop-down List', 'mailin' ); ?>
327 </label>&nbsp;&nbsp;
328 <label style="font-weight: normal;"><input type="radio" class="sib_field_changes" name="sib_field_type"
329 value="radio">&nbsp;<?php esc_attr_e( 'Radio List', 'mailin' ); ?>
330 </label>
331 </div>
332 </div>
333 <div class="small-content2" style="margin-top: 20px;"
334 id="sib_field_add_area">
335 <button type="button" id="sib_add_to_form_btn"
336 class="btn btn-success sib-add-to-form"><span
337 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
338 </button>&nbsp;&nbsp;
339 <div style="display:none">
340 <input id="getDomain" value="<?php
341 echo plugins_url('mailin/img/flags/') ?>"></input>
342 </div>
343 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
344 </div>
345 <div class="small-content2" style="margin-top: 20px;"
346 id="sib_field_html_area">
347 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
348 <textarea class="col-md-12" style="height: 140px;"
349 id="sib_field_html"></textarea>
350 </div>
351 </div>
352 </div>
353 <!---- multi list per interest ----->
354 <div id="sib-multi-lists" class="card form-field"
355 style="padding-bottom: 20px;">
356
357 <div class="small-content2"
358 style="margin-top: 15px">
359 <b><?php esc_attr_e( 'Add Multi-List Subscription', 'mailin' ); ?></b>&nbsp;
360 <?php SIB_Page_Home::get_narration_script( __( 'Add Multi-List Subscription', 'mailin' ), __( 'Enable your contacts to subscribe to content based on specific interests or preferences. Create a contact list for each interest and allow them to subscribe using this field', 'mailin' ) ); ?>
361 </div>
362 <div id="sib_sel_multi_list_area" class="small-content2"
363 style="margin-top: 20px;">
364 <input type="hidden" id="sib_selected_multi_list_id" value="">
365 <select data-placeholder="<?php esc_attr_e( 'Please select the lists', 'mailin' ); ?>" id="sib_select_multi_list"
366 class="col-md-12 chosen-select" name="multi_list_ids[]" multiple=""
367 tabindex="-1"></select>
368 </div>
369 <div id="sib_multi_list_field" style="display: none;">
370 <div style="margin-top: 30px;">
371 <div class="sib-attr-normal sib-attr-category small-content2"
372 style="margin-top: 10px;" id="sib_multi_field_label_area">
373 <?php esc_attr_e( 'Label', 'mailin' ); ?>
374 <small>(<?php esc_attr_e( 'Optional', 'mailin' ); ?>)</small>
375 <input type="text" class="col-md-12 sib_field_changes" id="sib_multi_field_label">
376 </div>
377 </div>
378 <div style="margin-top: 20px;">
379 <div class="sib-attr-normal sib-attr-category small-content2" style="margin-top: 5px;" id="sib_multi_field_required_area">
380 <label style="font-weight: normal;"><input type="checkbox" class="sib_field_changes" id="sib_multi_field_required">&nbsp;&nbsp;<?php esc_attr_e( 'Required field ?', 'mailin' ); ?>
381 </label>
382 </div>
383 </div>
384 <div class="small-content2" style="margin-top: 20px;"
385 id="sib_multi_field_add_area">
386 <button type="button" id="sib_multi_lists_add_form_btn"
387 class="btn btn-success sib-add-to-form"><span
388 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
389 </button>&nbsp;&nbsp;
390 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
391 </div>
392 <div class="small-content2" style="margin-top: 20px;"
393 id="sib_field_html_area">
394 <span><?php esc_attr_e( 'Generated HTML', 'mailin' ); ?></span>
395 <textarea class="col-md-12" style="height: 140px;"
396 id="sib_multi_field_html"></textarea>
397 </div>
398 </div>
399 </div>
400
401 <div id="sib-gdpr-block" class="card form-field" style="padding-bottom: 20px;">
402 <div class="small-content2"
403 style="margin-top: 15px;margin-bottom: 15px;">
404 <b><?php esc_attr_e( 'Compliance Note', 'mailin' ); ?></b>&nbsp;
405 <?php SIB_Page_Home::get_narration_script( __( 'Add compliance note', 'mailin' ), __( 'Create GDPR-compliant subscription forms for collecting email addresses.', 'mailin' ) ); ?>
406 </div>
407 <div class="small-content2" style="margin-top: 0px;">
408 <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="1" ><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin');?></label>
409 <input type="radio" name="sib_add_compliant_note" class="sib-add-compliant-note" value="0" checked><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin');?></label>
410 </div>
411 <div class="small-content2 sib-gdpr-block-area" style="display: none;">
412 <textarea id="sib_gdpr_text" class="col-md-12" rows="5"><?php echo trim( $this->defaultComplianceNote ); ?></textarea>
413 <label id="set_gdpr_default"><?php esc_attr_e('Reset to Default', 'mailin');?>&nbsp;<i class="fa fa-refresh"></i></label>
414 </div>
415 <div class="small-content2 sib-gdpr-block-btn" style="display: none;">
416 <button type="button" id="sib_add_compliance_note"
417 class="btn btn-success sib-add-to-form"><span
418 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
419 </button>&nbsp;&nbsp;
420 <?php SIB_Page_Home::get_narration_script( __( 'Add to form', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
421 </div>
422 </div>
423
424 <!---- end block ------>
425 <div id="sib_form_captcha" class="card form-field"
426 style="padding-bottom: 20px;">
427 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
428 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
429 <b><?php esc_attr_e( 'Add Captcha', 'mailin' ); ?></b>&nbsp;
430 <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'We are using Google reCaptcha for this form. To use Google reCaptcha on this form, you should input site key and secret key.' , 'mailin' ) ); ?>
431 </div>
432 <div class="small-content2" style="margin-top: 0px;">
433 <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="1" <?php checked( $gCaptcha, '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?></label>
434 <input type="radio" name="sib_add_captcha" class="sib-add-captcha" value="0" <?php checked( $gCaptcha, '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?></label>
435 </div>
436 <div class="small-content2 sib-captcha-key"
437 <?php
438 if ( '1' !== $gCaptcha ) {
439 echo("style='display: none;'");}
440 ?>
441 >
442 <i><?php esc_attr_e( 'Site Key', 'mailin' ); ?></i>&nbsp;
443 <input type="text" class="col-md-12" id="sib_captcha_site" name="sib_captcha_site" value="<?php
444 if ( isset( $formData['gCaptcha_site'] ) && ! empty( $formData['gCaptcha_site'] ) ) {
445 echo esc_attr( $formData['gCaptcha_site'] );
446 } else {
447 echo '';
448 }
449 ?>">
450 </div>
451 <div class="small-content2 sib-captcha-key"
452 <?php
453 if ( '1' !== $gCaptcha ) {
454 echo("style='display: none;'");}
455 ?>
456 >
457 <i><?php esc_attr_e( 'Secret Key', 'mailin' ); ?></i>&nbsp;
458 <input type="text" class="col-md-12" id="sib_captcha_secret" name="sib_captcha_secret" value="<?php
459 if ( isset( $formData['gCaptcha_secret'] ) && ! empty( $formData['gCaptcha_secret'] ) ) {
460 echo esc_attr( $formData['gCaptcha_secret'] );
461 } else {
462 echo '';
463 }
464 ?>">
465 </div>
466 <div class="small-content2 sib-captcha-key"
467 <?php
468 if ( '1' !== $gCaptcha ) {
469 echo("style='display: none;'");}
470 ?>
471 >
472 <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="0" <?php checked( $invisibleCaptcha, '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Google Captcha', 'mailin');?></label>
473 <input type="radio" name="sib_recaptcha_type" class="sib-captcha-type" value="1" <?php checked( $invisibleCaptcha, '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Google Invisible Captcha', 'mailin');?></label>
474 </div>
475 <div class="small-content2 sib-captcha-key"
476 <?php
477 if ( '1' !== $gCaptcha ) {
478 echo("style='display: none;'");}
479 ?>
480 >
481 <button type="button" id="sib_add_captcha_btn"
482 class="btn btn-success sib-add-to-form"><span
483 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
484 </button>&nbsp;&nbsp;
485 <?php SIB_Page_Home::get_narration_script( __( 'Add Captcha', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
486 </div>
487 </div>
488 <div id="sib_form_terms" class="card form-field"
489 style="padding-bottom: 20px;">
490 <div class="alert alert-danger" style="margin:5px;display: none;"></div>
491 <!-- for terms -->
492 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
493 <b><?php esc_attr_e( 'Add a Term acceptance checkbox', 'mailin' ); ?></b>&nbsp;
494 <?php SIB_Page_Home::get_narration_script( __( 'Add a Term acceptance checkbox', 'mailin' ), __( 'If the terms and condition checkbox is added to the form, the field will be mandatory for subscription.' , 'mailin' ) ); ?>
495 </div>
496 <div class="small-content2" style="margin-top: 0px;">
497 <input type="radio" name="sib_add_terms" class="sib-add-terms" value="1" <?php checked( $formData['termAccept'], '1' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'Yes', 'mailin');?></label>
498 <input type="radio" name="sib_add_terms" class="sib-add-terms" value="0" <?php checked( $formData['termAccept'], '0' ); ?>><label class="sib-radio-label">&nbsp;<?php esc_attr_e( 'No', 'mailin');?></label>
499 </div>
500 <div class="small-content2 sib-terms-url"
501 <?php
502 if ( '1' !== $formData['termAccept'] ) {
503 echo("style='display: none;'");}
504 ?>
505 >
506 <i><?php esc_attr_e( 'URL to terms and conditions', 'mailin' ); ?></i>&nbsp;
507 <input type="text" class="col-md-12" id="sib_terms_url" name="sib_terms_url" value="<?php
508 if ( isset( $formData['termsURL'] ) && ! empty( $formData['termsURL'] ) ) {
509 echo esc_attr( $formData['termsURL'] );
510 } else {
511 echo '';
512 }
513 ?>">
514 </div>
515 <div class="small-content2 sib-terms-url"
516 <?php
517 if ( '1' !== $formData['termAccept'] ) {
518 echo("style='display: none;'");}
519 ?>
520 >
521 <button type="button" id="sib_add_termsUrl_btn"
522 class="btn btn-success sib-add-to-form"><span
523 class="sib-large-icon"><</span> <?php esc_attr_e( 'Add to form', 'mailin' ); ?>
524 </button>&nbsp;&nbsp;
525 <?php SIB_Page_Home::get_narration_script( __( 'Add Terms URL', 'mailin' ), __( 'Please click where you want to insert the field and click on this button. By default, the new field will be added at top.', 'mailin' ) ); ?>
526 </div>
527
528 </div>
529 <!-- use css of custom or theme -->
530 <div class="card form-field">
531 <div class="small-content2" style="margin-top: 15px;margin-bottom: 10px;">
532 <b><?php esc_attr_e( 'Form Style', 'mailin' ); ?>&nbsp;</b>
533 <?php SIB_Page_Home::get_narration_script( __( 'Form Style', 'mailin' ), __( 'Select the style you favorite. Your custom css will be applied to form only.', 'mailin' ) ); ?>
534 </div>
535 <div id="sib_form_css_area" class="small-content2" style="margin-bottom: 15px;">
536 <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="1" <?php checked( $formData['dependTheme'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Current Theme', 'mailin' ); ?>
537 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
538 <label style="font-weight: normal;"><input type="radio" name="sib_css_type" value="0" <?php checked( $formData['dependTheme'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'Custom style', 'mailin' ); ?>
539 </label>
540 <textarea class="widefat" cols="60" rows="10" id="sibcssmarkup" style="margin-top: 10px; font-size: 13px; display: <?php echo '0' == $formData['dependTheme'] ? 'block' : 'none'; ?>;"
541 name="sib_form_css"><?php echo esc_textarea( $formData['css'] ); ?></textarea>
542
543 </div>
544
545 </div>
546 </div>
547 <div class="col-md-6">
548 <!-- hidden fields for attributes -->
549 <input type="hidden" id="sib_hidden_email" data-type="email" data-name="email"
550 data-text="<?php esc_attr_e( 'Email Address', 'mailin' ); ?>">
551 <input type="hidden" id="sib_hidden_submit" data-type="submit"
552 data-name="submit" data-text="<?php esc_attr_e( 'Subscribe', 'mailin' ); ?>">
553 <input type="hidden" id="sib_hidden_message_1"
554 value="<?php esc_attr_e( 'Select Brevo Attribute', 'mailin' ); ?>">
555 <input type="hidden" id="sib_hidden_message_2"
556 value="<?php esc_attr_e( 'Brevo merge fields : Normal', 'mailin' ); ?>">
557 <input type="hidden" id="sib_hidden_message_3"
558 value="<?php esc_attr_e( 'Brevo merge fields : Category', 'mailin' ); ?>">
559 <input type="hidden" id="sib_hidden_message_4"
560 value="<?php esc_attr_e( 'Other', 'mailin' ); ?>">
561 <input type="hidden" id="sib_hidden_message_5"
562 value="<?php esc_attr_e( 'Submit Button', 'mailin' ); ?>">
563
564 <!-- preview field -->
565
566 <div class="card form-field">
567 <div class="small-content2" style="margin-top: 15px;margin-bottom: 15px;">
568 <b><?php esc_attr_e( 'Preview', 'mailin' ); ?>&nbsp;
569 <i id="sib-preview-form-refresh" class="fa fa-refresh" style="cursor:pointer;font-weight: bold;" aria-hidden="true"></i>
570 </b>
571 </div>
572 <iframe id="sib-preview-form"
573 src="<?php echo esc_url( site_url() . '/?sib_form=' . esc_attr( $this->formID ) ); ?>"
574 width="300px" height="428" title="SIB Preview Form"></iframe>
575 </div>
576 </div>
577 </div>
578 <div class="sib-small-content" style="margin-top: 30px;">
579 <div class="col-md-3">
580 <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
581 </div>
582 </div>
583 </div>
584 </div> <!-- End Subscription form-->
585
586 <!-- Sign up Process -->
587
588 <div class="card sib-small-content">
589
590 <!-- Adding security through hidden referrer field -->
591 <div class="card-header">
592 <strong><?php esc_attr_e( 'Sign up process', 'mailin' ); ?></strong>&nbsp;<i
593 id="sib_setting_signup_spin" class="fa fa-spinner fa-spin fa-fw fa-lg fa-2x"></i>
594 </div>
595 <div id="sib_setting_signup_body" class="card-body">
596 <div id="sib_form_alert_message" class="alert alert-danger alert-dismissable fade in"
597 role="alert" style="display: none;">
598 <span id="sib_disclaim_smtp"
599 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.brevo.com/" target="_blank" rel="noopener">Click here</a> to send your emails through Brevo in order to improve your deliverability and get statistics', 'mailin' ); ?></span>
600 <span id="sib_disclaim_do_template"
601 style="display: none;"><?php _e( 'The template you selected does not include a link [DOUBLEOPTIN] to allow subscribers to confirm their subscription. <br/> Please edit the template to include a link with [DOUBLEOPTIN] as URL.', 'mailin' ); ?></span>
602 <span id="sib_disclaim_confirm_template"
603 style="display: none;"><?php _e( 'You cannot select a template with the tag [DOUBLEOPTIN]', 'mailin' ); ?></span>
604 </div>
605
606 <!-- Linked List -->
607 <div class="row sib-small-content">
608 <span class="col-md-3">
609 <?php esc_attr_e( 'Linked List', 'mailin' ); ?>&nbsp;
610 <?php SIB_Page_Home::get_narration_script( __( 'Linked List', 'mailin' ), __( 'Select the list where you want to add your new subscribers', 'mailin' ) ); ?>
611 </span>
612 <div id="sib_select_list_area" class="col-md-4">
613
614 <input type="hidden" id="sib_selected_list_id" value="">
615 <select data-placeholder="Please select the list" id="sib_select_list"
616 class="col-md-12 chosen-select" name="list_id[]" multiple=""
617 tabindex="-1"></select>
618 </div>
619 <div class="col-md-5">
620 <small
621 style="font-style: italic;"><?php esc_attr_e( 'You can use Marketing Automation to create specific workflow when a user is added to the list.', 'mailin' ); ?></small>
622 </div>
623
624 </div>
625 <!-- confirmation email -->
626 <div class="row small-content">
627 <span class="col-md-3"><?php esc_attr_e( 'Send a confirmation email', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Confirmation message', 'mailin' ), __( 'You can choose to send a confirmation email. You will be able to set up the template that will be sent to your new suscribers', 'mailin' ) ) ); ?></span>
628
629 <div class="col-md-4">
630 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
631 id="is_confirm_email_yes"
632 name="is_confirm_email"
633 value="1" <?php checked( $formData['isOpt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
634 </label>
635 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
636 id="is_confirm_email_no"
637 name="is_confirm_email"
638 value="0" <?php checked( $formData['isOpt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
639 </label>
640 </div>
641 <div class="col-md-5">
642 <small
643 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to receive a confirmation email', 'mailin' ); ?></small>
644 </div>
645 </div>
646 <!-- select template id for confirmation email -->
647 <div class="row" id="sib_confirm_template_area">
648 <input type="hidden" id="sib_selected_template_id"
649 value="<?php echo esc_attr( $formData['templateID'] ); ?>">
650 <input type="hidden" id="sib_default_template_name"
651 value="<?php esc_attr_e( 'Default', 'mailin' ); ?>">
652
653 <div class="col-md-3" id="sib_template_id_area">
654 </div>
655 <div class="col-md-4">
656 <a href="https://my.brevo.com/camp/lists/template" class="col-md-12"
657 target="_blank" rel="noopener"><i
658 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
659 </a>
660 </div>
661 </div>
662 <!-- double optin confirmation email -->
663 <div class="row sib-small-content mt-3">
664 <span
665 class="col-md-3"><?php esc_attr_e( 'Double Opt-In', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Double Opt-In', 'mailin' ), __( 'Your subscribers will receive an email inviting them to confirm their subscription. Be careful, your subscribers are not saved in your list before confirming their subscription.', 'mailin' ) ) ); ?></span>
666
667 <div class="col-md-4">
668 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
669 id="is_double_optin_yes"
670 name="is_double_optin"
671 value="1" <?php checked( $formData['isDopt'], '1' ); ?>>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
672 </label>
673 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
674 id="is_double_optin_no"
675 name="is_double_optin"
676 value="0" <?php checked( $formData['isDopt'], '0' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
677 </label>
678 </div>
679 <div class="col-md-5">
680 <small
681 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want your subscribers to confirm their email address', 'mailin' ); ?></small>
682 </div>
683 </div>
684 <!-- select template id for double optin confirmation email -->
685 <div class="row" id="sib_doubleoptin_template_area">
686 <input type="hidden" id="sib_selected_do_template_id" value="<?php echo esc_attr( $formData['templateID'] ); ?>">
687 <div class="col-md-3" id="sib_doubleoptin_template_id_area">
688 </div>
689 <div class="col-md-4">
690 <a href="https://my.brevo.com/camp/lists/template"
691 class="col-md-12" target="_blank" rel="noopener"><i
692 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
693 </a>
694 </div>
695 </div>
696 <div class="row sib-small-content mt-3" id="sib_double_redirect_area">
697 <span class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after clicking in the email', 'mailin' ); ?></span>
698
699 <div class="col-md-8">
700 <input type="url" class="col-md-11" name="redirect_url" value="<?php echo esc_attr( $formData['redirectInEmail'] ); ?>">
701 </div>
702 </div>
703 <div class="row sib-small-content mt-3" id="sib_final_confirm_template_area">
704 <span class="col-md-3"><?php esc_attr_e( 'Select final confirmation email template', 'mailin' ); ?><?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Final confirmation', 'mailin' ), __( 'This is the final confirmation email your contacts will receive once they click on the double opt-in confirmation link. You can select one of the default templates we have created for you, e.g. \'Default template - Final confirmation\'.
705 For your information, you cannot select a template with the tag [DOUBLEOPTIN].', 'mailin' ) ) ); ?></span>
706 <div class="row col-md-8">
707 <input type="hidden" id="sib_selected_confirm_template_id" value="<?php echo esc_attr( $formData['confirmID'] );?>">
708 <div class="col-md-5" id="sib_final_confirm_template_id_area">
709 </div>
710 <div class="col-md-4">
711 <a href="https://my.brevo.com/camp/lists/template"
712 class="col-md-12" target="_blank" rel="noopener"><i
713 class="fa fa-angle-right"></i> <?php esc_attr_e( 'Set up my templates', 'mailin' ); ?>
714 </a>
715 </div>
716 </div>
717 </div>
718
719 <div class="row sib-small-content mt-3">
720 <span
721 class="col-md-3"><?php esc_attr_e( 'Redirect to this URL after subscription', 'mailin' ); ?></span>
722
723 <div class="col-md-4">
724 <label class="col-md-6" style="font-weight: normal;"><input type="radio"
725 id="is_redirect_url_click_yes"
726 name="is_redirect_url_click"
727 value="1" checked>&nbsp;<?php esc_attr_e( 'Yes', 'mailin' ); ?>
728 </label>
729 <label class="col-md-5" style="font-weight: normal;"><input type="radio"
730 id="is_redirect_url_click_no"
731 name="is_redirect_url_click"
732 value="0" <?php checked( $formData['redirectInForm'], '' ); ?>>&nbsp;<?php esc_attr_e( 'No', 'mailin' ); ?>
733 </label>
734
735 </div>
736 <div class="col-md-5">
737 <small
738 style="font-style: italic;"><?php esc_attr_e( 'Select "Yes" if you want to redirect your subscribers to a specific page after they fullfill the form', 'mailin' ); ?></small>
739 </div>
740 </div>
741 <div class="row" style="margin-top: 10px;
742 <?php
743 if ( '' == $formData['redirectInForm'] ) {
744 echo 'display:none;';
745 }
746 ?>
747 " id="sib_subscrition_redirect_area">
748 <span class="col-md-3"></span>
749
750 <div class="col-md-8">
751 <input type="url" class="col-md-11" name="redirect_url_click"
752 value="<?php echo esc_attr( $formData['redirectInForm'] ); ?>">
753 </div>
754 </div>
755
756 <div class="row sib-small-content" style="margin-top: 30px;">
757 <div class="col-md-3">
758 <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
759 </div>
760 </div>
761
762 </div>
763 </div><!-- End Sign up process form-->
764
765 <!-- Confirmation message form -->
766 <div class="card sib-small-content">
767 <div class="card-header">
768 <strong><?php esc_attr_e( 'Confirmation message', 'mailin' ); ?></strong>
769 </div>
770 <div class="card-body">
771 <div class="row sib-small-content mt-3">
772 <!-- <span class="col-md-3"></span> -->
773 <label for="inputEmail3" class="col-md-3"><?php esc_attr_e( 'Success message', 'mailin' ); ?></label>
774 <div class="col-md-8">
775 <input type="text" class="col-md-11" name="alert_success_message"
776 value="<?php echo esc_attr( $formData['successMsg'] ); ?>" required>&nbsp;
777 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Success message', 'mailin' ), __( 'Set up the success message that will appear when one of your visitors surccessfully signs up', 'mailin' ) ) ); ?>
778 </div>
779 </div>
780 <div class="row sib-small-content mt-3">
781 <span class="col-md-3"><?php esc_attr_e( 'General error message', 'mailin' ); ?></span>
782
783 <div class="col-md-8">
784 <input type="text" class="col-md-11" name="alert_error_message"
785 value="<?php echo esc_attr( $formData['errorMsg'] ); ?>" required>&nbsp;
786 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'General message error', 'mailin' ), __( 'Set up the message that will appear when an error occurs during the subscritpion process', 'mailin' ) ) ); ?>
787 </div>
788 </div>
789 <!--
790 <div class="row sib-small-content mt-3">
791 <span class="col-md-3"><?php esc_attr_e( 'Existing subscribers', 'mailin' ); ?></span>
792
793 <div class="col-md-8">
794 <input type="text" class="col-md-11" name="alert_exist_subscriber"
795 value="<?php echo esc_attr( $formData['existMsg'] ); ?>" required>&nbsp;
796 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Existing Suscribers', 'mailin' ), __( 'Set up the message that will appear when a suscriber is already in your database', 'mailin' ) ) ); ?>
797 </div>
798 </div>
799 -->
800 <div class="row sib-small-content mt-3">
801 <span class="col-md-3"><?php esc_attr_e( 'Invalid email address', 'mailin' ); ?></span>
802
803 <div class="col-md-8">
804 <input type="text" class="col-md-11" name="alert_invalid_email"
805 value="<?php echo esc_attr( $formData['invalidMsg'] ); ?>" required>&nbsp;
806 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Invalid email address', 'mailin' ), __( 'Set up the message that will appear when the email address used to sign up is not valid', 'mailin' ) ) ); ?>
807 </div>
808 </div>
809 <div class="row sib-small-content mt-3">
810 <span class="col-md-3"><?php esc_attr_e( 'Required Field', 'mailin' ); ?></span>
811
812 <div class="col-md-8">
813 <input type="text" class="col-md-11" name="alert_required_message"
814 value="<?php echo esc_attr( $formData['requiredMsg'] ); ?>" required>&nbsp;
815 <?php echo esc_html( SIB_Page_Home::get_narration_script( __( 'Required Field', 'mailin' ), __( 'Set up the message that will appear when the required field is empty', 'mailin' ) ) ); ?>
816 </div>
817 </div>
818 <div class="row sib-small-content" style="margin-top: 30px;">
819 <div class="col-md-3">
820 <button class="btn btn-success"><?php esc_attr_e( 'Save', 'mailin' ); ?></button>
821 </div>
822 </div>
823 </div>
824 </div> <!-- End Confirmation message form-->
825 </form>
826 </div>
827 <script>
828 jQuery(document).ready(function () {
829 jQuery('#sib_add_to_form_btn').click(function () {
830 //var field_html = jQuery('#sib_field_html').html();
831
832 // tinyMCE.activeEditor.selection.setContent(field_html);
833
834 return false;
835 });
836 });
837 </script>
838 <?php
839 } else {
840 // If empty?
841 ?>
842 <div id="main-content" class="sib-content">
843 <div class="card sib-small-content">
844 <div class="card-header">
845 <strong><?php esc_attr_e( 'Subscription form', 'mailin' ); ?></strong>
846 </div>
847 <div style="padding: 24px 32px; margin-bottom: 12px;">
848 <?php esc_attr_e( 'Sorry, you selected invalid form ID. Please check again if the ID is right', 'mailin' ); ?>
849 </div>
850 </div>
851 </div>
852 <?php
853 }
854 }
855
856 /** Generate welcome page */
857 function generate_welcome_page() {
858 ?>
859 <div id="main-content" class="row">
860 <img class="small-content" src="<?php echo esc_url( SIB_Manager::$plugin_url . '/img/background/setting.png' ); ?>" alt="Settings Image" style="width: 100%;">
861 </div>
862 <?php
863 SIB_Page_Home::print_disable_popup();
864 }
865
866 /** Save subscription form setting */
867 public static function save_setting_subscription() {
868 // Check user role.
869 if ( ! current_user_can( 'manage_options' ) ) {
870 wp_die( 'Not allowed' );
871 }
872
873 // Check secret through hidden referrer field.
874 check_admin_referer( 'sib_setting_subscription' );
875
876 //Handling of backslash added by WP because magic quotes are enabled by default
877 array_walk_recursive( $_POST, function(&$value) {
878 $value = stripslashes($value);
879 });
880
881 // Subscription form.
882 $formID = isset( $_POST['sib_form_id'] ) ? sanitize_text_field( $_POST['sib_form_id'] ) : '';
883 $form_name = isset( $_POST['sib_form_name'] ) ? sanitize_text_field( $_POST['sib_form_name'] ) : '';
884 // phpcs:disable
885 $form_html = isset( $_POST['sib_form_html'] ) ? wp_kses($_POST['sib_form_html'], SIB_Manager::wordpress_allowed_attributes()) : '';
886 $list_ids = '';
887
888 if (!empty($_POST['list_id']) && is_array($_POST['list_id'])) {
889 $list_ids = array_filter($_POST['list_id'], 'intval');
890 $list_ids = maybe_serialize($list_ids);
891 }
892
893 // phpcs:enable
894 $dependTheme = isset( $_POST['sib_css_type'] ) ? sanitize_text_field( $_POST['sib_css_type'] ) : '';
895 $customCss = isset( $_POST['sib_form_css'] ) ? sanitize_text_field( $_POST['sib_form_css'] ) : '';
896 $gCaptcha = isset( $_POST['sib_add_captcha'] ) ? sanitize_text_field( $_POST['sib_add_captcha'] ) : '0';
897 $gCaptchaSecret = isset( $_POST['sib_captcha_secret'] ) ? sanitize_text_field( $_POST['sib_captcha_secret'] ) : '';
898 $gCaptchaSite = isset( $_POST['sib_captcha_site'] ) ? sanitize_text_field( $_POST['sib_captcha_site'] ) : '';
899 $termAccept = isset( $_POST['sib_add_terms'] ) ? sanitize_text_field( $_POST['sib_add_terms'] ) : '0';
900 $termURL = isset( $_POST['sib_terms_url'] ) ? sanitize_text_field( $_POST['sib_terms_url'] ) : '';
901 $gCaptchaType = isset( $_POST['sib_recaptcha_type'] ) ? sanitize_text_field( $_POST['sib_recaptcha_type'] ) : '0';
902 if ( $gCaptcha != '0' ) {
903 if ( $gCaptchaType == '0' ) {
904 $gCaptcha = '3'; // google recaptcha.
905 }
906 elseif ( $gCaptchaType == '1' ) {
907 $gCaptcha = '2'; // google invisible recaptcha.
908 }
909 }
910 // for wpml plugins.
911 $pid = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : '';
912 $lang = isset( $_POST['lang'] ) ? sanitize_text_field( $_POST['lang'] ) : '';
913 // sign up process.
914 $templateID = '-1';
915 $confirmID = '-1';
916 $redirectInForm = '';
917
918 $isOpt = isset( $_POST['is_confirm_email'] ) ? sanitize_text_field( $_POST['is_confirm_email'] ) : false;
919 if ( $isOpt ) {
920 $templateID = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '-1';
921 }
922 $isDopt = isset( $_POST['is_double_optin'] ) ? sanitize_text_field( $_POST['is_double_optin'] ) : false;
923 if ( $isDopt ) {
924 $templateID = isset( $_POST['doubleoptin_template_id'] ) ? sanitize_text_field( $_POST['doubleoptin_template_id'] ) : '-1';
925 $confirmID = isset( $_POST['confirm_template_id'] ) ? sanitize_text_field( $_POST['confirm_template_id'] ) : '-1';
926 }
927 $redirectInEmail = isset( $_POST['redirect_url'] ) ? sanitize_text_field( $_POST['redirect_url'] ) : '';
928 $isRedirectInForm = isset( $_POST['is_redirect_url_click'] ) ? sanitize_text_field( $_POST['is_redirect_url_click'] ) : false;
929 if ( $isRedirectInForm ) {
930 $redirectInForm = isset( $_POST['redirect_url_click'] ) ? sanitize_text_field( $_POST['redirect_url_click'] ) : '';
931 }
932
933 // get available attributes list.
934 $attributes = SIB_API_Manager::get_attributes();
935 $attributes = array_merge( $attributes['attributes']['normal_attributes'],$attributes['attributes']['category_attributes'] );
936 $available_attrs = array( 'email' );
937 if ( isset( $attributes ) && is_array( $attributes ) ) {
938 foreach ( $attributes as $attribute ) {
939 $pos = strpos( $form_html, 'sib-' . $attribute['name'] . '-area' );
940 if ( false !== $pos ) {
941 $available_attrs[] = $attribute['name'];
942 }
943 }
944 }
945 $successMsg = isset( $_POST['alert_success_message'] ) ? sanitize_text_field( esc_attr ($_POST['alert_success_message'] ) ) : '';
946 $errorMsg = isset( $_POST['alert_error_message'] ) ? sanitize_text_field( esc_attr( $_POST['alert_error_message'] ) ) : '';
947 $existMsg = isset( $_POST['alert_exist_subscriber'] ) ? sanitize_text_field( esc_attr( $_POST['alert_exist_subscriber'] ) ) : '';
948 $invalidMsg = isset( $_POST['alert_invalid_email'] ) ? sanitize_text_field( esc_attr( $_POST['alert_invalid_email'] ) ) : '';
949 $requiredMsg = isset( $_POST['alert_required_message']) ? sanitize_text_field( esc_attr($_POST['alert_required_message'])) : '';
950 $formData = array(
951 'title' => $form_name,
952 'html' => $form_html,
953 'css' => $customCss,
954 'listID' => $list_ids,
955 'dependTheme' => $dependTheme,
956 'isOpt' => $isOpt,
957 'isDopt' => $isDopt,
958 'templateID' => $templateID,
959 'confirmID' => $confirmID,
960 'redirectInEmail' => $redirectInEmail,
961 'redirectInForm' => $redirectInForm,
962 'successMsg' => $successMsg,
963 'errorMsg' => $errorMsg,
964 'existMsg' => $existMsg,
965 'invalidMsg' => $invalidMsg,
966 'requiredMsg' => $requiredMsg,
967 'attributes' => implode( ',', $available_attrs ),
968 'gcaptcha' => $gCaptcha,
969 'gcaptcha_secret' => $gCaptchaSecret,
970 'gcaptcha_site' => $gCaptchaSite,
971 'termAccept' => $termAccept,
972 'termsURL' => $termURL,
973 );
974 if ( 'new' === $formID ) {
975 $formID = SIB_Forms::addForm( $formData );
976 if ( '' !== $pid ) {
977 $transID = SIB_Forms_Lang::add_form_ID( $formID, $pid, $lang );
978 }
979 } else {
980 SIB_Forms::updateForm( $formID, $formData );
981 }
982 if ( '' !== $pid ) {
983 wp_safe_redirect(
984 add_query_arg(
985 array(
986 'page' => self::PAGE_ID,
987 'action' => 'edit',
988 'id' => $formID,
989 'pid' => $pid,
990 'lang' => $lang,
991 ), admin_url( 'admin.php' )
992 )
993 );
994 exit();
995 } else {
996 wp_safe_redirect(
997 add_query_arg(
998 array(
999 'page' => self::PAGE_ID,
1000 'action' => 'edit',
1001 'id' => $formID,
1002 ), admin_url( 'admin.php' )
1003 )
1004 );
1005 exit();
1006 }
1007 }
1008
1009 /** Ajax process when change template id */
1010 public static function ajax_change_template() {
1011 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1012 $template_id = isset( $_POST['template_id'] ) ? sanitize_text_field( $_POST['template_id'] ) : '';
1013 $mailin = new SendinblueApiClient( );
1014 $data = array(
1015 'id' => $template_id,
1016 );
1017 $response = $mailin->getEmailTemplate( $data["id"] );
1018
1019 $ret_email = '-1';
1020 if ( $mailin->getLastResponseCode() === SendinblueApiClient::RESPONSE_CODE_OK) {
1021 $from_email = $response[0]['sender']['email'];
1022 if ( '[DEFAULT_FROM_EMAIL]' == $from_email ) {
1023 $ret_email = '-1';
1024 } else {
1025 $ret_email = $from_email;
1026 }
1027 }
1028 wp_send_json( $ret_email );
1029 }
1030
1031 /**
1032 * Ajax module to get all lists.
1033 */
1034 public static function ajax_get_lists() {
1035 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1036 $lists = SIB_API_Manager::get_lists();
1037 $frmID = isset( $_POST['frmid'] ) ? sanitize_text_field( $_POST['frmid'] ) : '';
1038 $formData = SIB_Forms::getForm( $frmID );
1039 $result = array(
1040 'lists' => $lists,
1041 'selected' => $formData['listID'],
1042 );
1043 wp_send_json( $result );
1044 }
1045
1046 /**
1047 * Ajax module to get all templates.
1048 */
1049 public static function ajax_get_templates() {
1050 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1051 $templates = SIB_API_Manager::get_templates();
1052 $result = array(
1053 'templates' => $templates,
1054 );
1055 wp_send_json( $result );
1056 }
1057
1058 /**
1059 * Ajax module to get all attributes.
1060 */
1061 public static function ajax_get_attributes() {
1062 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1063 $attrs = SIB_API_Manager::get_attributes();
1064 $result = array(
1065 'attrs' => $attrs,
1066 );
1067 wp_send_json( $result );
1068 }
1069
1070 /**
1071 * Ajax module to update form html for preview
1072 */
1073 public static function ajax_update_html() {
1074 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1075 $gCaptchaType = isset( $_POST['gCaptchaType']) ? sanitize_text_field($_POST['gCaptchaType']) : '1';
1076 $gCaptcha = isset( $_POST['gCaptcha'] ) ? sanitize_text_field($_POST['gCaptcha']) : '0';
1077 if ( $gCaptcha != '0' ) {
1078 if( $gCaptchaType == '1' ) {
1079 $gCaptcha = '2';
1080 }
1081 elseif ( $gCaptchaType == '0' ) {
1082 $gCaptcha = '3';
1083 }
1084 }
1085 $formData = array(
1086 'html' => isset( $_POST['frmData'] ) ? wp_kses($_POST['frmData'], SIB_Manager::wordpress_allowed_attributes()) : '',// phpcs:ignore
1087 'css' => isset( $_POST['frmCss'] ) ? sanitize_text_field($_POST['frmCss']) : '',
1088 'dependTheme' => isset( $_POST['isDepend'] ) ? sanitize_text_field($_POST['isDepend']) : '',
1089 'gCaptcha' => $gCaptcha,
1090 'gCaptcha_site' => isset( $_POST['gCaptchaSite'] ) ? sanitize_text_field($_POST['gCaptchaSite']) : ''
1091 );
1092
1093 update_option( SIB_Manager::PREVIEW_OPTION_NAME, $formData );
1094 die;
1095 }
1096
1097 /**
1098 * Ajax module to copy content from origin form for translation
1099 */
1100 public static function ajax_copy_origin_form() {
1101 check_ajax_referer( 'ajax_sib_admin_nonce', 'security' );
1102 $pID = isset( $_POST['pid'] ) ? sanitize_text_field( $_POST['pid'] ) : 1;
1103 $formData = SIB_Forms::getForm( $pID );
1104 // phpcs:ignore
1105 $html = $formData['html'];
1106
1107 wp_send_json( $html );
1108 }
1109 }
1110 }
1111