Plugin Directory

source: arforms-form-builder/tags/1.6.3/core/controllers/arfliteformcontroller.php

Last change on this file was 3040281, checked in by reputeinfosystems, 14 months ago

=1.6.3=
Improved field sorting experience in editor with field swapping
Other minor bug fixes

File size: 372.9 KB
Line 
1<?php
2
3global $arflite_memory_limit, $arflitememorylimit, $arfliteversion;
4if ( isset( $arflite_memory_limit ) && isset( $arflitememorylimit ) && ( $arflite_memory_limit * 1024 * 1024 ) > $arflitememorylimit ) {
5        @ini_set( 'memory_limit', $arflite_memory_limit . 'M' );
6}
7class arfliteformcontroller {
8        function __construct() {
9                //add_action( 'admin_menu', array( $this, 'arflitemenu' ) );
10
11                add_action( 'admin_head-toplevel_page_ARForms', array( $this, 'arflitehead' ) );
12
13                add_action( 'admin_footer', array( $this, 'arflite_insert_form_popup' ) );
14
15                add_action( 'wp_ajax_arflite_change_show_hide_column', array( $this, 'arflite_change_show_hide_column' ) );
16
17                add_action( 'wp_ajax_arfliteupdateformbulkoption', array( $this, 'arfliteupdateformbulkoption' ) );
18
19                add_action( 'wp_ajax_arfliteformsavealloptions', array( $this, 'arfliteformsavealloptions' ) );
20
21                add_action( 'ARFormslite_shortcode_atts', array( $this, 'ARFormslite_shortcode_atts' ) );
22
23                add_action( 'media_buttons', array( $this, 'arflite_insert_form_button' ), 20 );
24
25                add_action( 'wp_ajax_arflitesavepreviewdata', array( $this, 'arfliteformsavealloptions' ) );
26
27                add_action( 'wp_ajax_arflite_delete_form', array( $this, 'arflite_delete_form_function' ) );
28
29                add_action( 'wp_ajax_arflite_csv_form', array( $this, 'arflite_csv_form_function' ) );
30
31                add_action( 'wp_ajax_arflitechangestyle', array( $this, 'arflite_change_input_style' ) );
32
33                add_action( 'wp_ajax_arflite_send_form_data_admin', array( $this, 'arflite_upload_image_from_admin' ) );
34
35                add_filter( 'arfliteadminactionformlist', array( $this, 'arflite_process_bulk_form_actions' ) );
36
37                add_filter( 'getarflitestylesheet', array( $this, 'arflitecustom_stylesheet' ), 10, 2 );
38
39                add_filter( 'arflitecontent', array( $this, 'arflite_filter_content' ), 10, 3 );
40
41                add_filter( 'plugin_action_links_' . ARFLITE_PLUGIN_BASE_FILE, array( $this, 'arflite_add_action_links' ) );
42
43                add_filter( 'arflite_after_submit_sucess_outside', array( $this, 'arflite_after_submit_sucess_outside_function' ), 10, 2 );
44
45                add_filter( 'arflite_replace_default_value_shortcode', array( $this, 'arflite_replace_default_value_shortcode_func' ), 10, 3 );
46
47                add_action( 'wp_ajax_arflite_remove_preview_opt', array( $this, 'arflite_remove_preview_data' ) );
48
49                add_action( 'arflite_rewrite_css_after_update', array( $this, 'arflite_rewrite_form_css' ), 10, 2 );
50
51        }
52
53        function arflite_upload_image_from_admin() {
54
55                $fn = ( isset( $_SERVER['HTTP_X_FILENAME'] ) ? sanitize_file_name( $_SERVER['HTTP_X_FILENAME'] ) : false );
56
57                if ( $fn && isset( $_FILES['files']['name'] ) ) {
58
59                        $upload_main_url = ARFLITE_UPLOAD_DIR;
60
61                        $arflitefilecontroller = new arflitefilecontroller( $_FILES['files'], false ); //phpcs:ignore
62
63                        if ( ! $arflitefilecontroller ) {
64                                echo '<p class="error_upload">' . $arflitefilecontroller->error_message . '</p>'; //phpcs:ignore
65                                die;
66                        }
67
68                        $arflitefilecontroller->check_cap    = true;
69                        $arflitefilecontroller->capabilities = array( 'arfviewforms', 'arfeditforms', 'arfchangesettings' );
70
71                        $arflitefilecontroller->check_nonce = true;
72                        $arflitefilecontroller->nonce_data  = isset( $_POST['_wpnonce_arflite'] ) ? sanitize_text_field( $_POST['_wpnonce_arflite'] ) : ''; //phpcs:ignore
73
74                        $arflitefilecontroller->nonce_action     = 'arflite_wp_nonce';
75                        $arflitefilecontroller->check_only_image = true;
76
77                        $arflitefilecontroller->check_specific_ext = false;
78                        $arflitefilecontroller->allowed_ext        = array();
79
80                        $destination = $upload_main_url . '/' . $fn;
81
82                        $upload_file = $arflitefilecontroller->arflite_process_upload( $destination );
83
84                        if ( false == $upload_file ) {
85                                echo '<p class="error_upload">' .$arflitefilecontroller->error_message . '</p>'; //phpcs:ignore
86                                die;
87                        } else {
88                                echo esc_html( $fn );
89                                die;
90                        }
91                }
92
93                die;
94
95        }
96
97        function arflite_upload_file_function( $source, $destination ) {
98                if ( empty( $source ) || empty( $destination ) ) {
99                        return false;
100                }
101
102                if ( ! function_exists( 'WP_Filesystem' ) ) {
103                        require_once ABSPATH . 'wp-admin/includes/file.php';
104                }
105
106                WP_Filesystem();
107                global $wp_filesystem;
108
109                $file_content = $wp_filesystem->get_contents( $source );
110
111                $wp_filesystem->put_contents( $destination, $file_content, 0777 );
112
113                return true;
114        }
115
116        function arflite_add_action_links( $links ) {
117                global $arformsmain;
118                $mylinks = array();
119
120                if( !$arformsmain->arforms_is_pro_active() ){
121                        $mylinks[] = '<a href="https://www.arformsplugin.com/thank-you/?utm_source=lite_version&utm_medium=wordpress_org&utm_campaign=upgrade_to_pro" target="_blank" rel="noopener noreferrer" style="font-weight:bold;">' . __( 'Upgrade To Premium', 'arforms-form-builder' ) . '</a>';
122                }
123
124                $mylinks[] = '<a href="' . esc_url_raw( admin_url( 'admin.php?page=ARForms-addons' ) ) . '">Addons</a>';
125
126                return array_merge( $mylinks, $links );
127        }
128
129        function arflite_class_to_hide_form( $id, $hide_form = false ) {
130                global $wpdb, $ARFLiteMdlDb,$arflitemainhelper, $tbl_arf_forms;
131
132                $form_data = wp_cache_get( 'arflite_form_options_' . $id );
133                if ( false == $form_data ) {
134                        $form_data = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM `' . $tbl_arf_forms . '` WHERE `id` = %d', $id ) ); //phpcs:ignore
135                        wp_cache_set( 'arflite_form_options_' . $id, $form_data );
136                }
137
138                if ( empty( $form_data ) ) {
139                        return;
140                }
141
142                $form_options = $form_data->options;
143                if ( ! is_array( $form_data->options ) ) {
144                        $form_options = maybe_unserialize( $form_data->options );
145                }
146
147                $arf_disable_form  = false;
148                $arf_current_token = $arflitemainhelper->arflite_generate_captcha_code( 10 );
149                if ( isset( $_SESSION[ 'arf_form_' . $arf_current_token . '_fileuploads' ] ) ) {
150                        $_SESSION[ 'arf_form_' . $arf_current_token . '_fileuploads' ] = array(); }
151
152                return '';
153        }
154
155        function arflite_include_remove_form_func( $form, $values ) {
156                require ARFLITE_VIEWS_PATH . '/arflite_form.php';
157        }
158
159        function arflite_process_bulk_form_actions( $arflite_errors ) {
160
161                if ( !isset( $_GET['arflite_page_nonce'] ) || ( isset( $_GET['arflite_page_nonce'] ) && '' != $_GET['arflite_page_nonce'] && wp_verify_nonce( sanitize_text_field( $_GET['arflite_page_nonce'] ), 'arflite_page_nonce' ) ) ) {
162                        return;
163                }
164
165                if ( ! isset( $_POST ) ) {
166                        return;
167                }
168
169                global $arfliteform, $arflitemainhelper;
170
171                $bulkaction = $arflitemainhelper->arflite_get_param( 'action1' );
172
173                if ( $bulkaction == -1 ) {
174                        $bulkaction = $arflitemainhelper->arflite_get_param( 'action2' );
175                }
176
177                if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
178
179                        if ( isset( $_GET ) && isset( $_GET['action1'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
180                                $_SERVER['REQUEST_URI'] = str_replace( '&action=' . sanitize_text_field( $_GET['action1'] ), '', esc_url_raw( $_SERVER['REQUEST_URI'] ) );
181                        }
182
183                        if ( isset( $_GET ) && isset( $_GET['action2'] ) ) {
184                                $_SERVER['REQUEST_URI'] = str_replace( '&action=' . sanitize_text_field( $_GET['action2'] ), '', esc_url_raw( $_SERVER['REQUEST_URI'] ) );
185                        }
186
187                        $bulkaction = str_replace( 'bulk_', '', $bulkaction );
188                } else {
189
190                        $bulkaction = '-1';
191
192                        if ( isset( $_POST['bulkaction1'] ) && $_POST['bulkaction1'] != '-1' ) {
193                                $bulkaction = sanitize_text_field( $_POST['bulkaction1'] );
194
195                        } elseif ( isset( $_POST['bulkaction2'] ) && $_POST['bulkaction2'] != '-1' ) {
196                                $bulkaction = sanitize_text_field( $_POST['bulkaction2'] );
197                        }
198                }
199
200                $ids = $arflitemainhelper->arflite_get_param( 'item-action', '' );
201
202                if ( empty( $ids ) ) {
203
204                        $arflite_errors[] = __( 'Please select one or more records.', 'arforms-form-builder' );
205                } else {
206
207                        if ( ! current_user_can( 'arfdeleteforms' ) ) {
208
209                                global $arformsmain;
210                                $admin_permission = $arformsmain->arforms_get_settings('admin_permission','general_settings');
211                                $arf_admin_permission = !empty($admin_permission) ? $admin_permission : esc_html__('You do not have permission to perform this action','arforms-form-builder');
212
213                                $arflite_errors[] = $arf_admin_permission;
214                        } else {
215
216                                if ( ! is_array( $ids ) ) {
217                                        $ids = explode( ',', $ids );
218                                }
219
220                                if ( is_array( $ids ) ) {
221
222                                        if ( $bulkaction == 'delete' ) {
223
224                                                foreach ( $ids as $form_id ) {
225                                                        $res_var = $arfliteform->arflitedestroy( $form_id );
226                                                }
227
228                                                if ( $res_var ) {
229                                                        $message = __( 'Record is deleted successfully.', 'arforms-form-builder' );
230                                                }
231                                        }
232                                }
233                        }
234                }
235
236                $return_array = array(
237                        'error'   => @$arflite_errors,
238                        'message' => @$message,
239                );
240
241                return $return_array;
242        }
243
244        function arflitemenu() {
245
246                add_submenu_page( 'ARForms-Lite', 'ARForms Lite | ' . __( 'Forms', 'arforms-form-builder' ), __( 'Manage Forms', 'arforms-form-builder' ), 'arfviewforms', 'ARForms-Lite', array( $this, 'arfliteroute' ) );
247                add_submenu_page( 'ARForms-Lite', 'ARForms Lite | ' . __( 'Add New Form', 'arforms-form-builder' ), '<span>' . __( 'Add New Form', 'arforms-form-builder' ) . '</span>', 'arfeditforms', 'ARForms-Lite&amp;arfaction=new&amp;isp=1', array( $this, 'arflite_new_form' ) );
248                add_action( 'admin_head-ARForms_page_ARForms-new', array( $this, 'arflitehead' ) );
249                add_action( 'admin_head-ARForms_page_ARForms-templates', array( $this, 'arflitehead' ) );
250        }
251
252        function arflitehead() {
253                global $arflitelitesettings, $arfliteversion;
254                require ARFLITE_VIEWS_PATH . '/arflite_head.php';
255        }
256
257        function arflite_list_form() {
258                $params          = $this->arflite_get_params();
259                $return_array    = apply_filters( 'arfliteadminactionformlist', array() );
260                $$arflite_errors = !empty( $return_array['error'] ) ? $return_array['error'] : '';
261                $message         = !empty( $return_array['message'] ) ? $return_array['message'] : '';
262                return $this->arflite_display_forms_list( $params, $message, false, false, $$arflite_errors );
263        }
264
265        function arflite_new_form( $newformid = 0 ) {
266                global $arfliteform, $arfliteajaxurl, $arflitemainhelper, $arflitefieldhelper, $arfliteformhelper, $arfliteversion;
267                do_action( 'before_arformslite_editor_init' );
268                $action         = isset( $_REQUEST['arfaction'] ) ? 'arfaction' : 'action';
269                $action         = $arflitemainhelper->arflite_get_param( $action );
270                $random_form_id = false;
271                if ( $action == 'new' || $action == 'duplicate' ) {
272                        global $wpdb, $ARFLiteMdlDb;
273                        $arffield_selection    = $arflitefieldhelper->arflite_field_selection();
274                        $form_name             = ( isset( $_REQUEST['form_name'] ) ) ? sanitize_text_field( $_REQUEST['form_name'] ) : '';
275                        $form_desc             = ( isset( $_REQUEST['form_desc'] ) ) ? sanitize_text_field( $_REQUEST['form_desc'] ) : '';
276                        $values['name']        = trim( $form_name );
277                        $values['description'] = trim( $form_desc );
278                        $random_form_id        = true;
279                        $values['id']          = 0;
280                        require ARFLITE_VIEWS_PATH . '/arflite_edit.php';
281                }
282        }
283
284        function arflitecustom_stylesheet( $previous_css, $location = 'header' ) {
285                global $arflite_style_settings, $arflitedatepickerloaded, $arflitecssloaded;
286                $uploads  = wp_upload_dir();
287                $css_file = array();
288                if ( ! $arflitecssloaded ) {
289                        if ( is_readable( ARFLITE_UPLOAD_DIR . '/css/arforms.css' ) ) {
290                                if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
291                                        $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
292                                }
293                        } else {
294                                $css_file[] = ARFLITESCRIPTURL . '&amp;controller=settings';
295                        }
296                }
297                return $css_file;
298        }
299
300        function ARFormslite_popup_shortcode_atts( $atts ) {
301                global $arfliteformcontroller;
302                $fid = $atts['id'];
303        }
304
305        function ARFormslite_shortcode_atts( $atts ) {
306                global $arflitereadonly, $arfliteformcontroller, $arfliteeditingentry, $arfliteshowfields, $ARFLiteMdlDb, $wpdb, $arflite_fid, $tbl_arf_entries;
307                $arflite_fid         = $atts['id'];
308                $arflitereadonly     = $atts['readonly'];
309                $arfliteeditingentry = false;
310                if ( ! is_array( $atts['fields'] ) ) {
311                        $arfliteshowfields = explode( ',', $atts['fields'] );
312                } else {
313                        $arfliteshowfields = array();
314                }
315
316                if ( $atts['entry_id'] == 'last' ) {
317                        global $user_ID, $arfliterecordmeta;
318                        if ( $user_ID ) {
319                                $where_meta          = array(
320                                        'form_id' => $atts['id'],
321                                        'user_id' => $user_ID,
322                                );
323                                $arfliteeditingentry = $ARFLiteMdlDb->arfliteget_var( $tbl_arf_entries, $where_meta, 'id', 'created_date DESC' );
324                        }
325                } elseif ( $atts['entry_id'] ) {
326                        $arfliteeditingentry = $atts['entry_id'];
327                }
328                $referer_info = ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) ? addslashes( sanitize_text_field( $_SERVER['HTTP_HOST'] ) . '/' . sanitize_text_field( $_SERVER['REQUEST_URI'] ) ) : '';
329                $formid       = ( isset( $_REQUEST['id'] ) ) ? intval( $_REQUEST['id'] ) : '';
330                $ipaddress    = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( $_SERVER['REMOTE_ADDR'] ) : '';
331                $useragent    = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ) : '';
332        }
333
334        function arflite_filter_content( $content, $form, $entry = false ) {
335                global $arflitemainhelper, $arflitefieldhelper;
336                if ( $entry && is_numeric( $entry ) ) {
337                        global $arflite_db_record;
338
339                        $entry_cache_obj = wp_cache_get( 'get_one_entry_record_' . $entry );
340
341                        if ( ! $entry_cache_obj ) {
342                                $entry = $arflite_db_record->arflitegetOne( $entry );
343
344                                wp_cache_set( 'get_one_entry_record_' . $entry->id, $entry );
345                        } else {
346                                $entry = $entry_cache_obj;
347                        }
348                } else {
349                        if ( !isset( $_POST['arflite_entry_nonce'] ) || ( isset( $_POST['arflite_entry_nonce'] ) && '' != $_POST['arflite_entry_nonce'] && ! wp_verify_nonce( sanitize_text_field( $_POST['arflite_entry_nonce'] ), 'arflite_entry_nonce' ) ) ) {
350                                return $content;
351                        }
352                        $entry_id = ( isset( $_POST ) && isset( $_POST['id'] ) ) ? intval( $_POST['id'] ) : false;
353                        if ( $entry_id ) {
354                                global $arflite_db_record;
355                                $entry_cache_obj = wp_cache_get( 'get_one_entry_record_' . $entry->id );
356
357                                if ( ! $entry_cache_obj ) {
358                                        $entry = $arflite_db_record->arflitegetOne( $entry_id );
359
360                                        wp_cache_set( 'get_one_entry_record_' . $entry->id, $entry );
361                                } else {
362                                        $entry = $entry_cache_obj;
363                                }
364                        }
365                }
366
367                if ( ! $entry ) {
368                        return $content;
369                }
370
371                if ( is_object( $form ) ) {
372                        $form = $form->id;
373                }
374
375                $shortcodes = $arflitemainhelper->arfliteget_shortcodes( $content, $form );
376
377                $content = $arflitefieldhelper->arflitereplaceshortcodes( $content, $entry, $shortcodes );
378
379                return $content;
380        }
381
382        function arflitepreview( $form_key = '' ) {
383                do_action( 'arflite_wp_process_entry' );
384
385                global $arfliteform, $arflitemainhelper, $arfliterecordcontroller, $arflitemaincontroller;
386
387                $arfliterecordcontroller->arflite_register_scripts();
388
389                //$arflitemaincontroller->arfliteafterinstall();
390
391                header( 'Content-Type: text/html; charset=utf-8' );
392
393                header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
394
395                $plugin = $arflitemainhelper->arflite_get_param( 'plugin' );
396
397                $controller = $arflitemainhelper->arflite_get_param( 'controller' );
398
399                $new = ( isset( $_REQUEST['ptype'] ) ) ? sanitize_text_field( $_REQUEST['ptype'] ) : '';
400
401                $key = ( isset( $_GET['form'] ) ? sanitize_text_field( $_GET['form'] ) : ( isset( $_POST['form'] ) ? sanitize_text_field( $_POST['form'] ) : '' ) ); //phpcs:ignore
402
403                if ( $key == '' && $form_key != '' ) {
404                        $key = $form_key;
405                }
406
407                $form = $arfliteform->arflitegetAll( array( 'form_key' => $key ), '', 1 );
408
409                $width  = ( isset( $_GET['width'] ) ) ? sanitize_text_field( $_GET['width'] ) : '';
410                $height = ( isset( $_GET['height'] ) ) ? sanitize_text_field( $_GET['height'] ) : '';
411
412                 $_SESSION['arfaction_ptype'] = ( isset( $_REQUEST['ptype'] ) ) ? sanitize_text_field( $_REQUEST['ptype'] ) : '';
413
414                require ARFLITE_VIEWS_PATH . '/arflite_preview.php';
415        }
416
417        function arflitedestroy() {
418
419                if ( ! current_user_can( 'arfdeleteforms' ) ) {
420
421                        global $arformsmain;
422                        $admin_permission = $arformsmain->arforms_get_settings('admin_permission', 'general_settings');
423                        $arf_admin_permission = !empty( $admin_permission ) ? $admin_permission : 'You do not have permission to perform this action';
424
425                        wp_die( esc_attr( $arf_admin_permission ) );
426                }
427
428                global $arfliteform;
429
430                $params = $this->arflite_get_params();
431
432                $message = __( 'Form is Successfully Deleted', 'arforms-form-builder' );
433
434                if ( $arfliteform->arflitedestroy( $params['id'] ) ) {
435                        $this->arflite_display_forms_list( $params, $message, '', 1 );
436                }
437        }
438
439        function arflite_insert_form_button( $content ) {
440
441                global $arformsmain;
442
443                if ( 'content' != $content  || $arformsmain->arforms_is_pro_active() ) {
444                        return;
445                }
446
447                if ( isset( $_SERVER['PHP_SELF'] ) && ! in_array( basename( sanitize_text_field( $_SERVER['PHP_SELF'] ) ), array( 'post.php', 'page.php', 'post-new.php', 'page-new.php' ) ) ) {
448                        return;
449                }
450
451                if ( ! current_user_can( 'administrator' ) ) {
452                        return;
453                }
454
455                echo '<a data-toggle="arfmodal" class="arfinsertformbuttoncls" onclick="arfliteopenarfinsertform();" href="#arfinsertform" title="' . esc_attr( __( 'Add ARForms Lite Form', 'arforms-form-builder' ) ) . '">
456                Shortcodes</a>';
457        }
458
459        function arflite_insert_form_popup() {
460                global $arformsmain;
461                if( $arformsmain->arforms_is_pro_active()  ){
462                        return;
463                }
464
465                $page = isset( $_SERVER['PHP_SELF'] ) ? basename( sanitize_text_field( $_SERVER['PHP_SELF'] ) ) : '';
466
467                if ( in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) || ( isset( $_GET ) && isset( $_GET['page'] ) && $_GET['page'] == 'ARForms-Lite-entry-templates' ) ) {
468
469                        require ARFLITE_VIEWS_PATH . '/arflite_insert_form_popup.php';
470                }
471        }
472
473        function arflite_display_forms_list( $params = false, $message = '', $page_params_ov = false, $current_page_ov = false, $arflite_errors = array() ) {
474
475                global $wpdb, $ARFLiteMdlDb, $arflitemainhelper, $arfliteform, $arflite_db_record, $arflitepagesize, $tbl_arf_forms;
476
477                if ( ! $params ) {
478                        $params = $this->arflite_get_params();
479                }
480
481                if ( $message == '' ) {
482                        $message = $arflitemainhelper->arflite_frm_get_main_message();
483                }
484
485                        $page_params = '&action=0&&arfaction=0&page=ARForms';
486
487                if ( $params['template'] ) {
488
489                        $default_templates = $arfliteform->arflitegetAll( array( 'is_template' => 1 ) );
490
491                        $all_templates = $arfliteform->arflitegetAll( array( 'is_template' => 1 ), 'name' );
492                }
493
494                $where_clause = " (status is NULL OR status = '' OR status = 'published') AND is_template = " . $params['template'];
495
496                $form_vars = $this->arflite_get_form_sort_vars( $params, $where_clause );
497
498                $current_page = ( $current_page_ov ) ? $current_page_ov : $params['paged'];
499
500                $page_params .= ( $page_params_ov ) ? $page_params_ov : $form_vars['page_params'];
501
502                $sort_str = $form_vars['sort_str'];
503
504                $sdir_str = $form_vars['sdir_str'];
505
506                $search_str = $form_vars['search_str'];
507
508                $record_count = $arflitemainhelper->arflitegetRecordCount( $form_vars['where_clause'], $tbl_arf_forms );
509
510                $page_count = $arflitemainhelper->arflitegetPageCount( $arflitepagesize, $record_count, $tbl_arf_forms );
511
512                $forms = $arflitemainhelper->arflitegetPage( $current_page, $arflitepagesize, $form_vars['where_clause'], $form_vars['order_by'], $tbl_arf_forms );
513
514                $page_last_record = $arflitemainhelper->arflitegetLastRecordNum( $record_count, $current_page, $arflitepagesize );
515
516                $page_first_record = $arflitemainhelper->arflitegetFirstRecordNum( $record_count, $current_page, $arflitepagesize );
517
518                require ARFLITE_VIEWS_PATH . '/arflite_list.php';
519        }
520
521        function arflite_get_version_val() {
522                return 1;
523        }
524
525        function arflite_get_form_sort_vars( $params, $where_clause = '' ) {
526
527                $order_by = '';
528
529                $page_params = '';
530
531                $sort_str = $params['sort'];
532
533                $sdir_str = $params['sdir'];
534
535                $search_str = $params['search'];
536
537                if ( ! empty( $search_str ) ) {
538
539                        $search_params = explode( ' ', $search_str );
540
541                        foreach ( $search_params as $search_param ) {
542
543                                if ( ! empty( $where_clause ) ) {
544                                        $where_clause .= ' AND';
545                                }
546
547                                $where_clause .= " (name like '%$search_param%' OR description like '%$search_param%' OR created_date like '%$search_param%')";
548                        }
549
550                        $page_params .= "&search=$search_str";
551                }
552
553                if ( ! empty( $sort_str ) ) {
554                        $page_params .= "&sort=$sort_str";
555                }
556
557                if ( ! empty( $sdir_str ) ) {
558                        $page_params .= "&sdir=$sdir_str";
559                }
560
561                switch ( $sort_str ) {
562
563                        case 'id':
564                        case 'name':
565                        case 'description':
566                        case 'form_key':
567                                $order_by .= " ORDER BY $sort_str";
568
569                                break;
570
571                        default:
572                                $order_by .= ' ORDER BY name';
573                }
574
575                if ( ( empty( $sort_str ) && empty( $sdir_str ) ) || $sdir_str == 'asc' ) {
576
577                        $order_by .= ' ASC';
578
579                        $sdir_str = 'asc';
580                } else {
581
582                        $order_by .= ' DESC';
583
584                        $sdir_str = 'desc';
585                }
586
587                return compact( 'order_by', 'sort_str', 'sdir_str', 'search_str', 'where_clause', 'page_params' );
588        }
589
590        function arflite_get_params() {
591
592                global $arflitemainhelper;
593
594                $values = array();
595
596                foreach ( array(
597                        'template' => 0,
598                        'id'       => '',
599                        'paged'    => 1,
600                        'form'     => '',
601                        'search'   => '',
602                        'sort'     => '',
603                        'sdir'     => '',
604                ) as $var => $default ) {
605                        $values[ $var ] = $arflitemainhelper->arflite_get_param( $var, $default );
606                }
607
608                return $values;
609        }
610
611        function arfliteroute() {
612
613                global $wpdb, $arflitemainhelper;
614
615                $action = isset( $_REQUEST['arfaction'] ) ? 'arfaction' : 'action';
616
617                $newformid = isset( $_REQUEST['newformid'] ) ? intval( $_REQUEST['newformid'] ) : 0;
618
619                $action = $arflitemainhelper->arflite_get_param( $action );             
620
621                if ( $action == 'new' || $action == 'duplicate' ) {
622                        return $this->arflite_new_form( $newformid );
623                } elseif ( $action == 'edit' ) {
624                        require ARFLITE_VIEWS_PATH . '/arflite_edit.php';
625                        return;
626                } elseif ( $action == 'destroy' ) {
627                        return $this->arflitedestroy();
628                } elseif ( $action == 'list-form' ) {
629                        return $this->arflite_list_form();
630                } elseif ( $action == 'preview' ) {
631                          return $this->arflitepreview();
632                } elseif ( $action == 'settings' ) {
633                          return $this->edit();
634                } else {
635                        $action = $arflitemainhelper->arflite_get_param( 'action' );
636                        if ( $action == -1 ) {
637                                $action = $arflitemainhelper->arflite_get_param( 'action2' );
638                        }
639                        if ( strpos( $action, 'bulk_' ) === 0 ) {
640                                if ( isset( $_GET ) && isset( $_GET['action'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
641                                        $_SERVER['REQUEST_URI'] = str_replace( '&action=' . sanitize_text_field( $_GET['action'] ), '', esc_url_raw( $_SERVER['REQUEST_URI'] ) );
642                                }
643                                if ( isset( $_GET ) && isset( $_GET['action2'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
644                                        $_SERVER['REQUEST_URI'] = str_replace( '&action=' . sanitize_text_field( $_GET['action2'] ), '', esc_url_raw( $_SERVER['REQUEST_URI'] ) );
645                                }
646                                return $this->arflite_list_form();
647                        } else {
648                                return $this->arflite_display_forms_list();
649                        }
650                }
651        }
652
653        function arflite_change_show_hide_column() {
654
655                if ( !isset( $_POST['arflite_wp_nonce'] ) || ( isset( $_POST['arflite_wp_nonce'] ) && '' != $_POST['arflite_wp_nonce'] && ! wp_verify_nonce( sanitize_text_field( $_POST['arflite_wp_nonce'] ), 'arflite_wp_nonce' ) ) ) {
656                        echo '';
657                        die;
658                }
659
660                $colsArray = isset( $_POST['colsArray'] ) ? sanitize_text_field( $_POST['colsArray'] ) : '';
661
662                $new_arr = explode( ',', $colsArray );
663
664                $array_hidden = array();
665
666                foreach ( $new_arr as $key => $val ) {
667                        if ( $key % 2 == 0 ) {
668                                if ( $new_arr[ $key + 1 ] == 'hidden' ) {
669                                        $array_hidden[] = $val;
670                                }
671                        }
672                }
673
674                $ser_arr = $array_hidden;
675
676                update_option( 'arfformcolumnlist', $ser_arr );
677
678                die();
679        }
680
681        function arfliteupdateformbulkoption() {
682               
683                if ( !isset( $_POST['_arforms_wpnonce'] ) || ( isset( $_POST['_arforms_wpnonce'] ) && '' != $_POST['_arforms_wpnonce'] && ! wp_verify_nonce( sanitize_text_field( $_POST['_arforms_wpnonce'] ), 'arflite_wp_nonce' ) ) ) {
684                        echo json_encode(
685                                array(
686                                        'error'       => true,
687                                        'message'     => __( 'Sorry, your request could not be processed due to security reason', 'arforms-form-builder' ),
688                                        'total_forms' => 0,
689                                )
690                        );
691                        die();
692                }
693
694                $return_array = apply_filters( 'arfliteadminactionformlist', array() );
695
696                $arflite_errors = !empty( $return_array['error'] ) ? $return_array['error'] : '';
697                $total_forms    = 0;
698                $message        = !empty( $return_array['message'] ) ? $return_array['message'] : '';
699                $action1        = ( isset( $_REQUEST['action1'] ) && $_REQUEST['action1'] != '' ) ? sanitize_text_field( $_REQUEST['action1'] ) : '';
700                $action2        = ( isset( $_REQUEST['action3'] ) && $_REQUEST['action3'] != '' ) ? sanitize_text_field( $_REQUEST['action3'] ) : '';
701
702                if ( $action1 == '-1' && $action2 == '-1' ) {
703                        echo json_encode(
704                                array(
705                                        'error'       => true,
706                                        'message'     => __( 'Please select valid action.', 'arforms-form-builder' ),
707                                        'total_forms' => $total_forms,
708                                )
709                        );
710                        die();
711                }
712                $items = isset( $_REQUEST['item-action'] ) ? array_map( 'intval', $_REQUEST['item-action'] ) : array();
713                if ( count( $items ) == 0 ) {
714                        echo json_encode(
715                                array(
716                                        'error'       => true,
717                                        'message'     => __( 'Please select one or more record to perform action.', 'arforms-form-builder' ),
718                                        'total_forms' => $total_forms,
719                                )
720                        );
721                        die();
722                }
723
724                $items = $this->arfliteObjtoArray( $items );
725                if ( $action1 == 'bulk_delete' || $action2 == 'bulk_delete' ) {
726
727                        if ( ! current_user_can( 'arfdeleteforms' ) ) {
728                                echo json_encode(
729                                        array(
730                                                'error'       => true,
731                                                'message'     => __( 'Sorry, you do not have enough permission to perform this action', 'arforms-form-builder' ),
732                                                'total_forms' => $total_forms,
733                                        )
734                                );
735                                die;
736                        }
737
738                        global $wpdb, $ARFLiteMdlDb, $tbl_arf_forms;
739                        $where  = ' WHERE 1=1 ';
740                        $where .= ' AND id IN(' . implode( ',', $items ) . ') ';
741                        $query  = 'DELETE FROM ' . $tbl_arf_forms . ' ' . $where;
742                        $wpdb->query( $query ); //phpcs:ignore
743                        if ( $wpdb->last_error != '' ) {
744                                echo json_encode(
745                                        array(
746                                                'error'       => true,
747                                                'message'     => $wpdb->last_error,
748                                                'total_forms' => $total_forms,
749                                        )
750                                );
751                                die();
752                        } else {
753                                $where       = "WHERE 1=1 AND is_template = %d AND (status is NULL OR status = '' OR status = 'published') ";
754                                $totalRecord = $wpdb->get_results( $wpdb->prepare( 'SELECT COUNT(*) as total_forms FROM ' . $tbl_arf_forms . ' ' . $where . ' ', 0 ) ); //phpcs:ignore
755                                $total_forms = $totalRecord[0]->total_forms;
756                                echo json_encode(
757                                        array(
758                                                'error'         => false,
759                                                'message'       => __( 'Record is deleted successfully.', 'arforms-form-builder' ),
760                                                'total_forms'   => $total_forms,
761                                                'deleted_forms' => $items,
762                                        )
763                                );
764                                die();
765                        }
766                }
767                die();
768        }
769
770        function arflite_load_form_grid_data() {
771                global $wpdb, $arflite_db_record, $ARFLiteMdlDb, $tbl_arf_forms;
772
773                $grid_columns = array(
774                        'input'        => '',
775                        'id'           => 'ID',
776                        'name'         => 'Name',
777                        'entries'      => 'Entries',
778                        'shortcode'    => 'Shortcodes',
779                        'created_date' => 'Create Date',
780                        'action'       => 'Action',
781                );
782
783                $query = $wpdb->prepare( 'SELECT * FROM ' . $tbl_arf_forms . " WHERE is_template = %d AND (status is NULL OR status = '' OR status = 'published') ORDER BY id DESC", 0 ); //phpcs:ignore
784
785                $form_results = $wpdb->get_results( $query ); //phpcs:ignore
786
787                $data = '';
788                $ai   = 0;
789                foreach ( $form_results as $frm_key => $form_data ) {
790                        $ni    = 0;
791                        $data .= "<tr data-form-id='" . $form_data->id . "'>";
792                        foreach ( $grid_columns as $key => $tmp_data ) {
793                                switch ( $key ) {
794                                        case 'input':
795                                                $data .= "<td class='box'><div class='arf_custom_checkbox_div arfmarginl20'><div class='arf_custom_checkbox_wrapper'><input id='cb-item-action-" . esc_attr( $form_data->id ) . "' class='chkstanard' type='checkbox' value='" . esc_attr( $form_data->id ) . "' name='item-action[]'>
796                                <svg width='18px' height='18px'>
797                                " . ARFLITE_CUSTOM_UNCHECKED_ICON . '
798                                ' . ARFLITE_CUSTOM_CHECKED_ICON . "
799                                </svg>
800                            </div>
801                        </div>
802                        <label for='cb-item-action-{$form_data->id}'><span></span></label></td>";
803                                                $ni++;
804                                                break;
805                                        case 'id':
806                                                $data .= "<td class='id_column'>" . $form_data->id . '</td>';
807                                                $ni++;
808                                                break;
809                                        case 'name':
810                                                $edit_link = "?page=ARForms&arfaction=edit&id={$form_data->id}";
811                                                if ( current_user_can( 'arfeditforms' ) ) {
812                                                        $data .= "<td class='form_title_column'><a class='row-title' href='{$edit_link}'>" . html_entity_decode( stripslashes( $form_data->name ) ) . '</a></td>';
813                                                } else {
814                                                        $data .= "<td class='form_title_column'>" . html_entity_decode( stripslashes_deep( $form_data->name ) ) . '</td>';
815                                                }
816
817                                                $ni++;
818                                                break;
819                                        case 'entries':
820                                                $entries = $arflite_db_record->arflitegetRecordCount( $form_data->id );
821                                                $data   .= "<td class='entry_column'>" . ( ( current_user_can( 'arfviewentries' ) ) ? "<a href='" . esc_url( admin_url( 'admin.php' ) . '?page=ARForms-entries&form=' . $form_data->id ) . "'>" . $entries . '</a>' : $entries ) . '</td>';
822                                                $ni++;
823                                                break;
824                                        case 'shortcode':
825                                                $data .= "<td class='arf_shortcode_width'>
826                        <div class='arf_shortcode_div'>
827                            <div class='arf_copied grid_copy_icon' data-attr='[ARForms id={$form_data->id}]'>" . __( 'Click to Copy', 'arforms-form-builder' ) . "</div>
828                            <input type='text' class='shortcode_textfield' readonly='readonly' onclick='this.select();' onfocus='this.select();' value='[ARForms id=" . esc_attr( $form_data->id ) . "]' />
829                        </div></td>";
830                                                $ni++;
831                                                break;
832                                        case 'created_date':
833                                                $wp_format_date = get_option( 'date_format' );
834                                                if ( $wp_format_date == 'F j, Y' || $wp_format_date == 'm/d/Y' ) {
835                                                        $date_format_new = 'M d, Y';
836                                                } elseif ( $wp_format_date == 'd/m/Y' ) {
837                                                        $date_format_new = 'd M, Y';
838                                                } elseif ( $wp_format_date == 'Y/m/d' ) {
839                                                        $date_format_new = 'Y, M d';
840                                                } else {
841                                                        $date_format_new = 'M d, Y';
842                                                }
843                                                $data .= "<td class='arf_created_date_col'>" . date( $date_format_new, strtotime( $form_data->created_date ) ) . '</td>';
844                                                $ni++;
845                                                break;
846                                        case 'action':
847                                                $div = "<div class='arf-row-actions'>";
848                                                if ( current_user_can( 'arfeditforms' ) ) {
849                                                        $edit_link = "?page=ARForms&arfaction=edit&id={$form_data->id}";
850                                                        $div      .= "<div class='arfformicondiv arfhelptip' title='" . __( 'Edit Form', 'arforms-form-builder' ) . "'><a href='" . wp_nonce_url( $edit_link ) . "'><svg width='30px' height='30px' viewBox='-5 -4 30 30' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill='#ffffff' d='M17.469,7.115v10.484c0,1.25-1.014,2.264-2.264,2.264H3.75c-1.25,0-2.262-1.014-2.262-2.264V5.082  c0-1.25,1.012-2.264,2.262-2.264h9.518l-2.264,2.001H3.489v13.042h11.979V9.379L17.469,7.115z M15.532,2.451l-0.801,0.8l2.4,2.401  l0.801-0.8L15.532,2.451z M17.131,0.85l-0.799,0.801l2.4,2.4l0.801-0.801L17.131,0.85z M6.731,11.254l2.4,2.4l7.201-7.202  l-2.4-2.401L6.731,11.254z M5.952,14.431h2.264l-2.264-2.264V14.431z' /></svg></a></div>";
851
852                                                        $duplicate_link = "?page=ARForms&arfaction=duplicate&id={$form_data->id}";
853
854                                                        if ( current_user_can( 'arfviewentries' ) ) {
855
856                                                                $div .= "<div class='arfformicondiv arfhelptip' title='" . __( 'Form Entry', 'arforms-form-builder' ) . "'><a href='" . wp_nonce_url( "?page=ARForms-entries&arfaction=list&form={$form_data->id}" ) . "' ><svg width='30px' height='30px' viewBox='-7 -4 30 30' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' fill='#ffffff' d='M1.489,19.829V0.85h14v18.979H1.489z M13.497,2.865H3.481v14.979  h10.016V2.865z M10.489,15.806H4.493v-2h5.996V15.806z M4.495,9.806h7.994v2H4.495V9.806z M4.495,5.806h7.994v2H4.495V5.806z' /></svg></a></div>";
857                                                        }
858
859                                                        $div .= "<div class='arfformicondiv arfhelptip' title='" . __( 'Duplicate Form', 'arforms-form-builder' ) . "'><a href='" . wp_nonce_url( $duplicate_link ) . "' ><svg width='30px' height='30px' viewBox='-5 -5 30 30' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' fill='#ffffff' d='M16.501,15.946V2.85H5.498v-2h11.991v0.025h1.012v15.07H16.501z   M15.489,19.81h-14V3.894h14V19.81z M13.497,5.909H3.481v11.979h10.016V5.909z'/></svg></a></div>";
860                                                        if ( current_user_can( 'arfviewentries' ) ) {
861                                                                $div .= "<div class='arfformicondiv arfhelptip' title='" . __( 'Export Entries', 'arforms-form-builder' ) . "'><a onclick='arfliteaction_func(\"export_csv\", \"{$form_data->id}\");'><svg width='30px' height='30px' viewBox='-3 -5 30 30' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill='#ffffff' d='M16.477,10.586V7.091c0-0.709-0.576-1.283-1.285-1.283H2.772c-0.709,0-1.283,0.574-1.283,1.283v3.495    c0,0.709,0.574,1.283,1.283,1.283h12.419C15.9,11.87,16.477,11.295,16.477,10.586z M5.131,9.887c0.277,0,0.492-0.047,0.67-0.116    l0.138,0.862c-0.208,0.092-0.6,0.17-1.047,0.17c-1.217,0-1.995-0.74-1.995-1.925c0-1.102,0.753-2.002,2.156-2.002    c0.308,0,0.646,0.054,0.893,0.146L5.762,7.892C5.623,7.83,5.415,7.776,5.107,7.776c-0.616,0-1.016,0.438-1.01,1.055    C4.098,9.524,4.561,9.887,5.131,9.887z M8.525,10.772c-0.492,0-1.369-0.107-1.654-0.262l0.646-0.839    C7.732,9.8,8.179,9.957,8.525,9.957c0.354,0,0.501-0.124,0.501-0.317c0-0.191-0.116-0.284-0.556-0.43    C7.695,8.948,7.395,8.524,7.402,8.077c0-0.701,0.6-1.231,1.531-1.231c0.44,0,0.832,0.101,1.063,0.216L9.789,7.87    c-0.17-0.094-0.494-0.216-0.816-0.216c-0.285,0-0.446,0.116-0.446,0.309c0,0.177,0.147,0.269,0.608,0.431    c0.717,0.246,1.016,0.608,1.023,1.162C10.158,10.255,9.604,10.772,8.525,10.772z M13.54,10.725h-1.171l-1.371-3.766h1.271    l0.509,1.748c0.092,0.315,0.162,0.617,0.216,0.916h0.023c0.062-0.308,0.124-0.593,0.208-0.916l0.486-1.748h1.23L13.54,10.725z     M19.961,0.85H6.02c-0.295,0-0.535,0.239-0.535,0.534v2.45h1.994V2.79h11.014v11.047l-2.447-0.002    c-0.158,0-0.309,0.064-0.421,0.177c-0.11,0.109-0.173,0.26-0.173,0.418l0.012,3.427H7.479V12.8H5.484v6.501    c0,0.294,0.239,0.533,0.535,0.533h10.389c0.153,0,0.297-0.065,0.398-0.179l3.553-4.048c0.088-0.098,0.135-0.224,0.135-0.355V1.384    C20.496,1.089,20.255,0.85,19.961,0.85z'/></svg></a></div>";
862                                                        }
863                                                }
864
865                                                global $arflite_style_settings, $arfliteformhelper;
866
867                                                $target_url = $arfliteformhelper->arflite_get_direct_link( $form_data->form_key );
868
869                                                $target_url = $target_url . '&ptype=list';
870
871                                                $div .= "<div class='arfformicondiv arfhelptip' title='" . __( 'Preview', 'arforms-form-builder' ) . "'><a class='openpreview' href='javascript:void(0)'  data-url='" . $target_url . $tb_width . $tb_height . "&whichframe=preview&TB_iframe=true'><svg width='30px' height='30px' viewBox='-3 -8 32 32' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' fill='#ffffff' d='M12.993,15.23c-7.191,0-11.504-7.234-11.504-7.234  S5.801,0.85,12.993,0.85c7.189,0,11.504,7.19,11.504,7.19S20.182,15.23,12.993,15.23z M12.993,2.827  c-5.703,0-8.799,5.214-8.799,5.214s3.096,5.213,8.799,5.213c5.701,0,8.797-5.213,8.797-5.213S18.694,2.827,12.993,2.827z   M12.993,11.572c-1.951,0-3.531-1.581-3.531-3.531s1.58-3.531,3.531-3.531c1.949,0,3.531,1.581,3.531,3.531  S14.942,11.572,12.993,11.572z'/></svg></a></div>";
872
873                                                if ( current_user_can( 'arfdeleteforms' ) ) {
874                                                        $delete_link = "?page=ARForms&arfaction=destroy&id={$form_data->id}";
875                                                        $id          = $form_data->id;
876                                                        $div        .= "<div class='arfformicondiv arfhelptip arfdeleteform_div_" . $id . "' title='" . __( 'Delete', 'arforms-form-builder' ) . "'><a class='arflite-cursor-pointer' id='delete_pop' data-toggle='arfmodal' data-id='" . $id . "'><svg width='30px' height='30px' viewBox='-5 -5 32 32' class='arfsvgposition'><path xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' fill='#ffffff' d='M18.435,4.857L18.413,19.87L3.398,19.88L3.394,4.857H1.489V2.929  h1.601h3.394V0.85h8.921v2.079h3.336h1.601l0,0v1.928H18.435z M15.231,4.857H6.597H5.425l0.012,13.018h10.945l0.005-13.018H15.231z   M11.4,6.845h2.029v9.065H11.4V6.845z M8.399,6.845h2.03v9.065h-2.03V6.845z' /></svg></a></div>";
877                                                }
878                                                $data .= "<td class='arf_action_cell'>" . $div . '</td>';
879                                                $ni++;
880                                                break;
881                                }
882                        }
883                        $data .= '</tr>';
884                        $ai++;
885                }
886
887                return $data;
888        }
889
890        function arflite_wp_kses_recursive( $arra_input ){
891                $check_allowed_html = arflite_retrieve_attrs_for_wp_kses(true);
892                if ( is_array( $arra_input ) ) {
893                        return array_map( array( $this, __FUNCTION__ ), $arra_input );
894                } else {
895                        return wp_kses( stripslashes_deep( $arra_input ), $check_allowed_html );
896                }
897        }
898        function arfliteformsavealloptions() {
899                global $arfliteform, $wpdb, $ARFLiteMdlDb, $arflitemainhelper, $arflitesettingcontroller, $arflitefield, $arfliteformhelper, $arflitefieldhelper, $arflitemaincontroller, $tbl_arf_forms, $tbl_arf_fields;
900
901                $arflite_validate_request = $arflitemaincontroller->arflite_check_user_cap( 'arfeditforms', true );
902
903                if ( 'success' != $arflite_validate_request ) {
904                        $arf_error_obj = arflite_json_decode( $arflite_validate_request, true );
905                        if ( ! empty( $arf_error_obj[1] ) && 'security_error' == $arf_error_obj[1] ) {
906                                echo 'reauth';
907                        } else {
908                                echo 'false^|^' . json_encode( $arf_error_obj );
909                        }
910                        die;
911                }
912                $is_preview = false;
913
914                $arf_preview_form_data = array();
915                $arflite_filterd_form = isset( $_REQUEST['filtered_form'] ) ?  $_REQUEST['filtered_form'] : array(); //phpcs:ignore
916                $str = json_decode( stripslashes_deep( $arflite_filterd_form ), true );;
917                $temp_form_id          = 0;
918
919                if ( sanitize_text_field( $str['arfaction'] ) == 'new' || sanitize_text_field( $str['arfaction'] ) == 'duplicate' ) {
920                        $temp_form_id = intval( $str['id'] );
921                        $form_id      = $id = $str['id'] = 0;
922                } else {
923                        $form_id = $id = intval( $str['id'] );
924                }
925
926                if ( ! empty( $_POST['arfaction'] ) && sanitize_text_field( $_POST['arfaction'] ) == 'preview' ) { //phpcs:ignore
927                        $is_preview                  = true;
928                        $form_id                     = $id = intval( $str['arfmf'] );
929                        $arf_preview_form_data['id'] = $form_id;
930                }
931
932                $arflite_errors = apply_filters( 'arflitevalidationofcurrentform', array(), $str );
933
934                if ( count( $arflite_errors ) > 0 ) {
935                        echo 'false^|^' . json_encode( $arflite_errors );
936                        die();
937                }
938
939                $_REQUEST = $values = $str;
940               
941                $values   = apply_filters( 'arflitechangevaluesbeforeupdateform', $values );
942
943                $ar_allowed_html_data = arflite_retrieve_attrs_for_wp_kses(true);
944               
945                /* form name */
946                $values['name'] = !empty( $values['name'] ) ? wp_kses( $values['name'], $ar_allowed_html_data ) : '';
947
948                /* form description */
949                $values['description'] = !empty( $values['description'] ) ? wp_kses( $values['description'], $ar_allowed_html_data ) : '';
950                /* useremail subject */
951                $values['options']['ar_email_subject'] = !empty( $values['options']['ar_email_subject'] ) ? wp_kses( $values['options']['ar_email_subject'] , $ar_allowed_html_data ) : '';
952               
953                $values['options']['ar_email_message'] = !empty( $values['options']['ar_email_message'] ) ? wp_kses(htmlspecialchars_decode($values['options']['ar_email_message']), $ar_allowed_html_data) : '';
954
955                /* uer from email */
956                $values['options']['ar_user_from_email'] = !empty( $values['options']['ar_user_from_email'] ) ? wp_kses( $values['options']['ar_user_from_email'], $ar_allowed_html_data ) : '';
957
958                /* user reply to email */
959                $values['options']['reply_to'] = !empty( $values['options']['reply_to'] ) ? wp_kses( $values['options']['reply_to'], $ar_allowed_html_data ) : '';
960
961                /* admin email subject */
962                $values['options']['admin_email_subject'] = !empty( $values['options']['admin_email_subject'] ) ? wp_kses( $values['options']['admin_email_subject'], $ar_allowed_html_data ) : '';
963
964                /* admin cc email */
965                $values['options']['admin_cc_email'] = !empty( $values['options']['admin_cc_email'] ) ? wp_kses( $values['options']['admin_cc_email'], $ar_allowed_html_data ) : '';
966
967                /* admin bcc email */
968                $values['options']['admin_bcc_email'] = !empty( $values['options']['admin_bcc_email'] ) ? wp_kses( $values['options']['admin_bcc_email'], $ar_allowed_html_data ) : '';
969
970                /* admin from name */
971                $values['options']['ar_admin_from_name'] = !empty( $values['options']['ar_admin_from_name'] ) ? wp_kses( $values['options']['ar_admin_from_name'], $ar_allowed_html_data ) : '';
972
973                /* admin from email */
974                $values['options']['ar_admin_from_email'] = !empty( $values['options']['ar_admin_from_email'] ) ? wp_kses( $values['options']['ar_admin_from_email'], $ar_allowed_html_data ) : '';
975               
976                /* admin reply to email */
977                $values['options']['ar_admin_reply_to_email'] = !empty( $values['options']['ar_admin_reply_to_email'] ) ? wp_kses( $values['options']['ar_admin_reply_to_email'], $ar_allowed_html_data ) : '';
978
979                /* admin email message */
980                $values['options']['ar_admin_email_message'] = !empty( $values['options']['ar_admin_email_message'] ) ? wp_kses(htmlspecialchars_decode($values['options']['ar_admin_email_message']), $ar_allowed_html_data) : '';
981
982                /* success message */
983                $values['options']['success_msg'] = !empty( $values['options']['success_msg'] ) ? wp_kses( $values['options']['success_msg'], $ar_allowed_html_data ) : '';
984
985                do_action( 'arflitebeforeupdateform', $id, $values, false );
986                do_action( 'arflitebeforeupdateform_' . $id, $id, $values, false );
987                $db_data = array();
988                if ( isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) {
989                        $values['status'] = 'published';
990                }
991
992                if ( isset( $values['form_key'] ) ) {
993                        $values['form_key'] = $arflitemainhelper->arflite_get_unique_key( $values['form_key'], $tbl_arf_forms, 'form_key', $id );
994                }
995
996                $form_fields  = array( 'form_key', 'name', 'description', 'status' );
997                $new_values   = array();
998                $double_optin = 0;
999
1000                $options = array();
1001                if ( isset( $values['options'] ) ) {
1002
1003                        $defaults = $arfliteformhelper->arflite_get_default_opts();
1004
1005                        foreach ( $defaults as $var => $default ) {
1006                                if ( $var == 'notification' ) {
1007                                        $options[ $var ] = isset( $values[ $var ] ) ? $values[ $var ] : $default;
1008                                } else {
1009                                        $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
1010                                }
1011                        }
1012                        $options['admin_cc_email'] = isset( $values['options']['admin_cc_email'] ) ? sanitize_text_field( $values['options']['admin_cc_email'] ) : '';
1013
1014                        $options['admin_bcc_email'] = isset( $values['options']['admin_bcc_email'] ) ? sanitize_text_field( $values['options']['admin_bcc_email'] ) : '';
1015
1016                        $options['arf_data_with_url'] = isset( $values['options']['arf_data_with_url'] ) ? sanitize_text_field( $values['options']['arf_data_with_url'] ) : 0;
1017
1018                        $options['arf_show_post_value'] = isset( $values['options']['arf_show_post_value'] ) ? sanitize_text_field( $values['options']['arf_show_post_value'] ) : 'no';
1019
1020                        $options['arf_post_value_url'] = isset( $values['options']['arf_post_value_url'] ) ? sanitize_text_field( $values['options']['arf_post_value_url'] ) : '';
1021
1022                        $options['arf_form_other_css'] = isset( $values['options']['arf_form_other_css'] ) ? sanitize_textarea_field( str_replace( "\n", '', str_replace( "\t", '', $values['options']['arf_form_other_css'] ) ) ) : '';
1023
1024                        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? sanitize_text_field( $values['options']['custom_style'] ) : 0;
1025
1026                        $allowed_html = arflite_retrieve_attrs_for_wp_kses();
1027
1028                        $options['before_html'] = isset( $values['options']['before_html'] ) ? wp_kses( $values['options']['before_html'], $allowed_html ) : '';
1029
1030                        $options['after_html'] = isset( $values['options']['after_html'] ) ? wp_kses( $values['options']['after_html'], $allowed_html ) : '';
1031
1032                        $options = apply_filters( 'arfliteformoptionsbeforeupdateform', $options, $values );
1033
1034                        $options['display_title_form'] = isset( $values['options']['display_title_form'] ) ? intval( $values['options']['display_title_form'] ) : 0;
1035
1036                        $double_optin = $options['arf_enable_double_optin'] = isset( $values['options']['arf_enable_double_optin'] ) ? $values['options']['arf_enable_double_optin'] : 0;
1037
1038                        $options['email_to'] = sanitize_text_field( $options['reply_to'] );
1039
1040                        $options['arf_sub_track_code'] = isset( $values['options']['arf_sub_track_code'] ) ? addslashes( rawurlencode( sanitize_textarea_field( $values['options']['arf_sub_track_code'] ) ) ) : '';
1041
1042                        $options['arf_field_order'] = isset( $values['arf_field_order'] ) ? sanitize_text_field( $values['arf_field_order'] ) : json_encode( array() );
1043
1044                        $options['arf_field_resize_width'] = isset( $values['arf_field_resize_width'] ) ? sanitize_text_field( $values['arf_field_resize_width'] ) : json_encode( array() );
1045                        $options['define_template']        = isset( $values['define_template'] ) ? intval( $values['define_template'] ) : 0;
1046
1047                        $options = apply_filters( 'arflite_save_form_options_outside', $options, $values, $form_id );
1048                }
1049
1050                foreach ( $values as $value_key => $value ) {
1051                        if ( in_array( $value_key, $form_fields ) ) {
1052                                $db_data[ $value_key ]               = $this->arfliteHtmlEntities( $value, true );
1053                                $arf_preview_form_data[ $value_key ] = $value;
1054                        }
1055                }
1056
1057                $sel_fields = $wpdb->prepare( 'SELECT id FROM ' . $tbl_arf_fields . ' where form_id = %d', $id ); //phpcs:ignore
1058
1059                $sel_fields_arr = $wpdb->get_results( $sel_fields, 'ARRAY_A' ); //phpcs:ignore
1060
1061                $old_field_array    = array();
1062                $change_field_value = array();
1063                if ( ! empty( $sel_fields_arr ) && count( $sel_fields_arr ) > 0 ) {
1064                        foreach ( $sel_fields_arr as $id_temp => $temp_value ) {
1065                                array_push( $old_field_array, $temp_value['id'] );
1066                        }
1067                }
1068
1069                $form_css = array();
1070
1071                $form_css['display_title_form'] = isset( $options['display_title_form'] ) ? sanitize_text_field( $options['display_title_form'] ) : '';
1072
1073                $form_css['arfmainformwidth'] = isset( $_REQUEST['arffw'] ) ? sanitize_text_field( $_REQUEST['arffw'] ) : '';
1074                $form_css['arfmainformwidth_tablet'] = isset($_REQUEST['arffw_tablet']) ? sanitize_text_field($_REQUEST['arffw_tablet']) : '';
1075        $form_css['arfmainformwidth_mobile'] = isset($_REQUEST['arffw_mobile']) ? sanitize_text_field($_REQUEST['arffw_mobile']) : '';
1076
1077                $form_css['form_width_unit'] = isset( $_REQUEST['arffu'] ) ? sanitize_text_field( $_REQUEST['arffu'] ) : '';
1078                $form_css['form_width_unit_tablet'] = isset($_REQUEST['arffu_tablet']) ? sanitize_text_field($_REQUEST['arffu_tablet']) : '';
1079        $form_css['arf_width_unit_mobile'] = isset($_REQUEST['arffu_mobile']) ? sanitize_text_field($_REQUEST['arffu_mobile']) : '';
1080
1081                $form_css['text_direction'] = isset( $_REQUEST['arftds'] ) ? sanitize_text_field( $_REQUEST['arftds'] ) : '';
1082
1083                $form_css['form_align'] = isset( $_REQUEST['arffa'] ) ? sanitize_text_field( $_REQUEST['arffa'] ) : '';
1084
1085                $form_css['arfmainfieldsetpadding'] = isset( $_REQUEST['arfmfsp'] ) ? sanitize_text_field( $_REQUEST['arfmfsp'] ) : '';
1086                $form_css['arfmainfieldsetpadding_tablet'] = isset( $_REQUEST['arfmfsp_tablet'] ) ? sanitize_text_field( $_REQUEST['arfmfsp_tablet'] ) : '';
1087                $form_css['arfmainfieldsetpadding_mobile'] = isset( $_REQUEST['arfmfsp_mobile'] ) ? sanitize_text_field( $_REQUEST['arfmfsp_mobile'] ) : '';
1088
1089                $form_css['form_border_shadow'] = isset( $_REQUEST['arffbs'] ) ? sanitize_text_field( $_REQUEST['arffbs'] ) : '';
1090
1091                $form_css['fieldset'] = isset( $_REQUEST['arfmfis'] ) ? sanitize_text_field( $_REQUEST['arfmfis'] ) : '';
1092
1093                $form_css['arfmainfieldsetradius'] = isset( $_REQUEST['arfmfsr'] ) ? sanitize_text_field( $_REQUEST['arfmfsr'] ) : '';
1094
1095                $form_css['arfmainfieldsetcolor'] = isset( $_REQUEST['arfmfsc'] ) ? sanitize_text_field( $_REQUEST['arfmfsc'] ) : '';
1096
1097                $form_css['arfmainformbordershadowcolorsetting'] = isset( $_REQUEST['arffboss'] ) ? sanitize_text_field( $_REQUEST['arffboss'] ) : '';
1098
1099                $form_css['arfmainformtitlecolorsetting'] = isset( $_REQUEST['arfftc'] ) ? sanitize_text_field( $_REQUEST['arfftc'] ) : '';
1100
1101                $form_css['check_weight_form_title'] = isset( $_REQUEST['arfftws'] ) ? sanitize_text_field( $_REQUEST['arfftws'] ) : '';
1102
1103                $form_css['form_title_font_size'] = isset( $_REQUEST['arfftfss'] ) ? sanitize_text_field( $_REQUEST['arfftfss'] ) : '';
1104
1105                $form_css['arfmainformtitlepaddingsetting'] = isset( $_REQUEST['arfftps'] ) ? sanitize_text_field( $_REQUEST['arfftps'] ) : '';
1106
1107                $form_css['arfmainformbgcolorsetting'] = isset( $_REQUEST['arffbcs'] ) ? sanitize_text_field( $_REQUEST['arffbcs'] ) : '';
1108
1109                $form_css['font'] = isset( $_REQUEST['arfmfs'] ) ? sanitize_text_field( $_REQUEST['arfmfs'] ) : '';
1110
1111                $form_css['label_color'] = isset( $_REQUEST['arflcs'] ) ? sanitize_text_field( $_REQUEST['arflcs'] ) : '';
1112
1113                $form_css['weight'] = isset( $_REQUEST['arfmfws'] ) ? sanitize_text_field( $_REQUEST['arfmfws'] ) : '';
1114
1115                $form_css['font_size'] = isset( $_REQUEST['arffss'] ) ? sanitize_text_field( $_REQUEST['arffss'] ) : '';
1116
1117                $form_css['align'] = isset( $_REQUEST['arffrma'] ) ? sanitize_text_field( $_REQUEST['arffrma'] ) : '';
1118
1119                $form_css['position'] = isset( $_REQUEST['arfmps'] ) ? sanitize_text_field( $_REQUEST['arfmps'] ) : '';
1120
1121                $form_css['width'] = isset( $_REQUEST['arfmws'] ) ? sanitize_text_field( $_REQUEST['arfmws'] ) : '';
1122
1123                $form_css['width_unit'] = isset( $_REQUEST['arfmwu'] ) ? sanitize_text_field( $_REQUEST['arfmwu'] ) : '';
1124
1125                $form_css['arfdescfontsizesetting'] = isset( $_REQUEST['arfdfss'] ) ? sanitize_text_field( $_REQUEST['arfdfss'] ) : '';
1126
1127                $form_css['arfdescalighsetting'] = isset( $_REQUEST['arfdas'] ) ? sanitize_text_field( $_REQUEST['arfdas'] ) : '';
1128
1129                $form_css['hide_labels'] = isset( $_REQUEST['arfhl'] ) ? sanitize_text_field( $_REQUEST['arfhl'] ) : '';
1130
1131                $form_css['check_font'] = isset( $_REQUEST['arfcbfs'] ) ? sanitize_text_field( $_REQUEST['arfcbfs'] ) : '';
1132
1133                $form_css['check_weight'] = isset( $_REQUEST['arfcbws'] ) ? sanitize_text_field( $_REQUEST['arfcbws'] ) : '';
1134
1135                $form_css['field_font_size'] = isset( $_REQUEST['arfffss'] ) ? sanitize_text_field( $_REQUEST['arfffss'] ) : '';
1136
1137                $form_css['text_color'] = isset( $_REQUEST['arftcs'] ) ? sanitize_text_field( $_REQUEST['arftcs'] ) : '';
1138
1139                $form_css['border_radius'] = isset( $_REQUEST['arfmbs'] ) ? sanitize_text_field( $_REQUEST['arfmbs'] ) : '';
1140                $form_css['border_radius_tablet'] = isset($_REQUEST['arfmbs_tablet']) ? sanitize_text_field($_REQUEST['arfmbs_tablet']) : '';
1141        $form_css['border_radius_mobile'] = isset($_REQUEST['arfmbs_mobile']) ? sanitize_text_field($_REQUEST['arfmbs_mobile']) : '';
1142
1143                $form_css['border_color'] = isset( $_REQUEST['arffmboc'] ) ? sanitize_text_field( $_REQUEST['arffmboc'] ) : '';
1144
1145                $form_css['arffieldborderwidthsetting'] = isset( $_REQUEST['arffbws'] ) ? sanitize_text_field( $_REQUEST['arffbws'] ) : '';
1146
1147                $form_css['arffieldborderstylesetting'] = isset( $_REQUEST['arffbss'] ) ? sanitize_text_field( $_REQUEST['arffbss'] ) : '';
1148
1149                $form_css['arfsubmitbuttonstyle'] = isset( $_REQUEST['arfsubmitbuttonstyle'] ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttonstyle'] ) : 'border';
1150
1151                if ( isset( $_REQUEST['arffiu'] ) && sanitize_text_field( $_REQUEST['arffiu'] ) == '%' && isset( $_REQUEST['arfmfiws'] ) && sanitize_text_field( $_REQUEST['arfmfiws'] ) > '100' ) {
1152                        $form_css['field_width'] = sanitize_text_field( '100' );
1153                } else {
1154                        $form_css['field_width'] = isset( $_REQUEST['arfmfiws'] ) ? sanitize_text_field( $_REQUEST['arfmfiws'] ) : '';
1155                }
1156                $form_css['field_width_unit'] = isset( $_REQUEST['arffiu'] ) ? sanitize_text_field( $_REQUEST['arffiu'] ) : '';
1157
1158                if ( isset( $_REQUEST['arffiu_tablet'] ) && sanitize_text_field( $_REQUEST['arffiu_tablet'] ) == '%' && isset( $_REQUEST['arfmfiws_tablet'] ) && sanitize_text_field( $_REQUEST['arfmfiws_tablet'] ) > '100' ) {
1159                        $form_css['field_width_tablet'] = sanitize_text_field( '100' );
1160                } else {
1161                        $form_css['field_width_tablet'] = isset( $_REQUEST['arfmfiws_tablet'] ) ? sanitize_text_field( $_REQUEST['arfmfiws_tablet'] ) : '';
1162                }
1163
1164                if ( isset( $_REQUEST['arffiu_mobile'] ) && sanitize_text_field( $_REQUEST['arffiu_mobile'] ) == '%' && isset( $_REQUEST['arfmfiws_mobile'] ) && sanitize_text_field( $_REQUEST['arfmfiws_mobile'] ) > '100' ) {
1165                        $form_css['field_width_mobile'] = sanitize_text_field( '100' );
1166                } else {
1167                        $form_css['field_width_mobile'] = isset( $_REQUEST['arfmfiws_mobile'] ) ? sanitize_text_field( $_REQUEST['arfmfiws_mobile'] ) : '';
1168                }
1169               
1170
1171                $form_css['field_width_unit_tablet'] = isset( $_REQUEST['arffiu_tablet'] ) ? sanitize_text_field( $_REQUEST['arffiu_tablet'] ) : '';
1172                $form_css['field_width_unit_mobile'] = isset( $_REQUEST['arffiu_mobile'] ) ? sanitize_text_field( $_REQUEST['arffiu_mobile'] ) : '';
1173
1174                $form_css['arffieldmarginssetting'] = isset( $_REQUEST['arffms'] ) ? sanitize_text_field( $_REQUEST['arffms'] ) : '';
1175
1176                $form_css['arffieldinnermarginssetting'] = isset( $_REQUEST['arffims'] ) ? sanitize_text_field( $_REQUEST['arffims'] ) : '';
1177
1178                $form_css['bg_color'] = isset( $_REQUEST['arffmbc'] ) ? sanitize_text_field( $_REQUEST['arffmbc'] ) : '';
1179
1180                $form_css['arfbgactivecolorsetting'] = isset( $_REQUEST['arfbcas'] ) ? sanitize_text_field( $_REQUEST['arfbcas'] ) : '';
1181
1182                $form_css['arfborderactivecolorsetting'] = isset( $_REQUEST['arfbacs'] ) ? sanitize_text_field( $_REQUEST['arfbacs'] ) : '';
1183
1184                $form_css['arferrorbgcolorsetting'] = isset( $_REQUEST['arfbecs'] ) ? sanitize_text_field( $_REQUEST['arfbecs'] ) : '';
1185
1186                $form_css['arferrorbordercolorsetting'] = isset( $_REQUEST['arfboecs'] ) ? sanitize_text_field( $_REQUEST['arfboecs'] ) : '';
1187
1188                $form_css['arfradioalignsetting'] = isset( $_REQUEST['arfras'] ) ? sanitize_text_field( $_REQUEST['arfras'] ) : '';
1189
1190                $form_css['arfcheckboxalignsetting'] = isset( $_REQUEST['arfcbas'] ) ? sanitize_text_field( $_REQUEST['arfcbas'] ) : '';
1191
1192                $form_css['auto_width'] = isset( $_REQUEST['arfautowidthsetting'] ) ? sanitize_text_field( $_REQUEST['arfautowidthsetting'] ) : '';
1193
1194                $form_css['arfcalthemename'] = isset( $_REQUEST['arffths'] ) ? sanitize_text_field( $_REQUEST['arffths'] ) : '';
1195
1196                $form_css['arfcalthemecss'] = isset( $_REQUEST['arffthc'] ) ? sanitize_text_field( $_REQUEST['arffthc'] ) : '';
1197
1198                $form_css['date_format'] = isset( $_REQUEST['arffdaf'] ) ? sanitize_text_field( $_REQUEST['arffdaf'] ) : '';
1199
1200                $form_css['arfsubmitbuttontext'] = isset( $_REQUEST['arfsubmitbuttontext'] ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttontext'] ) : '';
1201
1202                $form_css['arfsubmitweightsetting'] = isset( $_REQUEST['arfsbwes'] ) ? sanitize_text_field( $_REQUEST['arfsbwes'] ) : '';
1203
1204                $form_css['arfsubmitbuttonfontsizesetting'] = isset( $_REQUEST['arfsbfss'] ) ? sanitize_text_field( $_REQUEST['arfsbfss'] ) : '';
1205
1206                $form_css['arfsubmitbuttonwidthsetting'] = isset( $_REQUEST['arfsbws'] ) ? sanitize_text_field( $_REQUEST['arfsbws'] ) : '';
1207                $form_css['arfsubmitbuttonwidthsetting_tablet'] = isset( $_REQUEST['arfsbws_tablet'] ) ? sanitize_text_field( $_REQUEST['arfsbws_tablet'] ) : '';
1208                $form_css['arfsubmitbuttonwidthsetting_mobile'] = isset( $_REQUEST['arfsbws_mobile'] ) ? sanitize_text_field( $_REQUEST['arfsbws_mobile'] ) : '';
1209
1210                $form_css['arfsubmitbuttonheightsetting'] = isset( $_REQUEST['arfsbhs'] ) ? sanitize_text_field( $_REQUEST['arfsbhs'] ) : '';
1211                $form_css['submit_bg_color']              = isset( $_REQUEST['arfsbbcs'] ) ? sanitize_text_field( $_REQUEST['arfsbbcs'] ) : '';
1212
1213                $form_css['arfsubmitbuttonbgcolorhoversetting'] = isset( $_REQUEST['arfsbchs'] ) ? sanitize_text_field( $_REQUEST['arfsbchs'] ) : '';
1214
1215                $form_css['arfsubmitbgcolor2setting'] = isset( $_REQUEST['arfsbcs'] ) ? sanitize_text_field( $_REQUEST['arfsbcs'] ) : '';
1216
1217                $form_css['arfsubmittextcolorsetting'] = isset( $_REQUEST['arfsbtcs'] ) ? sanitize_text_field( $_REQUEST['arfsbtcs'] ) : '';
1218
1219                $form_css['arfsubmitbordercolorsetting'] = isset( $_REQUEST['arfsbobcs'] ) ? sanitize_text_field( $_REQUEST['arfsbobcs'] ) : '';
1220
1221                $form_css['arfsubmitborderwidthsetting'] = isset( $_REQUEST['arfsbbws'] ) ? sanitize_text_field( $_REQUEST['arfsbbws'] ) : '';
1222
1223                $form_css['arfsubmitboxxoffsetsetting'] = isset( $_REQUEST['arfsbxos'] ) ? sanitize_text_field( $_REQUEST['arfsbxos'] ) : '';
1224
1225                $form_css['arfsubmitboxyoffsetsetting'] = isset( $_REQUEST['arfsbyos'] ) ? sanitize_text_field( $_REQUEST['arfsbyos'] ) : '';
1226
1227                $form_css['arfsubmitboxblursetting'] = isset( $_REQUEST['arfsbbs'] ) ? sanitize_text_field( $_REQUEST['arfsbbs'] ) : '';
1228
1229                $form_css['arfsubmitboxshadowsetting'] = isset( $_REQUEST['arfsbsps'] ) ? sanitize_text_field( $_REQUEST['arfsbsps'] ) : '';
1230
1231                $form_css['arfsubmitborderradiussetting'] = isset( $_REQUEST['arfsbbrs'] ) ? sanitize_text_field( $_REQUEST['arfsbbrs'] ) : '';
1232
1233                $form_css['arfsubmitshadowcolorsetting'] = isset( $_REQUEST['arfsbscs'] ) ? sanitize_text_field( $_REQUEST['arfsbscs'] ) : '';
1234
1235                $form_css['arfsubmitbuttonmarginsetting'] = isset( $_REQUEST['arfsbms'] ) ? sanitize_text_field( $_REQUEST['arfsbms'] ) : '';
1236                $form_css['submit_bg_img']                = isset( $_REQUEST['arfsbis'] ) ? sanitize_text_field( $_REQUEST['arfsbis'] ) : '';
1237
1238                $form_css['submit_hover_bg_img'] = isset( $_REQUEST['arfsbhis'] ) ? sanitize_text_field( $_REQUEST['arfsbhis'] ) : '';
1239
1240                $form_css['error_font'] = isset( $_REQUEST['arfmefs'] ) ? sanitize_text_field( $_REQUEST['arfmefs'] ) : '';
1241
1242                $form_css['error_font_other'] = isset( $_REQUEST['arfmofs'] ) ? sanitize_text_field( $_REQUEST['arfmofs'] ) : '';
1243
1244                $form_css['arffontsizesetting'] = isset( $_REQUEST['arfmefss'] ) ? sanitize_text_field( $_REQUEST['arfmefss'] ) : '';
1245
1246                $form_css['arferrorbgsetting'] = isset( $_REQUEST['arfmebs'] ) ? sanitize_text_field( $_REQUEST['arfmebs'] ) : '';
1247
1248                $form_css['arferrortextsetting'] = isset( $_REQUEST['arfmets'] ) ? sanitize_text_field( $_REQUEST['arfmets'] ) : '';
1249
1250                $form_css['arferrorbordersetting'] = isset( $_REQUEST['arfmebos'] ) ? sanitize_text_field( $_REQUEST['arfmebos'] ) : '';
1251
1252                $form_css['arfsucessbgcolorsetting'] = isset( $_REQUEST['arfmsbcs'] ) ? sanitize_text_field( $_REQUEST['arfmsbcs'] ) : '';
1253
1254                $form_css['arfsucessbordercolorsetting'] = isset( $_REQUEST['arfmsbocs'] ) ? sanitize_text_field( $_REQUEST['arfmsbocs'] ) : '';
1255
1256                $form_css['arfsucesstextcolorsetting'] = isset( $_REQUEST['arfmstcs'] ) ? sanitize_text_field( $_REQUEST['arfmstcs'] ) : '';
1257
1258                $form_css['arfformerrorbgcolorsettings'] = isset( $_REQUEST['arffebgc'] ) ? sanitize_text_field( $_REQUEST['arffebgc'] ) : '';
1259
1260                $form_css['arfformerrorbordercolorsettings'] = isset( $_REQUEST['arffebrdc'] ) ? sanitize_text_field( $_REQUEST['arffebrdc'] ) : '';
1261
1262                $form_css['arfformerrortextcolorsettings'] = isset( $_REQUEST['arffetxtc'] ) ? sanitize_text_field( $_REQUEST['arffetxtc'] ) : '';
1263
1264                $form_css['arfsubmitalignsetting'] = isset( $_REQUEST['arfmsas'] ) ? sanitize_text_field( $_REQUEST['arfmsas'] ) : '';
1265
1266                $form_css['checkbox_radio_style'] = isset( $_REQUEST['arfcrs'] ) ? sanitize_text_field( $_REQUEST['arfcrs'] ) : '';
1267
1268                $form_css['arfmainform_bg_img'] = isset( $_REQUEST['arfmfbi'] ) ? sanitize_text_field( $_REQUEST['arfmfbi'] ) : '';
1269
1270                $form_css['arfmainform_color_skin'] = isset( $_REQUEST['arfmcs'] ) ? sanitize_text_field( $_REQUEST['arfmcs'] ) : '';
1271
1272                $form_css['arfinputstyle'] = isset( $_REQUEST['arfinpst'] ) ? sanitize_text_field( $_REQUEST['arfinpst'] ) : sanitize_text_field( 'standard' );
1273
1274                $form_css['arfsubmitfontfamily'] = isset( $_REQUEST['arfsff'] ) ? sanitize_text_field( $_REQUEST['arfsff'] ) : '';
1275
1276                $form_css['arfmainfieldcommonsize'] = isset( $_REQUEST['arfmainfieldcommonsize'] ) ? sanitize_text_field( $_REQUEST['arfmainfieldcommonsize'] ) : sanitize_text_field( '3' );
1277
1278                $form_css['arfdatepickerbgcolorsetting']   = isset( $_REQUEST['arfdbcs'] ) ? sanitize_text_field( $_REQUEST['arfdbcs'] ) : sanitize_text_field( '#23b7e5' );
1279                $form_css['arfdatepickertextcolorsetting'] = isset( $_REQUEST['arfdtcs'] ) ? sanitize_text_field( $_REQUEST['arfdtcs'] ) : sanitize_text_field( '#ffffff' );
1280
1281                $form_css['arfuploadbtntxtcolorsetting'] = isset( $_REQUEST['arfuptxt'] ) ? sanitize_text_field( $_REQUEST['arfuptxt'] ) : sanitize_text_field( '#ffffff' );
1282                $form_css['arfuploadbtnbgcolorsetting']  = isset( $_REQUEST['arfupbg'] ) ? sanitize_text_field( $_REQUEST['arfupbg'] ) : sanitize_text_field( '#077BDD' );
1283
1284                $form_css['arf_bg_position_x'] = ( isset( $_REQUEST['arf_bg_position_x'] ) && $_REQUEST['arf_bg_position_x'] != '' ) ? sanitize_text_field( $_REQUEST['arf_bg_position_x'] ) : sanitize_text_field( 'left' );
1285                $form_css['arf_bg_position_y'] = ( isset( $_REQUEST['arf_bg_position_y'] ) && $_REQUEST['arf_bg_position_y'] != '' ) ? sanitize_text_field( $_REQUEST['arf_bg_position_y'] ) : sanitize_text_field( 'top' );
1286
1287                $form_css['arf_bg_position_input_x'] = ( isset( $_REQUEST['arf_bg_position_input_x'] ) && $_REQUEST['arf_bg_position_input_x'] != '' ) ? sanitize_text_field( $_REQUEST['arf_bg_position_input_x'] ) : '';
1288                $form_css['arf_bg_position_input_y'] = ( isset( $_REQUEST['arf_bg_position_input_y'] ) && $_REQUEST['arf_bg_position_input_y'] != '' ) ? sanitize_text_field( $_REQUEST['arf_bg_position_input_y'] ) : '';
1289
1290                $form_css['arfmainfieldsetpadding_1']         = ( isset( $_REQUEST['arfmainfieldsetpadding_1'] ) && $_REQUEST['arfmainfieldsetpadding_1'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_1'] ) : 0;
1291                $form_css['arfmainfieldsetpadding_2']         = ( isset( $_REQUEST['arfmainfieldsetpadding_2'] ) && $_REQUEST['arfmainfieldsetpadding_2'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_2'] ) : 0;
1292                $form_css['arfmainfieldsetpadding_3']         = ( isset( $_REQUEST['arfmainfieldsetpadding_3'] ) && $_REQUEST['arfmainfieldsetpadding_3'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_3'] ) : 0;
1293                $form_css['arfmainfieldsetpadding_4']         = ( isset( $_REQUEST['arfmainfieldsetpadding_4'] ) && $_REQUEST['arfmainfieldsetpadding_4'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_4'] ) : 0;
1294
1295                $form_css['arfmainfieldsetpadding_1_tablet']         = ( isset( $_REQUEST['arfmainfieldsetpadding_1_tablet'] ) && $_REQUEST['arfmainfieldsetpadding_1'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_1_tablet'] ) : '';
1296                $form_css['arfmainfieldsetpadding_2_tablet']         = ( isset( $_REQUEST['arfmainfieldsetpadding_2_tablet'] ) && $_REQUEST['arfmainfieldsetpadding_2_tablet'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_2_tablet'] ) : '';
1297                $form_css['arfmainfieldsetpadding_3_tablet']         = ( isset( $_REQUEST['arfmainfieldsetpadding_3_tablet'] ) && $_REQUEST['arfmainfieldsetpadding_3_tablet'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_3_tablet'] ) : '';
1298                $form_css['arfmainfieldsetpadding_4_tablet']         = ( isset( $_REQUEST['arfmainfieldsetpadding_4_tablet'] ) && $_REQUEST['arfmainfieldsetpadding_4_tablet'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_4_tablet'] ) : '';
1299
1300                $form_css['arfmainfieldsetpadding_1_mobile']         = ( isset( $_REQUEST['arfmainfieldsetpadding_1_mobile'] ) && $_REQUEST['arfmainfieldsetpadding_1'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_1_mobile'] ) : '';
1301                $form_css['arfmainfieldsetpadding_2_mobile']         = ( isset( $_REQUEST['arfmainfieldsetpadding_2_mobile'] ) && $_REQUEST['arfmainfieldsetpadding_2_mobile'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_2_mobile'] ) : '';
1302                $form_css['arfmainfieldsetpadding_3_mobile']         = ( isset( $_REQUEST['arfmainfieldsetpadding_3_mobile'] ) && $_REQUEST['arfmainfieldsetpadding_3_mobile'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_3_mobile'] ) : '';
1303                $form_css['arfmainfieldsetpadding_4_mobile']         = ( isset( $_REQUEST['arfmainfieldsetpadding_4_mobile'] ) && $_REQUEST['arfmainfieldsetpadding_4_mobile'] != '' ) ? sanitize_text_field( $_REQUEST['arfmainfieldsetpadding_4_mobile'] ) : '';
1304
1305                $form_css['arfmainformtitlepaddingsetting_1'] = ( isset( $_REQUEST['arfformtitlepaddingsetting_1'] ) && $_REQUEST['arfformtitlepaddingsetting_1'] != '' ) ? sanitize_text_field( $_REQUEST['arfformtitlepaddingsetting_1'] ) : 0;
1306                $form_css['arfmainformtitlepaddingsetting_2'] = ( isset( $_REQUEST['arfformtitlepaddingsetting_2'] ) && $_REQUEST['arfformtitlepaddingsetting_2'] != '' ) ? sanitize_text_field( $_REQUEST['arfformtitlepaddingsetting_2'] ) : 0;
1307                $form_css['arfmainformtitlepaddingsetting_3'] = ( isset( $_REQUEST['arfformtitlepaddingsetting_3'] ) && $_REQUEST['arfformtitlepaddingsetting_3'] != '' ) ? sanitize_text_field( $_REQUEST['arfformtitlepaddingsetting_3'] ) : 0;
1308                $form_css['arfmainformtitlepaddingsetting_4'] = ( isset( $_REQUEST['arfformtitlepaddingsetting_4'] ) && $_REQUEST['arfformtitlepaddingsetting_4'] != '' ) ? sanitize_text_field( $_REQUEST['arfformtitlepaddingsetting_4'] ) : 0;
1309                $form_css['arffieldinnermarginssetting_1']    = ( isset( $_REQUEST['arffieldinnermarginsetting_1'] ) && $_REQUEST['arffieldinnermarginsetting_1'] != '' ) ? sanitize_text_field( $_REQUEST['arffieldinnermarginsetting_1'] ) : 0;
1310                $form_css['arffieldinnermarginssetting_2']    = ( isset( $_REQUEST['arffieldinnermarginsetting_2'] ) && $_REQUEST['arffieldinnermarginsetting_2'] != '' ) ? sanitize_text_field( $_REQUEST['arffieldinnermarginsetting_2'] ) : 0;
1311                $form_css['arffieldinnermarginssetting_3']    = ( isset( $_REQUEST['arffieldinnermarginsetting_3'] ) && $_REQUEST['arffieldinnermarginsetting_3'] != '' ) ? sanitize_text_field( $_REQUEST['arffieldinnermarginsetting_3'] ) : 0;
1312                $form_css['arffieldinnermarginssetting_4']    = ( isset( $_REQUEST['arffieldinnermarginsetting_4'] ) && $_REQUEST['arffieldinnermarginsetting_4'] != '' ) ? sanitize_text_field( $_REQUEST['arffieldinnermarginsetting_4'] ) : 0;
1313                $form_css['arfsubmitbuttonmarginsetting_1']   = ( isset( $_REQUEST['arfsubmitbuttonmarginsetting_1'] ) && $_REQUEST['arfsubmitbuttonmarginsetting_1'] != '' ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttonmarginsetting_1'] ) : 0;
1314                $form_css['arfsubmitbuttonmarginsetting_2']   = ( isset( $_REQUEST['arfsubmitbuttonmarginsetting_2'] ) && $_REQUEST['arfsubmitbuttonmarginsetting_2'] != '' ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttonmarginsetting_2'] ) : 0;
1315                $form_css['arfsubmitbuttonmarginsetting_3']   = ( isset( $_REQUEST['arfsubmitbuttonmarginsetting_3'] ) && $_REQUEST['arfsubmitbuttonmarginsetting_3'] != '' ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttonmarginsetting_3'] ) : 0;
1316                $form_css['arfsubmitbuttonmarginsetting_4']   = ( isset( $_REQUEST['arfsubmitbuttonmarginsetting_4'] ) && $_REQUEST['arfsubmitbuttonmarginsetting_4'] != '' ) ? sanitize_text_field( $_REQUEST['arfsubmitbuttonmarginsetting_4'] ) : 0;
1317
1318                $form_css['arfcheckradiostyle']          = isset( $_REQUEST['arfcksn'] ) ? sanitize_text_field( $_REQUEST['arfcksn'] ) : '';
1319                $form_css['arfcheckradiocolor']          = isset( $_REQUEST['arfcksc'] ) ? sanitize_text_field( $_REQUEST['arfcksc'] ) : '';
1320                $form_css['arf_checked_checkbox_icon']   = isset( $_REQUEST['arf_checkbox_icon'] ) ? sanitize_text_field( $_REQUEST['arf_checkbox_icon'] ) : '';
1321                $form_css['enable_arf_checkbox']         = isset( $_REQUEST['enable_arf_checkbox'] ) ? sanitize_text_field( $_REQUEST['enable_arf_checkbox'] ) : '';
1322                $form_css['arf_checked_radio_icon']      = isset( $_REQUEST['arf_radio_icon'] ) ? sanitize_text_field( $_REQUEST['arf_radio_icon'] ) : '';
1323                $form_css['enable_arf_radio']            = isset( $_REQUEST['enable_arf_radio'] ) ? sanitize_text_field( $_REQUEST['enable_arf_radio'] ) : '';
1324                $form_css['checked_checkbox_icon_color'] = isset( $_REQUEST['cbscol'] ) ? sanitize_text_field( $_REQUEST['cbscol'] ) : '';
1325                $form_css['checked_radio_icon_color']    = isset( $_REQUEST['rbscol'] ) ? sanitize_text_field( $_REQUEST['rbscol'] ) : '';
1326
1327                $form_css['arferrorstyle']         = isset( $_REQUEST['arfest'] ) ? sanitize_text_field( $_REQUEST['arfest'] ) : '';
1328                $form_css['arferrorstylecolor']    = isset( $_REQUEST['arfestc'] ) ? sanitize_text_field( $_REQUEST['arfestc'] ) : '';
1329                $form_css['arferrorstylecolor2']   = isset( $_REQUEST['arfestc2'] ) ? sanitize_text_field( $_REQUEST['arfestc2'] ) : '';
1330                $form_css['arferrorstyleposition'] = isset( $_REQUEST['arfestbc'] ) ? sanitize_text_field( $_REQUEST['arfestbc'] ) : '';
1331
1332                $form_css['arfsuccessmsgposition'] = isset( $_REQUEST['arfsuccessmsgposition'] ) ? sanitize_text_field( $_REQUEST['arfsuccessmsgposition'] ) : '';
1333
1334                $form_css['arfstandarderrposition'] = isset( $_REQUEST['arfstndrerr'] ) ? sanitize_text_field( $_REQUEST['arfstndrerr'] ) : 'relative';
1335
1336                $form_css['arfvalidationbgcolorsetting']   = isset( $_REQUEST['arfmvbcs'] ) ? sanitize_text_field( $_REQUEST['arfmvbcs'] ) : sanitize_text_field( '#ed4040' );
1337                $form_css['arfvalidationtextcolorsetting'] = isset( $_REQUEST['arfmvtcs'] ) ? sanitize_text_field( $_REQUEST['arfmvtcs'] ) : sanitize_text_field( '#ffffff' );
1338
1339                $form_css['arfformtitlealign']  = isset( $_REQUEST['arffta'] ) ? sanitize_text_field( $_REQUEST['arffta'] ) : '';
1340                $form_css['arfsubmitautowidth'] = isset( $_REQUEST['arfsbaw'] ) ? sanitize_text_field( $_REQUEST['arfsbaw'] ) : '';
1341
1342                $form_css['arftitlefontfamily'] = isset( $_REQUEST['arftff'] ) ? sanitize_text_field( $_REQUEST['arftff'] ) : '';
1343
1344                if ( isset( $_REQUEST['arfmainform_opacity'] ) and sanitize_text_field( $_REQUEST['arfmainform_opacity'] ) > 1 ) {
1345                        $form_css['arfmainform_opacity'] = sanitize_text_field( '1' );
1346                } else {
1347                        $form_css['arfmainform_opacity'] = isset( $_REQUEST['arfmainform_opacity'] ) ? sanitize_text_field( $_REQUEST['arfmainform_opacity'] ) : '';
1348                }
1349
1350                if ( isset( $_REQUEST['arfplaceholder_opacity'] ) and sanitize_text_field( $_REQUEST['arfplaceholder_opacity'] ) > 1 ) {
1351                        $form_css['arfplaceholder_opacity'] = sanitize_text_field( '1' );
1352                } else {
1353                        $form_css['arfplaceholder_opacity'] = isset( $_REQUEST['arfplaceholder_opacity'] ) ? sanitize_text_field( $_REQUEST['arfplaceholder_opacity'] ) : sanitize_text_field( '0.50' );
1354                }
1355
1356                $form_css['arfmainfield_opacity'] = isset( $_REQUEST['arfmfo'] ) ? sanitize_text_field( $_REQUEST['arfmfo'] ) : '';
1357                if ( sanitize_text_field( $_REQUEST['arfinpst'] ) == 'material' ) {
1358                        $form_css['arfmainfield_opacity'] = intval( 1 );
1359                }
1360                $form_css['arf_req_indicator'] = isset( $_REQUEST['arfrinc'] ) ? sanitize_text_field( $_REQUEST['arfrinc'] ) : sanitize_text_field( '0' );
1361
1362                $form_css['prefix_suffix_bg_color']   = isset( $_REQUEST['pfsfsbg'] ) ? sanitize_text_field( $_REQUEST['pfsfsbg'] ) : '';
1363                $form_css['prefix_suffix_icon_color'] = isset( $_REQUEST['pfsfscol'] ) ? sanitize_text_field( $_REQUEST['pfsfscol'] ) : '';
1364
1365                $form_css['arf_tooltip_bg_color']   = isset( $_REQUEST['arf_tooltip_bg_color'] ) ? sanitize_text_field( $_REQUEST['arf_tooltip_bg_color'] ) : '';
1366                $form_css['arf_tooltip_font_color'] = isset( $_REQUEST['arf_tooltip_font_color'] ) ? sanitize_text_field( $_REQUEST['arf_tooltip_font_color'] ) : '';
1367                $form_css['arf_tooltip_width']      = isset( $_REQUEST['arf_tooltip_width'] ) ? sanitize_text_field( $_REQUEST['arf_tooltip_width'] ) : '';
1368                $form_css['arftooltipposition']     = isset( $_REQUEST['arflitetippos'] ) ? sanitize_text_field( $_REQUEST['arflitetippos'] ) : '';
1369                $form_css['arfcommonfont']          = isset( $_REQUEST['arfcommonfont'] ) ? sanitize_text_field( $_REQUEST['arfcommonfont'] ) : sanitize_text_field( 'Helvetica' );
1370
1371                $form_css['arfmainbasecolor'] = isset( $_REQUEST['arfmbsc'] ) ? sanitize_text_field( $_REQUEST['arfmbsc'] ) : '';
1372
1373                $form_css['arfsliderselectioncolor'] = isset( $_REQUEST['asldrsl'] ) ? sanitize_text_field( $_REQUEST['asldrsl'] ) : '';
1374                $form_css['arfslidertrackcolor']     = isset( $_REQUEST['asltrcl'] ) ? sanitize_text_field( $_REQUEST['asltrcl'] ) : '';
1375
1376                if ( $form_css['arfcheckradiostyle'] == 'custom' ) {
1377                        $is_font_awesome                = true;
1378                        $options['font_awesome_loaded'] = $is_font_awesome;
1379                }
1380
1381                $options = apply_filters( 'arflite_trim_values', $options );
1382
1383                if ( ! $is_preview ) {
1384                        if ( ! empty( $form_css ) ) {
1385                                $db_data['options']              = maybe_serialize( $options );
1386                                $db_data['form_css']             = maybe_serialize( $form_css );
1387                                $db_data['status']               = 'published';
1388                                $db_data['arf_is_lite_form'] = 1;
1389                                if ( $str['arfaction'] == 'new' || $str['arfaction'] == 'duplicate' ) {
1390                                        $db_data['form_key']     = $arflitemainhelper->arflite_get_unique_key( '', $tbl_arf_forms, 'form_key' );
1391                                        $db_data['created_date'] = date( 'Y-m-d H:i:s' );
1392                                        $query_results           = $wpdb->insert( $tbl_arf_forms, $db_data );
1393                                        $form_id                 = $wpdb->insert_id;
1394                                        $str['id']               = $form_id;
1395                                        $values['id']            = $form_id;
1396                                        $id                      = $form_id;
1397                                        $query_results           = true;
1398                                } else {
1399                                        if ( ! empty( $db_data ) ) {
1400                                                $query_results = $wpdb->update( $tbl_arf_forms, $db_data, array( 'id' => $id ) );
1401                                                if ( $query_results ) {
1402                                                        wp_cache_delete( $id, 'arfform' );
1403                                                }
1404                                        } else {
1405                                                $query_results = true;
1406                                        }
1407                                }
1408                                $wpdb->update( $tbl_arf_forms, array('arf_lite_form_id' => $id), array( 'id' => $id ) );
1409                        } else {
1410                                $query_results = true;
1411                        }
1412                } else {
1413                        $options['arf_field_order']        = json_decode( $options['arf_field_order'] );
1414                        $options['arf_field_resize_width'] = json_decode( $options['arf_field_resize_width'] );
1415
1416                        $arf_preview_form_data['options']  = $options;
1417                        $arf_preview_form_data['form_css'] = $form_css;
1418                }
1419
1420                $selectbox_field_available      = '';
1421                $radio_field_available          = '';
1422                $checkbox_field_available       = '';
1423                $new_field_order                = array();
1424                $temp_order                     = json_decode( $values['arf_field_order'], true );
1425                $type_array                     = array();
1426                $content_array                  = array();
1427                $new_id_array                   = array();
1428                $is_font_awesome                = 0;
1429                $is_prefix_suffix_enable        = 0;
1430                $is_checkbox_img_enable         = 0;
1431                $is_radio_img_enable            = 0;
1432                $is_tooltip                     = 0;
1433                $is_input_mask                  = 0;
1434                $animate_number                 = 0;
1435                $round_total_number             = 0;
1436                $arf_hide_bar_belt              = 0;
1437                $html_running_total_field_array = array();
1438                $google_captcha_loaded          = 0;
1439                $loaded_field                   = array();
1440                $i                              = 0;
1441                $return_json_data               = array();
1442                $changed_field_value            = array();
1443                $arf_temp_fields                = array();
1444                $hidden_field_ids               = array();
1445                $default_value_field_array      = apply_filters( 'arflite_default_value_array_field_type', array( 'checkbox', 'radio' ) );
1446                $default_value_from_itemmeta    = apply_filters( 'arflite_default_value_array_field_type_from_itemmeta', array( 'select', 'hidden' ) );
1447
1448                foreach ( $values as $key => $value ) {
1449                        if ( preg_match( '/(arf_field_data_)/', $key ) ) {
1450
1451                                $name_array         = explode( 'arf_field_data_', $key );
1452                                $field_id_new       = $name_array[1];
1453                                $field_otions_new   = array();
1454                                $field_otions_new   = json_decode( $value, true );
1455                                $type_array[ $key ] = $field_otions_new['type'];
1456                                $default_value      = '';
1457                                $field_options      = '';
1458                                if ( in_array( $field_otions_new['type'], $default_value_field_array ) ) {
1459                                        $default_value = isset( $field_otions_new['default_value'] ) ? $field_otions_new['default_value'] : '';
1460                                } elseif ( in_array( $field_otions_new['type'], $default_value_from_itemmeta ) ) {
1461                                        $default_value = isset( $values['item_meta'][ $field_id_new ] ) ? $values['item_meta'][ $field_id_new ] : '';
1462                                } elseif ( $field_otions_new['default_value'] != '' ) {
1463                                        $default_value = $field_otions_new['default_value'];
1464                                }
1465
1466                                $clear_on_focus          = isset( $field_otions_new['frm_clear_field'] ) ? $field_otions_new['frm_clear_field'] : 0;
1467                                $default_blank           = isset( $field_otions_new['frm_default_blank'] ) ? $field_otions_new['frm_default_blank'] : 0;
1468                                $value                   = json_decode( $value, true );
1469                                $value['default_value']  = $default_value;
1470                                $value['clear_on_focus'] = $clear_on_focus;
1471                                $value['default_blank']  = $default_blank;
1472                                if ( $default_blank == 1 || $clear_on_focus == 1 ) {
1473                                        $value['value'] = ( $default_value == '' ) ? $value['placeholdertext'] : $default_value;
1474                                }
1475
1476                                $value = apply_filters( 'arflite_trim_values', $value );
1477
1478                                //if ( $is_preview ) {
1479                                        $new_temp_value = $value;
1480                                /* } else {
1481                                        $new_temp_value = json_encode( $value );
1482                                } */
1483
1484                                $check_allowed_html = arflite_retrieve_attrs_for_wp_kses(true);
1485
1486                                if( is_array( $new_temp_value ) ){
1487                                        $value = $this->arflite_wp_kses_recursive( $new_temp_value );
1488                                } else {
1489                                        $value = wp_kses( stripslashes_deep( $new_temp_value ), $check_allowed_html );
1490                                }
1491
1492                                if( is_array( $value ) && !$is_preview ){
1493                                        $value = json_encode( $value );
1494                                }
1495
1496                                if ( isset( $field_otions_new['options'] ) && ! empty( $field_otions_new['options'] ) ) {
1497                                        if ( is_array( $field_otions_new['options'] ) ) {
1498                                                if ( $is_preview ) {
1499                                                        $field_options = $field_otions_new['options'];
1500                                                } else {
1501                                                        $field_options = json_encode( $field_otions_new['options'] );
1502                                                }
1503                                        } elseif ( is_object( $field_otions_new['options'] ) ) {
1504                                                $field_otions_new['options'] = $this->arfliteObjtoArray( $field_otions_new['options'] );
1505                                                if ( $is_preview ) {
1506                                                        $field_options = $field_otions_new['options'];
1507                                                } else {
1508                                                        $field_options = json_encode( $field_otions_new['options'] );
1509                                                }
1510                                        }
1511                                }
1512                                if ( ! isset( $values['item_meta'] ) ) {
1513                                        $values['item_meta'] = array();
1514                                }
1515
1516                                $existing_keys = array_keys( $values['item_meta'] );
1517
1518                                if ( in_array( $field_id_new, $old_field_array ) ) {
1519
1520                                        $field_data_to_save = array(
1521                                                'name'          => isset( $field_otions_new['name'] ) ? sanitize_text_field( $field_otions_new['name'] ) : '',
1522                                                'type'          => sanitize_text_field( $field_otions_new['type'] ),
1523                                                'options'       => $field_options,
1524                                                'required'      => isset( $field_otions_new['required'] ) ? sanitize_text_field( $field_otions_new['required'] ) : sanitize_text_field( '0' ),
1525                                                'field_options' => $value,
1526                                                'form_id'       => intval( $id ),
1527                                                'option_order'  => isset( $field_otions_new['option_order'] ) ? $field_otions_new['option_order'] : '',
1528                                        );
1529
1530                                        if ( $field_otions_new['type'] == 'email' ) {
1531                                                if ( $field_otions_new['confirm_email'] == '1' ) {
1532                                                        $email_field_key = $arflitemainhelper->arflite_get_unique_key( '', $tbl_arf_fields, 'field_key' );
1533                                                        if ( is_array( $options['arf_field_order'] ) || is_object( $options['arf_field_order'] ) ) {
1534                                                                $confirm_field_order_arr = arflite_json_decode( json_encode( $options['arf_field_order'] ), true );
1535                                                        } else {
1536                                                                $confirm_field_order_arr = json_decode( $options['arf_field_order'], true );
1537                                                        }
1538                                                        $confirm_field_order = $confirm_field_order_arr[ $field_id_new . '_confirm' ];
1539
1540                                                        $arf_temp_fields[ 'confirm_email_' . $field_id_new ] = array(
1541                                                                'key'                 => $email_field_key,
1542                                                                'order'               => $confirm_field_order,
1543                                                                'parent_field_id'     => $field_id_new,
1544                                                                'confirm_inner_class' => $field_otions_new['confirm_email_inner_classes'],
1545                                                        );
1546                                                }
1547                                        }
1548                                        if ( ! $is_preview ) {
1549                                                $update = $wpdb->update( $tbl_arf_fields, $field_data_to_save, array( 'id' => $field_id_new ) );
1550                                        } else {
1551                                                if ( ! isset( $arf_preview_form_data['fields'] ) ) {
1552                                                        $arf_preview_form_data['fields'] = array();
1553                                                }
1554                                                $field_data_to_save['id']          = $field_id_new;
1555                                                $field_data_to_save['field_key']   = $arflitemainhelper->arflite_get_unique_key( '', $tbl_arf_fields, 'field_key' );
1556                                                $arf_preview_form_data['fields'][] = $field_data_to_save;
1557
1558                                        }
1559
1560                                        $new_id_array[ $i ]['old_id'] = $field_id_new;
1561                                        $new_id_array[ $i ]['new_id'] = $field_id_new;
1562                                        $new_id_array[ $i ]['name']   = isset( $field_otions_new['name'] ) ? $field_otions_new['name'] : '';
1563                                        $new_id_array[ $i ]['type']   = $field_otions_new['type'];
1564                                        $loaded_field[ $i ]           = $field_otions_new['type'];
1565
1566                                        if ( ( isset( $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] ) && $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] == 1 ) || ( isset( $field_otions_new[ 'enable_arf_suffix_' . $field_id_new ] ) && $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] == 1 ) || ( sanitize_text_field( $_REQUEST['arfcksn'] ) == 'custom' ) ) {
1567                                                $is_font_awesome = 1;
1568                                        }
1569
1570                                        if ( $field_otions_new['type'] == 'checkbox' && ( isset( $field_otions_new['use_image'] ) && $field_otions_new['use_image'] == 1 ) ) {
1571                                                $is_font_awesome        = 1;
1572                                                $is_checkbox_img_enable = true;
1573                                        }
1574
1575                                        if ( $field_otions_new['type'] == 'radio' && ( isset( $field_otions_new['use_image'] ) && $field_otions_new['use_image'] == 1 ) ) {
1576                                                $is_font_awesome     = 1;
1577                                                $is_radio_img_enable = true;
1578                                        }
1579
1580                                        if ( $field_otions_new['type'] == 'phone' && ( isset( $field_otions_new['phone_validation'] ) && $field_otions_new['phone_validation'] != 'international' ) ) {
1581                                                $is_input_mask = 1;
1582                                        }
1583
1584                                        if ( $field_otions_new['type'] == 'phone' && ( isset( $field_otions_new['phonetype'] ) && $field_otions_new['phonetype'] == 1 ) ) {
1585                                                $is_input_mask = 1;
1586                                        }
1587
1588                                        if ( $field_otions_new['type'] == 'captcha' && ( isset( $field_otions_new[ 'is_recaptcha_' . $field_id_new ] ) && $field_otions_new[ 'is_recaptcha_' . $field_id_new ] == 'recaptcha' ) ) {
1589                                                $google_captcha_loaded = 1;
1590                                        }
1591
1592                                        if ( ( isset( $field_otions_new['enable_arf_prefix'] ) && $field_otions_new['enable_arf_prefix'] == 1 ) || ( isset( $field_otions_new['enable_arf_suffix'] ) && $field_otions_new['enable_arf_suffix'] == 1 ) ) {
1593                                                $is_font_awesome         = 1;
1594                                                $is_prefix_suffix_enable = true;
1595                                        }
1596
1597                                        if ( isset( $field_otions_new['tooltip_text'] ) && $field_otions_new['tooltip_text'] != '' ) {
1598                                                $is_tooltip = 1;
1599                                        }
1600
1601                                        $field_id_all          = $field_id_new;
1602                                        $changed_field_value[] = $field_id_new;
1603                                        if ( $field_otions_new['type'] != 'hidden' ) {
1604                                                $new_field_order[ $field_id_new ] = isset( $temp_order[ $field_id_new ] ) ? $temp_order[ $field_id_new ] : '';
1605                                        }
1606
1607                                        if ( ( ( isset( $options['font_awesome_loaded'] ) && false == $options['font_awesome_loaded'] ) || ! isset( $options['font_awesome_loaded'] ) ) ) {
1608                                                $is_font_awesome                = true;
1609                                                $options['font_awesome_loaded'] = $is_font_awesome;
1610                                        }
1611                                } else {
1612                                        $field_otions_new['name'] = isset( $field_otions_new['name'] ) ? $field_otions_new['name'] : '';
1613
1614                                        $insert_default_value = is_array( $default_value ) ? json_encode( $default_value ) : $default_value;
1615
1616                                        $field_key      = $arflitemainhelper->arflite_get_unique_key( '', $tbl_arf_fields, 'field_key' );
1617                                        $new_val        = arflite_json_decode( $value, true );
1618                                        $new_val['key'] = $field_key;
1619                                        if ( $is_preview ) {
1620                                                $final_val = $new_val;
1621                                        } else {
1622                                                $final_val = json_encode( $new_val );
1623                                        }
1624                                        $field_otions_new_order = isset( $field_otions_new['option_order'] ) ? $field_otions_new['option_order'] : '';
1625                                        $args                   = array(
1626                                                'field_key'     => $field_key,
1627                                                'name'          => sanitize_text_field( $field_otions_new['name'] ),
1628                                                'type'          => sanitize_text_field( $field_otions_new['type'] ),
1629                                                'options'       => $field_options,
1630                                                'required'      => isset( $field_otions_new['required'] ) ? sanitize_text_field( $field_otions_new['required'] ) : sanitize_text_field( '0' ),
1631                                                'field_options' => $final_val,
1632                                                'form_id'       => intval( $id ),
1633                                                'created_date'  => current_time( 'mysql' ),
1634                                                'option_order'  => $field_otions_new_order,
1635                                        );
1636
1637                                         
1638                                        $format                 = array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%s', '%s' );
1639                                        if ( ! $is_preview ) {
1640                                                $wpdb->insert( $tbl_arf_fields, $args, $format );
1641                                        } else {
1642                                                if ( ! isset( $arf_preview_form_data['fields'] ) ) {
1643                                                        $arf_preview_form_data['fields'] = array();
1644                                                }
1645                                                $args['id']                        = $field_id_new;
1646                                                $args['field_key']                 = $field_key;
1647                                                $arf_preview_form_data['fields'][] = $args;
1648                                        }
1649
1650                                        $new_id_array[ $i ]['old_id'] = $field_id_new;
1651                                        $new_id_array[ $i ]['new_id'] = $wpdb->insert_id;
1652
1653                                        $new_id_array[ $i ]['name'] = $field_otions_new['name'];
1654                                        $new_id_array[ $i ]['type'] = $field_otions_new['type'];
1655                                        if ( $field_otions_new['type'] == 'hidden' ) {
1656                                                $hidden_field_ids[] = array(
1657                                                        'old_id' => $field_id_new,
1658                                                        'new_id' => $wpdb->insert_id,
1659                                                );
1660                                        }
1661                                        $field_opt = arflite_json_decode( $field_options, true );
1662
1663                                        if ( json_last_error() != JSON_ERROR_NONE ) {
1664                                                $field_opt = maybe_unserialize( $field_options );
1665                                        }
1666                                        if ( ! $is_preview ) {
1667                                                $changed_field_value[] = $new_field_id = $field_id_all = $wpdb->insert_id;
1668                                        } else {
1669                                                $changed_field_value[] = $new_field_id = $field_id_all = $args['id'];
1670                                        }
1671                                        if ( $field_otions_new['type'] != 'hidden' ) {
1672                                                $new_field_order[ $new_field_id ] = isset( $temp_order[ $field_id_new ] ) ? $temp_order[ $field_id_new ] : '';
1673                                        }
1674
1675                                        if ( $field_otions_new['type'] == 'email' ) {
1676                                                if ( $field_otions_new['confirm_email'] == '1' ) {
1677                                                        $email_field_key = $arflitemainhelper->arflite_get_unique_key( '', $tbl_arf_fields, 'field_key' );
1678                                                        if ( is_array( $options['arf_field_order'] ) || is_object( $options['arf_field_order'] ) ) {
1679                                                                $confirm_field_order_arr = arflite_json_decode( json_encode( $options['arf_field_order'] ), true );
1680                                                        } else {
1681                                                                $confirm_field_order_arr = json_decode( $options['arf_field_order'], true );
1682                                                        }
1683                                                        $confirm_field_order = $confirm_field_order_arr[ $field_id_new . '_confirm' ];
1684
1685                                                        $arf_temp_fields[ 'confirm_email_' . $new_field_id ] = array(
1686                                                                'key'                 => $email_field_key,
1687                                                                'order'               => $confirm_field_order,
1688                                                                'parent_field_id'     => $new_field_id,
1689                                                                'confirm_inner_class' => $field_otions_new['confirm_email_inner_classes'],
1690                                                        );
1691                                                }
1692                                        }
1693
1694                                        $loaded_field[ $i ] = $field_otions_new['type'];
1695
1696                                        if ( ( isset( $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] ) && $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] == 1 ) || ( isset( $field_otions_new[ 'enable_arf_suffix_' . $field_id_new ] ) && $field_otions_new[ 'enable_arf_prefix_' . $field_id_new ] == 1 ) || ( sanitize_text_field( $_REQUEST['arfcksn'] ) == 'custom' ) ) {
1697                                                $is_font_awesome = 1;
1698                                        }
1699
1700                                        if ( $field_otions_new['type'] == 'checkbox' && ( isset( $field_otions_new['use_image'] ) && $field_otions_new['use_image'] == 1 ) ) {
1701                                                $is_font_awesome        = 1;
1702                                                $is_checkbox_img_enable = true;
1703                                        }
1704
1705                                        if ( $field_otions_new['type'] == 'radio' && ( isset( $field_otions_new['use_image'] ) && $field_otions_new['use_image'] == 1 ) ) {
1706                                                $is_font_awesome     = 1;
1707                                                $is_radio_img_enable = true;
1708                                        }
1709
1710                                        if ( $field_otions_new['type'] == 'phone' && ( isset( $field_otions_new['phone_validation'] ) && $field_otions_new['phone_validation'] != 'international' ) ) {
1711                                                $is_input_mask = 1;
1712                                        }
1713
1714                                        if ( $field_otions_new['type'] == 'phone' && ( isset( $field_otions_new['phonetype'] ) && $field_otions_new['phonetype'] == 1 ) ) {
1715                                                $is_input_mask = 1;
1716                                        }
1717
1718                                        if ( $field_otions_new['type'] == 'captcha' && ( isset( $field_otions_new[ 'is_recaptcha_' . $field_id_new ] ) && $field_otions_new[ 'is_recaptcha_' . $field_id_new ] == 'recaptcha' ) ) {
1719                                                $google_captcha_loaded = 1;
1720                                        }
1721
1722                                        if ( ( isset( $field_otions_new['enable_arf_prefix'] ) && $field_otions_new['enable_arf_prefix'] == 1 ) || ( isset( $field_otions_new['enable_arf_suffix'] ) && $field_otions_new['enable_arf_suffix'] == 1 ) ) {
1723                                                $is_font_awesome         = 1;
1724                                                $is_prefix_suffix_enable = true;
1725                                        }
1726
1727                                        if ( isset( $field_otions_new['tooltip_text'] ) && $field_otions_new['tooltip_text'] != '' ) {
1728                                                $is_tooltip = 1;
1729                                        }
1730
1731                                        $ar_email_subject                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1732                                        $replace_with_ar_email_subject        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1733                                        $options['ar_email_subject']          = str_replace( $ar_email_subject, $replace_with_ar_email_subject, $options['ar_email_subject'] );
1734                                        $return_json_data['ar_email_subject'] = $options['ar_email_subject'];
1735
1736                                        $ar_user_from_email                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1737                                        $replace_with_ar_user_from_email        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1738                                        $options['ar_user_from_email']          = str_replace( $ar_user_from_email, $replace_with_ar_user_from_email, $options['ar_user_from_email'] );
1739                                        $return_json_data['ar_user_from_email'] = $options['ar_user_from_email'];
1740
1741                                        $ar_user_nreplyto_email                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1742                                        $replace_with_ar_user_nreplyto_email        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1743                                        $options['ar_user_nreplyto_email']          = str_replace( $ar_user_nreplyto_email, $replace_with_ar_user_nreplyto_email, $options['ar_user_nreplyto_email'] );
1744                                        $return_json_data['ar_user_nreplyto_email'] = $options['ar_user_nreplyto_email'];
1745
1746                                        $ar_email_message                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1747                                        $replace_with_ar_email_message        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1748                                        $options['ar_email_message']          = str_replace( $ar_email_message, $replace_with_ar_email_message, $options['ar_email_message'] );
1749                                        $return_json_data['ar_email_message'] = $options['ar_email_message'];
1750
1751                                        $reply_to              = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1752                                        $replace_with_reply_to = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1753                                        $options['reply_to']   = str_replace( $reply_to, $replace_with_reply_to, $options['reply_to'] );
1754                                        $return_json_data['options_admin_reply_to_notification'] = $options['reply_to'];
1755
1756                                        $admin_email_subject                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1757                                        $replace_with_admin_email_subject        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1758                                        $options['admin_email_subject']          = str_replace( $admin_email_subject, $replace_with_admin_email_subject, $options['admin_email_subject'] );
1759                                        $return_json_data['admin_email_subject'] = $options['admin_email_subject'];
1760
1761                                        $ar_admin_email_message                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1762                                        $replace_with_ar_admin_email_message        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1763                                        $options['ar_admin_email_message']          = str_replace( $ar_admin_email_message, $replace_with_ar_admin_email_message, $options['ar_admin_email_message'] );
1764                                        $return_json_data['ar_admin_email_message'] = $options['ar_admin_email_message'];
1765
1766                                        $ar_admin_from_name                             = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1767                                        $replace_with_ar_admin_from_name                = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1768                                        $options['ar_admin_from_name']                  = str_replace( $ar_admin_from_name, $replace_with_ar_admin_from_name, $options['ar_admin_from_name'] );
1769                                        $return_json_data['options_ar_admin_from_name'] = $options['ar_admin_from_name'];
1770
1771                                        $ar_admin_cc_email                                       = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1772                                        $replace_with_ar_admin_cc_email                          = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1773                                        $options['ar_admin_cc_email']                            = str_replace( $ar_admin_cc_email, $replace_with_ar_admin_cc_email, $options['admin_cc_email'] );
1774                                        $options['admin_cc_email']                               = $options['ar_admin_cc_email'];
1775                                        $return_json_data['options_admin_cc_email_notification'] = $options['admin_cc_email'];
1776
1777                                        $ar_admin_bcc_email                                       = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1778                                        $replace_with_ar_admin_bcc_email                          = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1779                                        $options['ar_admin_bcc_email']                            = str_replace( $ar_admin_bcc_email, $replace_with_ar_admin_bcc_email, $options['admin_bcc_email'] );
1780                                        $options['admin_bcc_email']                               = $options['ar_admin_bcc_email'];
1781                                        $return_json_data['options_admin_bcc_email_notification'] = $options['admin_bcc_email'];
1782
1783                                        $ar_admin_from_email                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1784                                        $replace_with_ar_admin_from_email        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1785                                        $options['ar_admin_from_email']          = str_replace( $ar_admin_from_email, $replace_with_ar_admin_from_email, $options['ar_admin_from_email'] );
1786                                        $return_json_data['ar_admin_from_email'] = $options['ar_admin_from_email'];
1787
1788                                        $ar_admin_reply_to_email                     = '[' . $field_otions_new['name'] . ':' . $field_id_new . ']';
1789                                        $replace_with_ar_admin_reply_to_email        = '[' . $field_otions_new['name'] . ':' . $new_field_id . ']';
1790                                        $options['ar_admin_reply_to_email']          = str_replace( $ar_admin_reply_to_email, $replace_with_ar_admin_reply_to_email, $options['ar_admin_reply_to_email'] );
1791                                        $return_json_data['ar_admin_reply_to_email'] = $options['ar_admin_reply_to_email'];
1792                                }
1793                                $i++;
1794                        }
1795                }
1796
1797                if ( $options['arf_form_other_css'] != '' && ( $str['arfaction'] == 'new' || $str['arfaction'] == 'duplicate' ) ) {
1798                        $options['arf_form_other_css'] = isset( $values['options']['arf_form_other_css'] ) ? addslashes( str_replace( "\n", '', str_replace( "\t", '', $values['options']['arf_form_other_css'] ) ) ) : '';
1799                        $temp_arf_form_other_css       = str_replace( $temp_form_id, $id, $options['arf_form_other_css'] );
1800                        $options['arf_form_other_css'] = $temp_arf_form_other_css;
1801                }
1802
1803                $options['arf_loaded_field']               = $loaded_field;
1804                $options['font_awesome_loaded']            = $is_font_awesome;
1805                $options['tooltip_loaded']                 = $is_tooltip;
1806                $options['arf_input_mask']                 = $is_input_mask;
1807                $options['arf_number_animation']           = $animate_number;
1808                $options['arf_number_round']               = $round_total_number;
1809                $options['arf_hide_bar_belt']              = $arf_hide_bar_belt;
1810                $options['html_running_total_field_array'] = $html_running_total_field_array;
1811                $options['google_captcha_loaded']          = $google_captcha_loaded;
1812                $options['calender_theme']                 = isset( $values['arffths'] ) ? $values['arffths'] : 'default_theme';
1813                $new_html_running_total                    = array();
1814
1815                foreach ( $new_id_array as $key_new => $value_new ) {
1816                        if ( $options['ar_email_to'] == $value_new['old_id'] ) {
1817                                $options['ar_email_to']                       = str_replace( $value_new['old_id'], $value_new['new_id'], $options['ar_email_to'] );
1818                                $return_json_data['options_ar_user_email_to'] = $options['ar_email_to'];
1819                        }
1820                        $options = apply_filters( 'arflite_update_form_option_outside', $options, $return_json_data, $value_new['old_id'], $value_new['new_id'] );
1821
1822                        $return_json_data = apply_filters( 'arflite_update_form_return_json_outside', $return_json_data, $options );
1823                }
1824
1825                if ( $options['arf_data_with_url'] != 0 ) {
1826                        $options['arf_data_with_url_type'] = isset( $values['options']['arf_data_with_url_type'] ) ? $values['options']['arf_data_with_url_type'] : 'post';
1827
1828                        $options['arf_data_key_with_url'] = isset( $values['options']['arf_data_key_with_url'] ) ? $values['options']['arf_data_key_with_url'] : 0;
1829                        if ( $options['arf_data_key_with_url'] != 0 ) {
1830
1831                                $k_field_id    = $new_id_array;
1832                                $key_name_list = array();
1833
1834                                foreach ( $k_field_id as $kfid => $val ) {
1835
1836                                        $key_name_list[ $val['new_id'] ] = isset( $_REQUEST['options']['arf_data_with_url_data'][ $val['old_id'] ] ) ? sanitize_text_field( $_REQUEST['options']['arf_data_with_url_data'][ $val['old_id'] ] ) : '';
1837                                }
1838                                $options['arf_field_key_name'] = json_encode( $key_name_list );
1839                        }
1840                }
1841
1842                $values_field_order = json_decode( $values['arf_field_order'], true );
1843                $final_field_order  = array();
1844                if( !empty( $values_field_order ) ){
1845                        foreach ( $values_field_order as $values_field_order_key => $values_field_order_value ) {
1846                                if ( ! array_key_exists( $values_field_order_key, $new_field_order ) && is_int( $values_field_order_key ) ) {
1847                                        $changed_new_field_key                       = array_search( $values_field_order_value, $new_field_order );
1848                                        $final_field_order[ $changed_new_field_key ] = $values_field_order_value;
1849
1850                                        if ( array_key_exists( $values_field_order_key . '_confirm', $values_field_order ) ) {
1851                                                unset( $final_field_order[ $values_field_order_key . '_confirm' ] );
1852
1853                                                $final_field_order[ $changed_new_field_key . '_confirm' ] = $values_field_order[ $values_field_order_key . '_confirm' ];
1854
1855                                                unset( $values_field_order[ $values_field_order_key . '_confirm' ] );
1856                                        }
1857                                } elseif ( array_key_exists( $values_field_order_key, $new_field_order ) && is_int( $values_field_order_key ) ) {
1858                                        $final_field_order[ $values_field_order_key ] = $values_field_order_value;
1859
1860                                        if ( array_key_exists( $values_field_order_key . '_confirm', $values_field_order ) ) {
1861                                                unset( $final_field_order[ $values_field_order_key . '_confirm' ] );
1862
1863                                                $final_field_order[ $values_field_order_key . '_confirm' ] = $values_field_order[ $values_field_order_key . '_confirm' ];
1864
1865                                                unset( $values_field_order[ $values_field_order_key . '_confirm' ] );
1866                                        }
1867                                } else {
1868                                        if ( strpos( $values_field_order_key, '_confirm' ) === false ) {
1869                                                $final_field_order[ $values_field_order_key ] = $values_field_order_value;
1870                                        }
1871                                }
1872                        }
1873                }
1874                if ( ! $is_preview ) {
1875                        $options['arf_field_order'] = isset( $final_field_order ) ? json_encode( $final_field_order ) : array();
1876                } else {
1877                        $options['arf_field_order'] = isset( $final_field_order ) ? $final_field_order : array();
1878                }
1879
1880                $selectDeletedFields = array();
1881
1882               
1883                if ( ! $is_preview ) {
1884                        if ( isset( $changed_field_value ) && ! empty( $changed_field_value ) ) {
1885                                $selectDeletedFields = $wpdb->get_results( $wpdb->prepare( 'SELECT id FROM `' . $tbl_arf_fields . "` WHERE id NOT IN( '" . implode( '\',\'', $changed_field_value ) . "') AND form_id = %d", $id ) ); //phpcs:ignore
1886       
1887                                $del_fields = $wpdb->query( $wpdb->prepare( 'delete from ' . $tbl_arf_fields . ' where form_id = %d and id NOT IN (' . rtrim(implode( ',', $changed_field_value ),',') . ')', $id ) ); //phpcs:ignore
1888       
1889                        } elseif ( empty( $changed_field_value ) ) {
1890                                $del_fields = $wpdb->query( $wpdb->prepare( 'delete from ' . $tbl_arf_fields . ' where form_id = %d', $id ) ); //phpcs:ignore
1891                        }
1892                       
1893
1894                        $query_results = $wpdb->query( 'update ' . $tbl_arf_forms . " set options = '" . addslashes( maybe_serialize( $options ) ) . "', temp_fields='" . maybe_serialize( $arf_temp_fields ) . "' where id = '" . $id . "'" ); //phpcs:ignore
1895                } else {
1896                        $arf_preview_form_data['options']     = $options;
1897                        $arf_preview_form_data['temp_fields'] = $arf_temp_fields;
1898                }
1899
1900                if ( $is_preview ) {
1901                        $random = rand( 11, 9999 );
1902                        if ( get_option( 'arflite_previewtabledata_' . $random ) != '' ) {
1903                                $random = rand( 11, 9999 );
1904                        }
1905                        $option_name = 'arflite_previewtabledata_' . $random;
1906
1907                        update_option( $option_name, addslashes( json_encode( $arf_preview_form_data ) ) );
1908                        echo esc_html( $option_name );
1909                        die;
1910                }
1911
1912                do_action( 'arfliteafterupdateform', $id, $values, false, 0 );
1913                do_action( 'arfliteafterupdateform_' . $id, $id, $values, false, 0 );
1914
1915                do_action( 'arfliteupdateform_' . $id, $values );
1916
1917                $query_results = apply_filters( 'arflitechangevaluesafterupdateform', $query_results );
1918
1919                $sel_fields = $wpdb->prepare( 'select * from ' . $tbl_arf_fields . ' where form_id = %d', $str['id'] ); //phpcs:ignore
1920
1921                $res_fields_arr = $wpdb->get_results( $sel_fields, 'ARRAY_A' ); //phpcs:ignore
1922
1923                $selectbox_field_available = '';
1924                $radio_field_available     = '';
1925                $checkbox_field_available  = '';
1926
1927                foreach ( $res_fields_arr as $res_fields ) {
1928
1929                        if ( ( $res_fields['type'] == 'select' || $res_fields['type'] == 'time' ) && $selectbox_field_available == '' ) {
1930                                $selectbox_field_available = true;
1931                        }
1932
1933                        if ( $res_fields['type'] == 'checkbox' && $checkbox_field_available == '' ) {
1934                                $checkbox_field_available = true;
1935                        }
1936
1937                        if ( $res_fields['type'] == 'radio' && $radio_field_available == '' ) {
1938                                $radio_field_available = true;
1939                        }
1940                }
1941
1942                $upload_dir   = ARFLITE_UPLOAD_DIR . '/css/';
1943                $dest_dir     = ARFLITE_UPLOAD_DIR . '/maincss/';
1944                $dest_css_url = ARFLITE_UPLOAD_URL . '/maincss/';
1945
1946                $form_id = $id;
1947
1948                $cssoptions = $form_css;
1949
1950                $target_path = ARFLITE_UPLOAD_DIR . '/maincss';
1951
1952                $arflite_preview = 'none';
1953                if ( count( $cssoptions ) > 0 ) {
1954                        $new_values      = array();
1955                        $temp_new_values = array();
1956
1957                        foreach ( $cssoptions as $k => $v ) {
1958                                $new_values[ $k ] = $temp_new_values[ $k ] = str_replace( '##', '#', $v );
1959                        }
1960
1961                        $saving       = true;
1962                        $use_saved    = true;
1963                        $is_form_save = false;
1964
1965                        $arfssl = ( is_ssl() ) ? 1 : 0;
1966
1967                        $arflite_preview = false;
1968
1969                        $form = $arfliteform->arflitegetOne( $form_id );
1970
1971                        $form->form_css = maybe_unserialize( $form->form_css );
1972
1973                        $css_common_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_common.php';
1974
1975                        $css_rtl_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_rtl.php';
1976
1977                        if ( 'standard' == $form_css['arfinputstyle'] || 'rounded' == $form_css['arfinputstyle'] ) {
1978                                $filename = ARFLITE_FORMPATH . '/core/arflite_css_create_main.php';
1979
1980                                $wp_upload_dir = wp_upload_dir();
1981
1982                                $target_path = ARFLITE_UPLOAD_DIR . '/maincss';
1983
1984                                $temp_css_file = '';// $warn = "/* WARNING: Any changes made to this file will be lost when your ARForms settings are updated */";
1985
1986                                ob_start();
1987
1988                                include $filename;
1989                                include $css_common_filename;
1990                                if ( is_rtl() ) {
1991                                        include $css_rtl_filename;
1992                                }
1993
1994                                $temp_css_file .= str_replace( '##', '#', ob_get_contents() );
1995
1996                                ob_end_clean();
1997
1998                        }
1999
2000                        if ( 'material' == $form_css['arfinputstyle'] ) {
2001
2002                                $file_name_materialize = ARFLITE_FORMPATH . '/core/arflite_css_create_materialize.php';
2003
2004                                $wp_upload_dir = wp_upload_dir();
2005
2006                                $target_path = ARFLITE_UPLOAD_DIR . '/maincss';
2007
2008                                $temp_materialize_file = $materialize_warn = '/* WARNING: Any changes made to this file will be lost when your ARForms settings are updated */';
2009
2010                                $temp_materialize_file .= "\n";
2011
2012                                ob_start();
2013
2014                                include $file_name_materialize;
2015                                include $css_common_filename;
2016                                if ( is_rtl() ) {
2017                                        include $css_rtl_filename;
2018                                }
2019
2020                                $temp_materialize_file .= str_replace( '##', '#', ob_get_contents() );
2021
2022                                ob_end_clean();
2023
2024                                $temp_materialize_file .= "\n " . $materialize_warn;
2025
2026                        }
2027                } else {
2028
2029                        $temp_css_file = file_get_contents( $upload_dir . 'arforms.css' );
2030                        $temp_css_file = str_replace( '.arflite_main_div_', '.arflite_main_div_' . $id, $temp_css_file );
2031                        $temp_css_file = str_replace( '#popup-form-', '#popup-form-' . $id, $temp_css_file );
2032                        $temp_css_file = str_replace( 'cycle_', 'cycle_' . $id, $temp_css_file );
2033                        $temp_css_file = str_replace( '##', '#', $temp_css_file );
2034                }
2035
2036                /*INCLUDE ACTUAL DYNAMIC FILE IN AJAX RESPONSE START*/
2037                if ( count( $cssoptions ) > 0 ) {
2038                        $new_values      = array();
2039                        $temp_new_values = array();
2040
2041                        foreach ( $cssoptions as $k => $v ) {
2042                                $new_values[ $k ] = $temp_new_values[ $k ] = str_replace( '##', '#', $v );
2043                        }
2044
2045                        $saving       = true;
2046                        $use_saved    = true;
2047                        $is_form_save = true;
2048
2049                        $arfssl = ( is_ssl() ) ? 1 : 0;
2050
2051                        $arflite_preview = false;
2052
2053                        $filename = ARFLITE_FORMPATH . '/core/arflite_css_create_main.php';
2054
2055                        $standard_css_file = $warn = '/* WARNING: Any changes made to this file will be lost when your ARForms lite settings are updated */';
2056
2057                        $standard_css_file .= "\n";
2058
2059                        ob_start();
2060
2061                        include $filename;
2062                        include $css_common_filename;
2063                        if ( is_rtl() ) {
2064                                include $css_rtl_filename;
2065                        }
2066                        $standard_css_file .= str_replace( '##', '#', ob_get_contents() );
2067
2068                        ob_end_clean();
2069
2070                        $standard_css_file .= "\n " . $warn;
2071
2072                        $file_name_materialize = ARFLITE_FORMPATH . '/core/arflite_css_create_materialize.php';
2073
2074                        $materialize_css_file = $materialize_warn = '/* WARNING: Any changes made to this file will be lost when your ARForms lite settings are updated */';
2075
2076                        $materialize_css_file .= "\n";
2077
2078                        ob_start();
2079
2080                        include $file_name_materialize;
2081                        include $css_common_filename;
2082                        if ( is_rtl() ) {
2083                                include $css_rtl_filename;
2084                        }
2085
2086                        $materialize_css_file .= str_replace( '##', '#', ob_get_contents() );
2087
2088                        ob_end_clean();
2089
2090                        $materialize_css_file .= "\n " . $materialize_warn;
2091                }
2092                /*INCLUDE ACTUAL DYNAMIC FILE IN AJAX RESPONSE END*/
2093
2094                $css_file_new = $dest_dir . 'maincss_' . $id . '.css';
2095
2096                $material_css_file_new = $dest_dir . 'maincss_materialize_' . $id . '.css';
2097
2098                WP_Filesystem();
2099                global $wp_filesystem;
2100                if ( 'standard' == $form_css['arfinputstyle'] || 'rounded' == $form_css['arfinputstyle'] ) {
2101                        if ( $selectbox_field_available == '' ) {
2102                                $start_get_css_selbox_position = strpos( $temp_css_file, '/*arf selectbox css start*/' );
2103                                $end_get_css_selbox_position   = strpos( $temp_css_file, '/*arf selectbox css end*/' );
2104
2105                                $end_get_css_selbox_lenght = strlen( '/*arf selectbox css end*/' );
2106
2107                                if ( $start_get_css_selbox_position && $end_get_css_selbox_position ) {
2108
2109                                        $temp_css_file_star_selectbox = substr( $temp_css_file, $start_get_css_selbox_position, ( $end_get_css_selbox_position + $end_get_css_selbox_lenght ) - $start_get_css_selbox_position );
2110                                        $temp_css_file                = str_replace( $temp_css_file_star_selectbox, '', $temp_css_file );
2111                                }
2112                        }
2113
2114                        if ( $radio_field_available == '' && $checkbox_field_available == '' ) {
2115                                $start_get_css_radiocheck_position = strpos( $temp_css_file, '/*arf checkbox radio css start*/' );
2116                                $end_get_css_radiocheck_position   = strpos( $temp_css_file, '/*arf checkbox radio css end*/' );
2117
2118                                $end_get_css_radiocheck_lenght = strlen( '/*arf checkbox radio css end*/' );
2119
2120                                if ( $start_get_css_radiocheck_position && $end_get_css_radiocheck_position ) {
2121
2122                                        $temp_css_file_radiocheckbox = substr( $temp_css_file, $start_get_css_radiocheck_position, ( $end_get_css_radiocheck_position + $end_get_css_radiocheck_lenght ) - $start_get_css_radiocheck_position );
2123                                        $temp_css_file               = str_replace( $temp_css_file_radiocheckbox, '', $temp_css_file );
2124                                }
2125                        }
2126
2127                        $temp_css_file = str_replace( '##', '#', $temp_css_file );
2128
2129                        $wp_filesystem->put_contents( $css_file_new, $temp_css_file, 0777 );
2130                }
2131
2132                if ( 'material' == $form_css['arfinputstyle'] ) {
2133                        $temp_materialize_file = str_replace( '##', '#', $temp_materialize_file );
2134                        $wp_filesystem->put_contents( $material_css_file_new, $temp_materialize_file, 0777 );
2135                }
2136
2137                $message = addslashes( esc_html__( 'Form is saved successfully.', 'arforms-form-builder' ) );
2138                if ( isset( $hidden_field_ids ) && ! empty( $hidden_field_ids ) && count( $hidden_field_ids ) > 0 ) {
2139                        $return_json_data['arf_hidden_field_ids'] = $hidden_field_ids;
2140                }
2141
2142                $return_json_data['arf_default_newarr']           = json_encode( $temp_new_values );
2143                $return_json_data['arf_new_standard_css_data']    = $standard_css_file;
2144                $return_json_data['arf_new_materialize_css_data'] = $materialize_css_file;
2145               
2146                $return_json_data_final = json_encode( $return_json_data );
2147                echo esc_html( $message ) . '^|^' . esc_html( $id ) . '^|^' . $return_json_data_final . '^|^'; //phpcs:ignore
2148
2149                $all_fields     = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . $tbl_arf_fields . '` WHERE form_id = %d', $id ) ); //phpcs:ignore
2150                $arf_all_fields = array();
2151
2152                foreach ( $all_fields as $key => $field_ ) {
2153                        foreach ( $field_ as $k => $field_val ) {
2154                                if ( $k == 'options' ) {
2155                                        $arf_all_fields[ $key ][ $k ] = json_decode( $field_val, true );
2156                                        if ( json_last_error() != JSON_ERROR_NONE ) {
2157                                                $arf_all_fields[ $key ][ $k ] = maybe_unserialize( $field_val );
2158                                        }
2159                                } elseif ( $k == 'field_options' ) {
2160                                        $field_opts = json_decode( $field_val, true );
2161                                        if ( json_last_error() != JSON_ERROR_NONE ) {
2162                                                $field_opts = maybe_unserialize( $field_val );
2163                                        }
2164                                        foreach ( $field_opts as $ki => $val_ ) {
2165                                                $arf_all_fields[ $key ][ $ki ] = $val_;
2166                                        }
2167                                } else {
2168                                        $arf_all_fields[ $key ][ $k ] = $field_val;
2169                                }
2170                        }
2171                }
2172
2173                $values['fields'] = $arf_all_fields;
2174
2175                if ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) {
2176                        $arf_load_confirm_email = array();
2177                        $totalpass              = 0;
2178                        foreach ( $values['fields'] as $arrkey => $field ) {
2179
2180                                if ( $field['type'] == 'email' ) {
2181                                        $field['id'] = $arflitefieldhelper->arfliteget_actual_id( $field['id'] );
2182                                        if ( isset( $field['confirm_email'] ) && $field['confirm_email'] == 1 && isset( $arf_load_confirm_email['confirm_email_field'] ) && $arf_load_confirm_email['confirm_email_field'] == $field['id'] ) {
2183                                                $values['confirm_email_arr'][ $field['id'] ] = isset( $field['confirm_email_field'] ) ? $field['confirm_email_field'] : '';
2184                                        } else {
2185                                                $arf_load_confirm_email['confirm_email_field'] = isset( $field['confirm_email_field'] ) ? $field['confirm_email_field'] : '';
2186                                        }
2187                                }
2188
2189                                if ( $field['type'] == 'email' && isset( $field['confirm_email'] ) && $field['confirm_email'] == 1 ) {
2190                                        if ( isset( $field['confirm_email'] ) && $field['confirm_email'] == 1 && isset( $arf_load_confirm_email['confirm_email_field'] ) && $arf_load_confirm_email['confirm_email_field'] == $field['id'] ) {
2191                                                $values['confirm_email_arr'][ $field['id'] ] = isset( $field['confirm_email_field'] ) ? $field['confirm_email_field'] : '';
2192                                        } else {
2193                                                $arf_load_confirm_email['confirm_email_field'] = isset( $field['confirm_email_field'] ) ? $field['confirm_email_field'] : '';
2194                                        }
2195                                        $confirm_email_field = $arflitefieldhelper->arflite_get_confirm_email_field( $field );
2196                                        $values['fields']    = $arflitefieldhelper->arflitearray_push_after( $values['fields'], array( $confirm_email_field ), $arrkey + $totalpass );
2197                                        $totalpass++;
2198                                }
2199                        }
2200                        $field_data = file_get_contents( ARFLITE_VIEWS_PATH . '/arflite_editor_data.json' );
2201
2202                        $field_data_obj = json_decode( $field_data );
2203
2204                        $arf_fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . $tbl_arf_fields . '` WHERE `form_id` = %d', $id ), ARRAY_A ); //phpcs:ignore
2205
2206                        $field_order = $final_field_order;
2207
2208                        $field_resize_width = json_decode( $options['arf_field_resize_width'], true );
2209                        $data['form_css']   = $db_data['form_css'];
2210                        $frm_css            = maybe_unserialize( $data['form_css'] );
2211                        $newarr             = array();
2212                        $arr                = $frm_css;
2213                        if ( isset( $arr ) && ! empty( $arr ) && is_array( $arr ) ) {
2214                                foreach ( $arr as $k => $v ) {
2215                                        $newarr[ $k ] = $v;
2216                                }
2217                        }
2218                        $arf_sorted_fields = array();
2219                        if ( $field_order != '' ) {
2220                                if ( ! is_array( $field_order ) ) {
2221                                        $field_order = json_decode( $field_order, true );
2222                                }
2223                                asort( $field_order );
2224                                foreach ( $field_order as $field_id => $order ) {
2225                                        if ( is_int( $field_id ) ) {
2226                                                foreach ( $arf_fields as $field ) {
2227                                                        if ( $field_id == $field['id'] ) {
2228                                                                $arf_sorted_fields[] = $field;
2229                                                        }
2230                                                }
2231                                        } else {
2232                                                $arf_sorted_fields[] = $field_id;
2233                                        }
2234                                }
2235                        }
2236
2237                        if ( isset( $arf_sorted_fields ) && ! empty( $arf_sorted_fields ) ) {
2238                                $arf_fields = $arf_sorted_fields;
2239                        }
2240                        $class_array       = array();
2241                        $conut_arf_fields  = count( $arf_fields );
2242                        $index_arf_fields  = 0;
2243                        $arf_field_counter = 1;
2244
2245                        foreach ( $arf_fields as $key => $field ) {
2246                                $display_field_in_editor_from_outside = apply_filters( 'arflite_display_field_in_editor_outside', false, $field );
2247                                if ( is_array( $field ) ) {
2248                                        if ( $field['type'] == 'hidden' ) {
2249                                                continue;
2250                                        }
2251
2252                                        $field_name = 'item_meta[' . $field['id'] . ']';
2253
2254                                        $field_opt = json_decode( $field['field_options'], true );
2255                                        if ( json_last_error() != JSON_ERROR_NONE ) {
2256                                                $field_opt = maybe_unserialize( $field['field_options'] );
2257                                        }
2258                                          $class = $field_opt['inner_class'];
2259                                        array_push( $class_array, $field_opt['inner_class'] );
2260                                        $field['default_value'] = $field_opt['default_value'];
2261
2262                                        $has_options = false;
2263                                        if ( isset( $field['options'] ) && $field['options'] != '' ) {
2264                                                $has_options  = true;
2265                                                $field_opt_db = json_decode( $field['options'], true );
2266                                                if ( json_last_error() != JSON_ERROR_NONE ) {
2267                                                        $field_opt_db = maybe_unserialize( $field['optinos'] );
2268                                                }
2269                                        }
2270
2271                                        foreach ( $field_opt as $k => $field_opt_val ) {
2272                                                if ( $k != 'options' ) {
2273                                                        $field[ $k ] = $this->arflite_html_entity_decode( $field_opt_val );
2274                                                } else {
2275                                                        if ( $has_options == true ) {
2276                                                                $field[ $k ] = $field_opt_db;
2277                                                        }
2278                                                }
2279                                        }
2280                                }
2281                                if ( ! $display_field_in_editor_from_outside ) {
2282                                        $is_form_save = true;
2283                                        require ARFLITE_VIEWS_PATH . '/arflite_field_editor.php';
2284                                } else {
2285                                        do_action( 'arflite_render_field_in_editor_outside', $field, $field_data_obj, $field_order, $frm_css, $data, $id, array(), false, $newarr );
2286                                }
2287                                unset( $field );
2288                                unset( $field_name );
2289
2290                                $arf_field_counter++;
2291                        }
2292                }
2293
2294                die();
2295        }
2296
2297        function arflite_check_current_val() {
2298                return 1;
2299        }
2300
2301
2302        function arflite_check_valid_sample() {
2303                return 1;
2304        }
2305
2306
2307        function arflitechecksoringcode( $code, $info ) {
2308                global $arfliteformcontroller;
2309
2310                $mysortid = base64_decode( $code );
2311                $mysortid = explode( '^', $mysortid );
2312
2313                if ( $mysortid != '' && count( $mysortid ) > 0 ) {
2314                        $setdata = $arfliteformcontroller->arflitesetdata( $code, $info );
2315
2316                        return $setdata;
2317                        exit;
2318                } else {
2319                        return 0;
2320                        exit;
2321                }
2322        }
2323
2324        function arflitesetdata( $code, $info ) {
2325                if ( $code != '' ) {
2326                        $mysortid = base64_decode( $code );
2327                        $mysortid = explode( '^', $mysortid );
2328                        $mysortid = $mysortid[4];
2329
2330                        update_option( 'arfliteIsSorted', 'Yes' );
2331                        update_option( 'arfliteSortOrder', $code );
2332                        update_option( 'arfliteSortId', $mysortid );
2333                        update_option( 'arfliteSortInfo', $info );
2334
2335                        global $wpdb;
2336                        $res1 = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . "options WHERE option_name = 'arflite_options' ", OBJECT_K );
2337                        foreach ( $res1 as $key1 => $val1 ) {
2338                                $mynewarr = maybe_unserialize( $val1->option_value );
2339                        }
2340
2341                        update_option( 'arflite_options', $mynewarr );
2342                        set_transient( 'arflite_options', $mynewarr );
2343
2344                        return 1;
2345                        exit;
2346                } else {
2347                        return 0;
2348                        exit;
2349                }
2350        }
2351
2352        function get_arflite_google_fonts() {
2353                global $arflitegooglefontbaseurl;
2354
2355                $font_list = array(
2356                        'ABeeZee',
2357                        'Abel',
2358                        'Abril Fatface',
2359                        'Aclonica',
2360                        'Acme',
2361                        'Actor',
2362                        'Adamina',
2363                        'Advent Pro',
2364                        'Aguafina Script',
2365                        'Akronim',
2366                        'Aladin',
2367                        'Aldrich',
2368                        'Alef',
2369                        'Alegreya',
2370                        'Alegreya SC',
2371                        'Alegreya Sans',
2372                        'Alegreya Sans SC',
2373                        'Alex Brush',
2374                        'Alfa Slab One',
2375                        'Alice',
2376                        'Alike',
2377                        'Alike Angular',
2378                        'Allan',
2379                        'Allerta',
2380                        'Allerta Stencil',
2381                        'Allura',
2382                        'Almendra',
2383                        'Almendra Display',
2384                        'Almendra SC',
2385                        'Amarante',
2386                        'Amaranth',
2387                        'Amatic SC',
2388                        'Amethysta',
2389                        'Amiri',
2390                        'Amita',
2391                        'Anaheim',
2392                        'Andada',
2393                        'Andika',
2394                        'Angkor',
2395                        'Annie Use Your Telescope',
2396                        'Anonymous Pro',
2397                        'Antic',
2398                        'Antic Didone',
2399                        'Antic Slab',
2400                        'Anton',
2401                        'Arapey',
2402                        'Arbutus',
2403                        'Arbutus Slab',
2404                        'Architects Daughter',
2405                        'Archivo Black',
2406                        'Archivo Narrow',
2407                        'Arimo',
2408                        'Arizonia',
2409                        'Armata',
2410                        'Artifika',
2411                        'Arvo',
2412                        'Arya',
2413                        'Asap',
2414                        'Asar',
2415                        'Asset',
2416                        'Astloch',
2417                        'Asul',
2418                        'Atomic Age',
2419                        'Aubrey',
2420                        'Audiowide',
2421                        'Autour One',
2422                        'Average',
2423                        'Average Sans',
2424                        'Averia Gruesa Libre',
2425                        'Averia Libre',
2426                        'Averia Sans Libre',
2427                        'Averia Serif Libre',
2428                        'Bad Script',
2429                        'Balthazar',
2430                        'Bangers',
2431                        'Basic',
2432                        'Battambang',
2433                        'Baumans',
2434                        'Bayon',
2435                        'Belgrano',
2436                        'Belleza',
2437                        'BenchNine',
2438                        'Bentham',
2439                        'Berkshire Swash',
2440                        'Bevan',
2441                        'Bigelow Rules',
2442                        'Bigshot One',
2443                        'Bilbo',
2444                        'Bilbo Swash Caps',
2445                        'Biryani',
2446                        'Bitter',
2447                        'Black Ops One',
2448                        'Bokor',
2449                        'Bonbon',
2450                        'Boogaloo',
2451                        'Bowlby One',
2452                        'Bowlby One SC',
2453                        'Brawler',
2454                        'Bree Serif',
2455                        'Bubblegum Sans',
2456                        'Bubbler One',
2457                        'Buda',
2458                        'Buenard',
2459                        'Butcherman',
2460                        'Butterfly Kids',
2461                        'Cabin',
2462                        'Cabin Condensed',
2463                        'Cabin Sketch',
2464                        'Caesar Dressing',
2465                        'Cagliostro',
2466                        'Calligraffitti',
2467                        'Cambay',
2468                        'Cambo',
2469                        'Candal',
2470                        'Cantarell',
2471                        'Cantata One',
2472                        'Cantora One',
2473                        'Capriola',
2474                        'Cardo',
2475                        'Carme',
2476                        'Carrois Gothic',
2477                        'Carrois Gothic SC',
2478                        'Carter One',
2479                        'Catamaran',
2480                        'Caudex',
2481                        'Caveat',
2482                        'Caveat Brush',
2483                        'Cedarville Cursive',
2484                        'Ceviche One',
2485                        'Changa One',
2486                        'Chango',
2487                        'Chau Philomene One',
2488                        'Chela One',
2489                        'Chelsea Market',
2490                        'Chenla',
2491                        'Cherry Cream Soda',
2492                        'Cherry Swash',
2493                        'Chewy',
2494                        'Chicle',
2495                        'Chivo',
2496                        'Chonburi',
2497                        'Cinzel',
2498                        'Cinzel Decorative',
2499                        'Clicker Script',
2500                        'Coda',
2501                        'Coda Caption',
2502                        'Codystar',
2503                        'Combo',
2504                        'Comfortaa',
2505                        'Coming Soon',
2506                        'Concert One',
2507                        'Condiment',
2508                        'Content',
2509                        'Contrail One',
2510                        'Convergence',
2511                        'Cookie',
2512                        'Copse',
2513                        'Corben',
2514                        'Courgette',
2515                        'Cousine',
2516                        'Coustard',
2517                        'Covered By Your Grace',
2518                        'Crafty Girls',
2519                        'Creepster',
2520                        'Crete Round',
2521                        'Crimson Text',
2522                        'Croissant One',
2523                        'Crushed',
2524                        'Cuprum',
2525                        'Cutive',
2526                        'Cutive Mono',
2527                        'Damion',
2528                        'Dancing Script',
2529                        'Dangrek',
2530                        'Dawning of a New Day',
2531                        'Days One',
2532                        'Dekko',
2533                        'Delius',
2534                        'Delius Swash Caps',
2535                        'Delius Unicase',
2536                        'Della Respira',
2537                        'Denk One',
2538                        'Devonshire',
2539                        'Dhurjati',
2540                        'Didact Gothic',
2541                        'Diplomata',
2542                        'Diplomata SC',
2543                        'Domine',
2544                        'Donegal One',
2545                        'Doppio One',
2546                        'Dorsa',
2547                        'Dosis',
2548                        'Dr Sugiyama',
2549                        'Droid Sans',
2550                        'Droid Sans Mono',
2551                        'Droid Serif',
2552                        'Duru Sans',
2553                        'Dynalight',
2554                        'EB Garamond',
2555                        'Eagle Lake',
2556                        'Eater',
2557                        'Economica',
2558                        'Eczar',
2559                        'Ek Mukta',
2560                        'Electrolize',
2561                        'Elsie',
2562                        'Elsie Swash Caps',
2563                        'Emblema One',
2564                        'Emilys Candy',
2565                        'Engagement',
2566                        'Englebert',
2567                        'Enriqueta',
2568                        'Erica One',
2569                        'Esteban',
2570                        'Euphoria Script',
2571                        'Ewert',
2572                        'Exo',
2573                        'Exo 2',
2574                        'Expletus Sans',
2575                        'Fanwood Text',
2576                        'Fascinate',
2577                        'Fascinate Inline',
2578                        'Faster One',
2579                        'Fasthand',
2580                        'Fauna One',
2581                        'Federant',
2582                        'Federo',
2583                        'Felipa',
2584                        'Fenix',
2585                        'Finger Paint',
2586                        'Fira Mono',
2587                        'Fira Sans',
2588                        'Fjalla One',
2589                        'Fjord One',
2590                        'Flamenco',
2591                        'Flavors',
2592                        'Fondamento',
2593                        'Fontdiner Swanky',
2594                        'Forum',
2595                        'Francois One',
2596                        'Freckle Face',
2597                        'Fredericka the Great',
2598                        'Fredoka One',
2599                        'Freehand',
2600                        'Fresca',
2601                        'Frijole',
2602                        'Fruktur',
2603                        'Fugaz One',
2604                        'GFS Didot',
2605                        'GFS Neohellenic',
2606                        'Gabriela',
2607                        'Gafata',
2608                        'Galdeano',
2609                        'Galindo',
2610                        'Gentium Basic',
2611                        'Gentium Book Basic',
2612                        'Geo',
2613                        'Geostar',
2614                        'Geostar Fill',
2615                        'Germania One',
2616                        'Gidugu',
2617                        'Gilda Display',
2618                        'Give You Glory',
2619                        'Glass Antiqua',
2620                        'Glegoo',
2621                        'Gloria Hallelujah',
2622                        'Goblin One',
2623                        'Gochi Hand',
2624                        'Gorditas',
2625                        'Goudy Bookletter 1911',
2626                        'Graduate',
2627                        'Grand Hotel',
2628                        'Gravitas One',
2629                        'Great Vibes',
2630                        'Griffy',
2631                        'Gruppo',
2632                        'Gudea',
2633                        'Gurajada',
2634                        'Habibi',
2635                        'Halant',
2636                        'Hammersmith One',
2637                        'Hanalei',
2638                        'Hanalei Fill',
2639                        'Handlee',
2640                        'Hanuman',
2641                        'Happy Monkey',
2642                        'Headland One',
2643                        'Henny Penny',
2644                        'Herr Von Muellerhoff',
2645                        'Hind',
2646                        'Hind Siliguri',
2647                        'Hind Vadodara',
2648                        'Holtwood One SC',
2649                        'Homemade Apple',
2650                        'Homenaje',
2651                        'IM Fell DW Pica',
2652                        'IM Fell DW Pica SC',
2653                        'IM Fell Double Pica',
2654                        'IM Fell Double Pica SC',
2655                        'IM Fell English',
2656                        'IM Fell English SC',
2657                        'IM Fell French Canon',
2658                        'IM Fell French Canon SC',
2659                        'IM Fell Great Primer',
2660                        'IM Fell Great Primer SC',
2661                        'Iceberg',
2662                        'Iceland',
2663                        'Imprima',
2664                        'Inconsolata',
2665                        'Inder',
2666                        'Indie Flower',
2667                        'Inika',
2668                        'Inknut Antiqua',
2669                        'Irish Grover',
2670                        'Istok Web',
2671                        'Italiana',
2672                        'Italianno',
2673                        'Itim',
2674                        'Jacques Francois',
2675                        'Jacques Francois Shadow',
2676                        'Jaldi',
2677                        'Jim Nightshade',
2678                        'Jockey One',
2679                        'Jolly Lodger',
2680                        'Josefin Sans',
2681                        'Josefin Slab',
2682                        'Joti One',
2683                        'Judson',
2684                        'Julee',
2685                        'Julius Sans One',
2686                        'Junge',
2687                        'Jura',
2688                        'Just Another Hand',
2689                        'Just Me Again Down Here',
2690                        'Kadwa',
2691                        'Kalam',
2692                        'Kameron',
2693                        'Kantumruy',
2694                        'Karla',
2695                        'Karma',
2696                        'Kaushan Script',
2697                        'Kavoon',
2698                        'Kdam Thmor',
2699                        'Keania One',
2700                        'Kelly Slab',
2701                        'Kenia',
2702                        'Khand',
2703                        'Khmer',
2704                        'Khula',
2705                        'Kite One',
2706                        'Knewave',
2707                        'Kotta One',
2708                        'Koulen',
2709                        'Kranky',
2710                        'Kreon',
2711                        'Kristi',
2712                        'Krona One',
2713                        'Kurale',
2714                        'La Belle Aurore',
2715                        'Laila',
2716                        'Lakki Reddy',
2717                        'Lancelot',
2718                        'Lateef',
2719                        'Lato',
2720                        'League Script',
2721                        'Leckerli One',
2722                        'Ledger',
2723                        'Lekton',
2724                        'Lemon',
2725                        'Libre Baskerville',
2726                        'Life Savers',
2727                        'Lilita One',
2728                        'Lily Script One',
2729                        'Limelight',
2730                        'Linden Hill',
2731                        'Lobster',
2732                        'Lobster Two',
2733                        'Londrina Outline',
2734                        'Londrina Shadow',
2735                        'Londrina Sketch',
2736                        'Londrina Solid',
2737                        'Lora',
2738                        'Love Ya Like A Sister',
2739                        'Loved by the King',
2740                        'Lovers Quarrel',
2741                        'Luckiest Guy',
2742                        'Lusitana',
2743                        'Lustria',
2744                        'Macondo',
2745                        'Macondo Swash Caps',
2746                        'Magra',
2747                        'Maiden Orange',
2748                        'Mako',
2749                        'Mallanna',
2750                        'Mandali',
2751                        'Marcellus',
2752                        'Marcellus SC',
2753                        'Marck Script',
2754                        'Margarine',
2755                        'Marko One',
2756                        'Marmelad',
2757                        'Martel',
2758                        'Martel Sans',
2759                        'Marvel',
2760                        'Mate',
2761                        'Mate SC',
2762                        'Maven Pro',
2763                        'McLaren',
2764                        'Meddon',
2765                        'MedievalSharp',
2766                        'Medula One',
2767                        'Megrim',
2768                        'Meie Script',
2769                        'Merienda',
2770                        'Merienda One',
2771                        'Merriweather',
2772                        'Merriweather Sans',
2773                        'Metal',
2774                        'Metal Mania',
2775                        'Metamorphous',
2776                        'Metrophobic',
2777                        'Michroma',
2778                        'Milonga',
2779                        'Miltonian',
2780                        'Miltonian Tattoo',
2781                        'Miniver',
2782                        'Miss Fajardose',
2783                        'Modak',
2784                        'Modern Antiqua',
2785                        'Molengo',
2786                        'Molle',
2787                        'Monda',
2788                        'Monofett',
2789                        'Monoton',
2790                        'Monsieur La Doulaise',
2791                        'Montaga',
2792                        'Montez',
2793                        'Montserrat',
2794                        'Montserrat Alternates',
2795                        'Montserrat Subrayada',
2796                        'Moul',
2797                        'Moulpali',
2798                        'Mountains of Christmas',
2799                        'Mouse Memoirs',
2800                        'Mr Bedfort',
2801                        'Mr Dafoe',
2802                        'Mr De Haviland',
2803                        'Mrs Saint Delafield',
2804                        'Mrs Sheppards',
2805                        'Muli',
2806                        'Mystery Quest',
2807                        'NTR',
2808                        'Neucha',
2809                        'Neuton',
2810                        'New Rocker',
2811                        'News Cycle',
2812                        'Niconne',
2813                        'Nixie One',
2814                        'Nobile',
2815                        'Nokora',
2816                        'Norican',
2817                        'Nosifer',
2818                        'Nothing You Could Do',
2819                        'Noticia Text',
2820                        'Noto Sans',
2821                        'Noto Serif',
2822                        'Nova Cut',
2823                        'Nova Flat',
2824                        'Nova Mono',
2825                        'Nova Oval',
2826                        'Nova Round',
2827                        'Nova Script',
2828                        'Nova Slim',
2829                        'Nova Square',
2830                        'Numans',
2831                        'Nunito',
2832                        'Odor Mean Chey',
2833                        'Offside',
2834                        'Old Standard TT',
2835                        'Oldenburg',
2836                        'Oleo Script',
2837                        'Oleo Script Swash Caps',
2838                        'Open Sans',
2839                        'Open Sans Condensed',
2840                        'Oranienbaum',
2841                        'Orbitron',
2842                        'Oregano',
2843                        'Orienta',
2844                        'Original Surfer',
2845                        'Oswald',
2846                        'Over the Rainbow',
2847                        'Overlock',
2848                        'Overlock SC',
2849                        'Ovo',
2850                        'Oxygen',
2851                        'Oxygen Mono',
2852                        'PT Mono',
2853                        'PT Sans',
2854                        'PT Sans Caption',
2855                        'PT Sans Narrow',
2856                        'PT Serif',
2857                        'PT Serif Caption',
2858                        'Pacifico',
2859                        'Palanquin',
2860                        'Palanquin Dark',
2861                        'Paprika',
2862                        'Parisienne',
2863                        'Passero One',
2864                        'Passion One',
2865                        'Pathway Gothic One',
2866                        'Patrick Hand',
2867                        'Patrick Hand SC',
2868                        'Patua One',
2869                        'Paytone One',
2870                        'Peddana',
2871                        'Peralta',
2872                        'Permanent Marker',
2873                        'Petit Formal Script',
2874                        'Petrona',
2875                        'Philosopher',
2876                        'Piedra',
2877                        'Pinyon Script',
2878                        'Pirata One',
2879                        'Plaster',
2880                        'Play',
2881                        'Playball',
2882                        'Playfair Display',
2883                        'Playfair Display SC',
2884                        'Podkova',
2885                        'Poiret One',
2886                        'Poller One',
2887                        'Poly',
2888                        'Pompiere',
2889                        'Pontano Sans',
2890                        'Poppins',
2891                        'Port Lligat Sans',
2892                        'Port Lligat Slab',
2893                        'Pragati Narrow',
2894                        'Prata',
2895                        'Preahvihear',
2896                        'Press Start 2P',
2897                        'Princess Sofia',
2898                        'Prociono',
2899                        'Prosto One',
2900                        'Puritan',
2901                        'Purple Purse',
2902                        'Quando',
2903                        'Quantico',
2904                        'Quattrocento',
2905                        'Quattrocento Sans',
2906                        'Questrial',
2907                        'Quicksand',
2908                        'Quintessential',
2909                        'Qwigley',
2910                        'Racing Sans One',
2911                        'Radley',
2912                        'Rajdhani',
2913                        'Raleway',
2914                        'Raleway Dots',
2915                        'Ramabhadra',
2916                        'Ramaraja',
2917                        'Rambla',
2918                        'Rammetto One',
2919                        'Ranchers',
2920                        'Rancho',
2921                        'Ranga',
2922                        'Rationale',
2923                        'Ravi Prakash',
2924                        'Redressed',
2925                        'Reenie Beanie',
2926                        'Revalia',
2927                        'Rhodium Libre',
2928                        'Ribeye',
2929                        'Ribeye Marrow',
2930                        'Righteous',
2931                        'Risque',
2932                        'Roboto',
2933                        'Roboto Condensed',
2934                        'Roboto Mono',
2935                        'Roboto Slab',
2936                        'Rochester',
2937                        'Rock Salt',
2938                        'Rokkitt',
2939                        'Romanesco',
2940                        'Ropa Sans',
2941                        'Rosario',
2942                        'Rosarivo',
2943                        'Rouge Script',
2944                        'Rozha One',
2945                        'Rubik',
2946                        'Rubik Mono One',
2947                        'Rubik One',
2948                        'Ruda',
2949                        'Rufina',
2950                        'Ruge Boogie',
2951                        'Ruluko',
2952                        'Rum Raisin',
2953                        'Ruslan Display',
2954                        'Russo One',
2955                        'Ruthie',
2956                        'Rye',
2957                        'Sacramento',
2958                        'Sahitya',
2959                        'Sail',
2960                        'Salsa',
2961                        'Sanchez',
2962                        'Sancreek',
2963                        'Sansita One',
2964                        'Sarala',
2965                        'Sarina',
2966                        'Sarpanch',
2967                        'Satisfy',
2968                        'Scada',
2969                        'Schoolbell',
2970                        'Seaweed Script',
2971                        'Sevillana',
2972                        'Seymour One',
2973                        'Shadows Into Light',
2974                        'Shadows Into Light Two',
2975                        'Shanti',
2976                        'Share',
2977                        'Share Tech',
2978                        'Share Tech Mono',
2979                        'Shojumaru',
2980                        'Short Stack',
2981                        'Siemreap',
2982                        'Sigmar One',
2983                        'Signika',
2984                        'Signika Negative',
2985                        'Simonetta',
2986                        'Sintony',
2987                        'Sirin Stencil',
2988                        'Six Caps',
2989                        'Skranji',
2990                        'Slabo 13px',
2991                        'Slabo 27px',
2992                        'Slackey',
2993                        'Smokum',
2994                        'Smythe',
2995                        'Sniglet',
2996                        'Snippet',
2997                        'Snowburst One',
2998                        'Sofadi One',
2999                        'Sofia',
3000                        'Sonsie One',
3001                        'Sorts Mill Goudy',
3002                        'Source Code Pro',
3003                        'Source Sans Pro',
3004                        'Source Serif Pro',
3005                        'Special Elite',
3006                        'Spicy Rice',
3007                        'Spinnaker',
3008                        'Spirax',
3009                        'Squada One',
3010                        'Sree Krushnadevaraya',
3011                        'Stalemate',
3012                        'Stalinist One',
3013                        'Stardos Stencil',
3014                        'Stint Ultra Condensed',
3015                        'Stint Ultra Expanded',
3016                        'Stoke',
3017                        'Strait',
3018                        'Sue Ellen Francisco',
3019                        'Sumana',
3020                        'Sunshiney',
3021                        'Supermercado One',
3022                        'Sura',
3023                        'Suranna',
3024                        'Suravaram',
3025                        'Suwannaphum',
3026                        'Swanky and Moo Moo',
3027                        'Syncopate',
3028                        'Tangerine',
3029                        'Taprom',
3030                        'Tauri',
3031                        'Teko',
3032                        'Telex',
3033                        'Tenali Ramakrishna',
3034                        'Tenor Sans',
3035                        'Text Me One',
3036                        'The Girl Next Door',
3037                        'Tienne',
3038                        'Tillana',
3039                        'Timmana',
3040                        'Tinos',
3041                        'Titan One',
3042                        'Titillium Web',
3043                        'Trade Winds',
3044                        'Trocchi',
3045                        'Trochut',
3046                        'Trykker',
3047                        'Tulpen One',
3048                        'Ubuntu',
3049                        'Ubuntu Condensed',
3050                        'Ubuntu Mono',
3051                        'Ultra',
3052                        'Uncial Antiqua',
3053                        'Underdog',
3054                        'Unica One',
3055                        'UnifrakturCook',
3056                        'UnifrakturMaguntia',
3057                        'Unkempt',
3058                        'Unlock',
3059                        'Unna',
3060                        'VT323',
3061                        'Vampiro One',
3062                        'Varela',
3063                        'Varela Round',
3064                        'Vast Shadow',
3065                        'Vesper Libre',
3066                        'Vibur',
3067                        'Vidaloka',
3068                        'Viga',
3069                        'Voces',
3070                        'Volkhov',
3071                        'Vollkorn',
3072                        'Voltaire',
3073                        'Waiting for the Sunrise',
3074                        'Wallpoet',
3075                        'Walter Turncoat',
3076                        'Warnes',
3077                        'Wellfleet',
3078                        'Wendy One',
3079                        'Wire One',
3080                        'Work Sans',
3081                        'Yanone Kaffeesatz',
3082                        'Yantramanav',
3083                        'Yellowtail',
3084                        'Yeseva One',
3085                        'Yesteryear',
3086                        'Zeyada',
3087                        'Abhaya Libre',
3088                        'Amiko',
3089                        'Archivo',
3090                        'Aref Ruqaa',
3091                        'Arima Madurai',
3092                        'Arsenal',
3093                        'Asap Condensed',
3094                        'Assistant',
3095                        'Athiti',
3096                        'Atma',
3097                        'Bahiana',
3098                        'Baloo',
3099                        'Baloo Bhai',
3100                        'Baloo Bhaijaan',
3101                        'Baloo Bhaina',
3102                        'Baloo Chettan',
3103                        'Baloo Da',
3104                        'Baloo Paaji',
3105                        'Baloo Tamma',
3106                        'Baloo Tammudu',
3107                        'Baloo Thambi',
3108                        'Barlow',
3109                        'Barlow Condensed',
3110                        'Barlow Semi Condensed',
3111                        'Barrio',
3112                        'Bellefair',
3113                        'BioRhyme',
3114                        'BioRhyme Expanded',
3115                        'Bungee',
3116                        'Bungee Hairline',
3117                        'Bungee Inline',
3118                        'Bungee Outline',
3119                        'Bungee Shade',
3120                        'Cairo',
3121                        'Changa',
3122                        'Chathura',
3123                        'Coiny',
3124                        'Cormorant',
3125                        'Cormorant Garamond',
3126                        'Cormorant Infant',
3127                        'Cormorant SC',
3128                        'Cormorant Unicase',
3129                        'Cormorant Upright',
3130                        'David Libre',
3131                        'El Messiri',
3132                        'Encode Sans',
3133                        'Encode Sans Condensed',
3134                        'Encode Sans Expanded',
3135                        'Encode Sans Semi Condensed',
3136                        'Encode Sans Semi Expanded',
3137                        'Farsan',
3138                        'Faustina',
3139                        'Fira Sans Condensed',
3140                        'Fira Sans Extra Condensed',
3141                        'Frank Ruhl Libre',
3142                        'Galada',
3143                        'Harmattan',
3144                        'Heebo',
3145                        'Hind Guntur',
3146                        'Hind Madurai',
3147                        'IM Fell English',
3148                        'Jomhuria',
3149                        'Kanit',
3150                        'Katibeh',
3151                        'Kavivanar',
3152                        'Kumar One',
3153                        'Kumar One Outline',
3154                        'Lalezar',
3155                        'Lemonada',
3156                        'Libre Barcode 128',
3157                        'Libre Barcode 128 Text',
3158                        'Libre Barcode 39',
3159                        'Libre Barcode 39 Extended',
3160                        'Libre Barcode 39 Extended Text',
3161                        'Libre Barcode 39 Text',
3162                        'Libre Franklin',
3163                        'Mada',
3164                        'Maitree',
3165                        'Manuale',
3166                        'Meera Inimai',
3167                        'Miriam Libre',
3168                        'Mirza',
3169                        'Mitr',
3170                        'Mogra',
3171                        'Mukta',
3172                        'Mukta Mahee',
3173                        'Mukta Malar',
3174                        'Mukta Vaani',
3175                        'Nunito Sans',
3176                        'Overpass',
3177                        'Overpass Mono',
3178                        'Padauk',
3179                        'Pangolin',
3180                        'Pattaya',
3181                        'Pavanam',
3182                        'Pridi',
3183                        'Prompt',
3184                        'Proza Libre',
3185                        'Rakkas',
3186                        'Rasa',
3187                        'Reem Kufi',
3188                        'Saira',
3189                        'Saira Condensed',
3190                        'Saira Extra Condensed',
3191                        'Saira Semi Condensed',
3192                        'Sansita',
3193                        'Scheherazade',
3194                        'Scope One',
3195                        'Secular One',
3196                        'Sedgwick Ave',
3197                        'Sedgwick Ave Display',
3198                        'Shrikhand',
3199                        'Space Mono',
3200                        'Spectral',
3201                        'Spectral SC',
3202                        'Sriracha',
3203                        'Suez One',
3204                        'Taviraj',
3205                        'Trirong',
3206                        'Vollkorn SC',
3207                        'Yatra One',
3208                        'Yrsa',
3209                        'Zilla Slab',
3210                        'Zilla Slab Highlight',
3211                );
3212
3213                sort( $font_list );
3214                return $font_list;
3215        }
3216
3217        function arflitebr2nl( $string ) {
3218                return preg_replace( '/\<br(\s*)?\/?\>/i', "\n", $string );
3219        }
3220
3221        function arflite_remove_br( $content ) {
3222                if ( trim( $content ) == '' ) {
3223                        return $content;
3224                }
3225
3226                $content = preg_replace( '|<br />\s*<br />|', '', $content );
3227                $content = preg_replace( "~\r?~", '', $content );
3228                $content = preg_replace( "~\r\n?~", '', $content );
3229                $content = preg_replace( "/\n\n+/", '', $content );
3230
3231                $content = preg_replace( "|\n|", '', $content );
3232                $content = preg_replace( "~\n~", '', $content );
3233
3234                return $content;
3235        }
3236
3237
3238        function arflitedeciamlseparator( $value = 0 ) {
3239                global $arformsmain, $arflite_decimal_separator;
3240
3241                $value                     = number_format( (float) $value, 2 );
3242
3243                $decimal_separator = $arformsmain->arforms_get_settings('decimal_separator','general_settings');
3244                $decimal_separator = !empty( $decimal_separator ) ? $decimal_separator : '.';
3245
3246                $arflite_decimal_separator = $decimal_separator;
3247
3248                if ( $arflite_decimal_separator == ',' ) {
3249                        $value = str_replace( '.', ',', $value );
3250                } elseif ( $arflite_decimal_separator == '.' ) {
3251                        $value = $value;
3252                } else {
3253                        $value = round( $value );
3254                }
3255                return $value;
3256        }
3257
3258        function arflite_get_form_hidden_field( $form, $fields, $values, $arflite_preview, $is_widget_or_modal, $arflite_data_uniq_id, $form_action, $loaded_field, $type, $is_close_link, $arf_current_token ) {
3259
3260                $hidden_fields = '';
3261                global $arfliterecordcontroller, $arformsmain, $arflitefieldhelper, $arflite_form_all_footer_js,$arflite_decimal_separator,$is_gutenberg;
3262
3263                $arflite_http_server_agent = !empty( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field($_SERVER['HTTP_USER_AGENT']) : '';
3264                $browser_info              = $arfliterecordcontroller->arflitegetBrowser( $arflite_http_server_agent );
3265
3266                $decimal_separator = $arformsmain->arforms_get_settings('decimal_separator','general_settings');
3267                $decimal_separator = !empty( $decimal_separator ) ? $decimal_separator : '.';
3268                $arflite_decimal_separator = $decimal_separator;
3269
3270                $arf_form_hide_after_submit_val = ( isset( $form->options['arf_form_hide_after_submit'] ) && $form->options['arf_form_hide_after_submit'] == '1' ) ? $form->options['arf_form_hide_after_submit'] : '';
3271
3272                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_browser_name" data-id="arf_browser_name" data-version="' . esc_attr( $browser_info['version'] ) . '" value="' . esc_attr( $browser_info['name'] ) . '" />';
3273
3274                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arflite_entry_nonce" id="arflite_entry_nonce" value="' . wp_create_nonce( 'arflite_entry_nonce' ) . '" />';
3275
3276                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="imagename_' . esc_attr( $form->id . '_' . $arflite_data_uniq_id ) . '" id="imagename_' . esc_attr( $form->id . '_' . $arflite_data_uniq_id ) . '" value="" />';
3277
3278                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arfdecimal_separator" data-id="arfdecimal_separator" value="' . esc_attr( $arflite_decimal_separator ) . '" />';
3279
3280                if ( in_array( 'date', $loaded_field ) ) {
3281                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arfform_date_formate_' . esc_attr( $form->id ) . '" data-id="arfform_date_formate_' . esc_attr( $form->id ) . '" value="' . esc_attr( $form->form_css['date_format'] ) . '" />';
3282                }
3283
3284                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_key_' . esc_attr( $form->id ) . '" data-id="form_key_' . esc_attr( $form->id ) . '" value="' . esc_attr( $form->form_key ) . '" />';
3285
3286                $arf_success_message_show_time = $arformsmain->arforms_get_settings('arf_success_message_show_time','general_settings');
3287                $arf_success_message_show_time = !empty($arf_success_message_show_time) ? $arf_success_message_show_time : 3;
3288
3289                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_success_message_show_time_' . esc_attr( $form->id ) . '" data-id="arf_success_message_show_time_' . esc_attr( $form->id ) . '" value="' . esc_attr( $arf_success_message_show_time ) . '" />';
3290
3291                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_form_hide_after_submit_' . esc_attr( $form->id ) . '" data-id="arf_form_hide_after_submit_' . esc_attr( $form->id ) . '" value="' . esc_attr( $arf_form_hide_after_submit_val ) . '" />';
3292
3293                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="is_form_preview_' . esc_attr( $form->id ) . '" data-id="is_form_preview_' . esc_attr( $form->id ) . '" value="' . esc_attr( $arflite_preview ) . '" />';
3294
3295                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_validate_outside_' . esc_attr( $form->id ) . '" data-id="arf_validate_outside_' . esc_attr( $form->id ) . '" data-validate="' . ( ( apply_filters( 'arflite_validateform_outside', false, $form ) ) ? 1 : 0 ) . '" value="' . ( ( apply_filters( 'arflite_validateform_outside', false, $form ) ) ? 1 : 0 ) . '" />';
3296
3297                $arf_is_validateform_outside_filter = ( ( apply_filters( 'arflite_is_validateform_outside', false, $form ) ) ? 1 : 0 );
3298                $hidden_fields                     .= '<input type="hidden" data-jqvalidate="false" name="arf_is_validate_outside_' . esc_attr( $form->id ) . '" data-id="arf_is_validate_outside_' . esc_attr( $form->id ) . '" data-validate="' . esc_attr( $arf_is_validateform_outside_filter ) . '" value="' . esc_attr( $arf_is_validateform_outside_filter ) . '" />';
3299
3300                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" data-id="arflite_validate_outside_token" value="' . wp_create_nonce( 'arflite_validate_outside_nonce' ) . '" />';
3301
3302                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" data-id="arflite_reset_form_outside_token" value="' . wp_create_nonce( 'arflite_reset_form_outside_nonce' ) . '" />';
3303
3304                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_is_resetform_aftersubmit_' . esc_attr( $form->id ) . '" data-id="arf_is_resetform_aftersubmit_' . esc_attr( $form->id ) . '" value="' . ( ( apply_filters( 'arflite_is_resetform_aftersubmit', true, $form ) ) ? 1 : 0 ) . '" />';
3305
3306                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_is_resetform_outside_' . esc_attr( $form->id ) . '" data-id="arf_is_resetform_outside_' . esc_attr( $form->id ) . '" value="' . ( ( apply_filters( 'arflite_is_resetform_outside', false, $form ) ) ? 1 : 0 ) . '" />';
3307
3308                $form->form_css            = maybe_unserialize( $form->form_css );
3309                $arf_field_tooltipposition = isset( $form->form_css['arftooltipposition'] ) ? $form->form_css['arftooltipposition'] : 'top';
3310                $hidden_fields            .= '<input type="hidden" data-jqvalidate="false" name="arf_tooltip_settings_' . esc_attr( $form->id ) . '" data-id="arf_tooltip_settings_' . esc_attr( $form->id ) . '" class="arf_front_tooltip_settings" data-form-id="' . esc_attr( $form->id ) . '" data-color="' . esc_attr( $form->form_css['arf_tooltip_font_color'] ) . '" data-position="' . esc_attr( $arf_field_tooltipposition ) . '" data-width="' . esc_attr( $form->form_css['arf_tooltip_width'] ) . '" data-bg-color="' . esc_attr( $form->form_css['arf_tooltip_bg_color'] ) . '" />';
3311
3312                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arfsuccessmsgposition_' . esc_attr( $form->id ) . '" data-id="arfsuccessmsgposition_' . esc_attr( $form->id ) . '"  value="' . ( isset( $form->form_css['arfsuccessmsgposition'] ) ? esc_attr( $form->form_css['arfsuccessmsgposition'] ) : 'top' ) . '" />';
3313
3314                if ( isset( $arflite_preview ) && $arflite_preview ) {
3315                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_form_date_format" id="arf_form_date_format" value="' . esc_attr( $form->form_css['date_format'] ) . '" />';
3316                }
3317
3318                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_tooltip_error_' . esc_attr( $form->id ) . '" data-id="arflite_form_tooltip_error_' . esc_attr( $form->id ) . '" data-color="' . ( isset( $form->form_css['arferrorstylecolor'] ) ? esc_attr( $form->form_css['arferrorstylecolor'] ) : '' ) . '" data-position="' . ( isset( $form->form_css['arferrorstyleposition'] ) ? esc_attr( $form->form_css['arferrorstyleposition'] ) : '' ) . '" value="' . ( isset( $form->form_css['arferrorstyle'] ) ? esc_attr( $form->form_css['arferrorstyle'] ) : '' ) . '" />';
3319               
3320                global $is_beaverbuilder, $is_divibuilder , $is_fusionbuilder;
3321               
3322                if($is_gutenberg == false  && $is_beaverbuilder == false && $is_divibuilder == false  && $is_fusionbuilder == false)
3323                {
3324                        $hidden_fields .= '<input type="text" data-jqvalidate="false" class="arflite_fake_text_input" name="fake_text" data-id="fake_text" value="" />';
3325                }
3326
3327                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arfaction" value="' . esc_attr( $form_action ) . '" />';
3328                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_id" data-id="form_id" value="' . esc_attr( $form->id ) . '" />';
3329                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_data_id" data-id="form_data_id" value="' . esc_attr( $arflite_data_uniq_id ) . '" />';
3330                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_key" data-id="form_key" value="' . esc_attr( $form->form_key ) . '" />';
3331
3332                $arfmainformloadjscss = $arformsmain->arforms_get_settings('arfmainformloadjscss','general_settings');
3333                $arfmainformloadjscss = !empty( $arfmainformloadjscss ) ? $arfmainformloadjscss : 0;
3334
3335                if ( '1' == $arfmainformloadjscss ) {
3336                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="is_load_js_and_css_in_all_pages" data-id="is_load_js_and_css_in_all_pages" value="' . esc_attr( $arfmainformloadjscss ) . '" />';
3337                }
3338
3339                $pageURL = '';
3340                $pageURL = get_permalink( get_the_ID() );
3341                if ( $pageURL == '' ) {
3342                        $pageURL = site_url();
3343                }
3344
3345                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_display_type" data-id="form_display_type" value="' . ( ( $is_widget_or_modal ) ? 1 : 0 ) . '|' . $pageURL . '" />'; 
3346
3347                $form_submit_type = $arformsmain->arforms_get_settings('form_submit_type','general_settings');
3348                $form_submit_type = isset($form_submit_type ) ? $form_submit_type : 1;
3349
3350
3351                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="form_submit_type" data-id="form_submit_type" value="' . esc_attr( $form_submit_type ) . '" />';
3352
3353                $_SERVER['HTTP_REFERER'] = !empty( $_SERVER['HTTP_REFERER'] ) ? esc_url($_SERVER['HTTP_REFERER']) : ''; //phpcs:ignore
3354                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arf_http_referrer_url" data-id="arf_http_referrer_url" value="' . esc_url($_SERVER['HTTP_REFERER']) . '" />'; //phpcs:ignore
3355
3356                if ( isset( $controller ) && isset( $plugin ) ) {
3357                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="controller" value="' . esc_attr( $controller ) . '" />';
3358                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="plugin" value="' . esc_attr( $plugin ) . '" />';
3359                }
3360
3361                if ( is_admin() ) {
3362                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="entry_key" value="' . esc_attr( $values['entry_key'] ) . '" />';
3363                } else {
3364                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="entry_key" value="' . esc_attr( $values['entry_key'] ) . '" />';
3365                }
3366
3367                if ( $type != '' ) {
3368                        global $arfliteajaxurl;
3369                        $hidden_fields              .= '<input type="hidden"  data-jqvalidate="false" value="' . $arfliteajaxurl . '" data-id="admin_ajax_url" name="admin_ajax_url" >';
3370                        $_SESSION['last_open_modal'] = isset( $_SESSION['last_open_modal'] ) ? sanitize_text_field( $_SESSION['last_open_modal'] ) : '';
3371                        $hidden_fields              .= '<input type="hidden" data-jqvalidate="false" value="' . esc_html( $_SESSION['last_open_modal'] ) . '" data-id="current_modal" name="current_modal" >';
3372
3373                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" value="' . $is_close_link . '" data-id="is_close_link" name="is_close_link" >';
3374                        $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arfmainformurl" data-id="arfmainformurl" value="' . ARFLITEURL . '" />';
3375                }       
3376
3377                $hidden_captcha = $arformsmain->arforms_get_settings('hidden_captcha','general_settings');
3378                $hidden_captcha = !empty( $hidden_captcha ) ? $hidden_captcha : false;
3379
3380                $hidden_fields .= '<input type="hidden" data-jqvalidate="false" name="arflite_skip_captcha" data-id="arflite_skip_captcha" value="' . esc_attr( $hidden_captcha ) . '" />';
3381
3382                return $hidden_fields;
3383        }
3384
3385
3386
3387        function arflite_label_top_position( $label_size ) {
3388                return 'arf_main_label_' . $label_size . 'px';
3389        }
3390
3391        function arflite_get_all_field_html( $form, $values, $arflite_data_uniq_id, $fields, $arflite_preview, $arflite_errors, $inputStyle, $arf_arr_preset_data = array() ) {
3392
3393                global $arflitefieldhelper, $arfliteformcontroller, $arflitefieldcontroller, $arflitemainhelper, $arfliterecordcontroller, $arflite_form_all_footer_js, $arflitemaincontroller, $wpdb, $ARFLiteMdlDb, $arfliteversion,$arflite_style_settings,$arflite_form_all_footer_css, $tbl_arf_fields;
3394                $return_string       = '';
3395                $arf_classes_blank   = '';
3396                $confirm_email_style = '';
3397
3398                foreach ( $values['fields'] as $fieldkey => $fieldarr ) {
3399                        $fields_key = '';
3400                        $update_arr = false;
3401
3402                        if ( isset( $fields[ $fieldkey ] ) && $fieldarr['id'] == $fields[ $fieldkey ]->id ) {
3403                                $fields_key = $fieldkey;
3404                                $update_arr = true;
3405                        } else {
3406                                foreach ( $fields as $key => $value ) {
3407                                        if ( $fieldarr['id'] == $value->id ) {
3408                                                $fields_key = $key;
3409                                                $update_arr = true;
3410                                        }
3411                                }
3412                        }
3413
3414                        if ( $update_arr ) {
3415
3416                                if ( isset( $fieldarr['value'] ) && $fieldarr['value'] != '' ) {
3417
3418                                        $fields[ $fields_key ]->value = $fieldarr['value'];
3419
3420                                }
3421
3422                                if ( isset( $fieldarr['default_value'] ) && $fieldarr['default_value'] != '' ) {
3423
3424                                        $fields[ $fields_key ]->default_value = $fieldarr['default_value'];
3425
3426                                }
3427                        }
3428                }
3429
3430                $form_data           = new stdClass();
3431                $form_data->id       = $form->id;
3432                $form_data->form_key = $form->form_key;
3433                $form_data->options  = maybe_serialize( $form->options );
3434                $form_temp_fields    = maybe_unserialize( $form->temp_fields );
3435
3436                if ( ! is_array( $form_temp_fields ) ) {
3437                        $form_temp_fields = arflite_json_decode( json_encode( $form_temp_fields ), true );
3438                }
3439
3440                foreach ( $fields as $key => $value ) {
3441                        if ( ! isset( $res_data[ $key ] ) ) {
3442                                $res_data[ $key ] = new stdClass();
3443                        }
3444                        $res_data[ $key ]->id            = $value->id;
3445                        $res_data[ $key ]->type          = $value->type;
3446                        $res_data[ $key ]->name          = $value->name;
3447                        $res_data[ $key ]->field_options = json_encode( $value->field_options );
3448                }
3449                $css_data_arr = $form->form_css;
3450                $arr          = maybe_unserialize( $css_data_arr );
3451                $newarr       = array();
3452
3453                $newarr                     = $arr;
3454                $_SESSION['label_position'] = $newarr['position'];
3455                if ( $newarr['position'] == 'right' ) {
3456                        $class_position = 'right_container';
3457                } elseif ( $newarr['position'] == 'left' ) {
3458                        $class_position = 'left_container';
3459                } else {
3460                        $class_position = 'top_container';
3461                }
3462
3463                if ( $newarr['hide_labels'] == 1 ) {
3464                        $class_position .= ' none_container';
3465                }
3466
3467                $arf_fields = $fields;
3468
3469                $arf_column_field_custom_width = array(
3470                        'arf_2' => '1.5',
3471                        'arf_3' => '2',
3472                        'arf_4' => '2.25',
3473                        'arf_5' => '2.4',
3474                        'arf_6' => '2.5',
3475                );
3476
3477                $arf_fields_merged = array_merge( $arf_fields, $values['fields'] );
3478                $field_order       = isset( $form->options['arf_field_order'] ) ? $form->options['arf_field_order'] : '';
3479                $field_order       = ( $field_order != '' ) ? json_decode( $field_order, true ) : array();
3480
3481                asort( $field_order );
3482
3483                $field_resize_width = isset( $form->options['arf_field_resize_width'] ) ? $form->options['arf_field_resize_width'] : '';
3484                $field_resize_width = ( $field_resize_width != '' ) ? json_decode( $field_resize_width, true ) : array();
3485
3486                $arf_sorted_fields = array();
3487
3488                $temp_arf_fields = $values['fields'];
3489
3490                $confirm_email_field_id = $confirm_pass_field_id = array();
3491                $email_field_ids        = array();
3492                $x                      = 0;
3493                $email_exist            = 0;
3494                $fields_key             = array();
3495                foreach ( $values['fields'] as $temp_key => $temp_value ) {
3496                        $fields_key[ $temp_key ] = $temp_value['id'];
3497                }
3498
3499                $all_hidden_fields = array();
3500
3501                foreach ( $arf_fields as $key => $tmp_field ) {
3502
3503                        if ( $tmp_field->type == 'email' && ( isset($tmp_field->field_options['confirm_email']) && $tmp_field->field_options['confirm_email'] == '1') ) {
3504                                $current_key = array_search( $tmp_field->id, $fields_key );
3505
3506                                $current_field_arr = $form_temp_fields[ 'confirm_email_' . $tmp_field->id ];
3507
3508                                $current_field_arr['key'] = $current_key;
3509
3510                                $confirm_email_field_id[ $x ] = $values['fields'][ $current_key + 1 ]['id'];
3511
3512                                $email_field_ids[ $x ] = $tmp_field->id;
3513                                array_push( $arf_fields, $values['fields'][ $current_key + 1 ] );
3514
3515                                $email_field_key = array_keys( $email_field_ids, $tmp_field->id );
3516
3517                                if ( ( $key = array_search( $current_field_arr['order'], $field_order ) ) !== false ) {
3518                                        unset( $field_order[ $key ] );
3519                                        $field_order[ $confirm_email_field_id[ $email_field_key[0] ] ] = $current_field_arr['order'];
3520                                }
3521                        }
3522                        if ( $tmp_field->type == 'hidden' ) {
3523                                $all_hidden_fields[] = $tmp_field;
3524                        }
3525                        $x++;
3526                }
3527
3528                $field_pos = $x;
3529
3530                $field_order_updated = array();
3531                $field_order_updated = $field_order;
3532
3533                asort( $field_order_updated );
3534                foreach ( $all_hidden_fields as $field_id => $field ) {
3535                        $field_order_updated[ $field->id ] = $field_pos;
3536                        $field_pos++;
3537                }
3538
3539                foreach ( $field_order_updated as $field_id => $field ) {
3540                        if ( is_int( $field_id ) ) {
3541                                foreach ( $arf_fields as $temp_field ) {
3542                                        $temp_field    = $this->arfliteObjtoArray( $temp_field );
3543                                        $temp_field_id = $temp_field['id'];
3544                                        if ( $temp_field_id == $field_id ) {
3545                                                $arf_sorted_fields[] = $temp_field;
3546                                        }
3547                                }
3548                        } else {
3549                                $arf_sorted_fields[] = $field_id;
3550                        }
3551                }
3552
3553                if ( isset( $arf_sorted_fields ) && ! empty( $arf_sorted_fields ) ) {
3554                        $arf_fields = $arf_sorted_fields;
3555                }
3556
3557                unset( $field );
3558                $class_array      = array();
3559                $conut_arf_fields = count( $arf_fields );
3560                $index_arf_fields = 0;
3561
3562                $arf_field_front_counter = 1;
3563
3564                $OFData = wp_cache_get( 'arflite_form_fields_' . $form->id );
3565                if ( false == $OFData ) {
3566                        $OFData = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $tbl_arf_fields . ' WHERE form_id = %d ORDER BY id', $form->id ) ); //phpcs:ignore
3567                        wp_cache_set( 'arflite_form_fields_' . $form->id, $OFData );
3568                }
3569
3570                $arf_cookie_field_arr = array();
3571               
3572
3573                foreach ( $arf_fields as $field ) {
3574                        $material_input_cls = ( $inputStyle == 'material' ) ? 'input-field' : '';
3575                       
3576                        if ( is_array( $field ) || is_object( $field ) ) {
3577                                $field = $this->arfliteObjtoArray( $field );
3578
3579                                $field_opt = isset( $field['field_options'] ) ? $field['field_options'] : array();
3580                                if ( is_array( $field_opt ) && ! empty( $field_opt ) ) {
3581                                        foreach ( $field_opt as $k => $fieldOpt ) {
3582                                                if ( $k != 'options' && $k != 'default_value' ) {
3583                                                        $field[ $k ] = $fieldOpt;
3584                                                }
3585                                        }
3586                                } else {
3587                                        $field_opt = isset( $field['field_options'] ) ? json_decode( $field['field_options'], true ) : json_decode( json_encode( array() ), true );
3588                                        if ( json_last_error() != JSON_ERROR_NONE ) {
3589                                                $field_opt = maybe_unserialize( $field['field_options'] );
3590                                        }
3591                                        if ( is_array( $field_opt ) && ! empty( $field_opt ) ) {
3592                                                foreach ( $field_opt as $k => $fieldOpt ) {
3593                                                        if ( $k != 'options' && $k != 'default_value' ) {
3594                                                                $field[ $k ] = $fieldOpt;
3595                                                        }
3596                                                }
3597                                        }
3598                                }
3599
3600                                if ( isset( $field_resize_width[ $arf_field_front_counter ] ) ) {
3601
3602                                        if ( $field['type'] == 'confirm_email' ) {
3603                                                $field_level_class = isset( $field['confirm_email_classes'] ) ? $field['confirm_email_classes'] : 'arf_1';
3604                                        } else {
3605                                                $field_level_class = isset( $field_opt['classes'] ) ? $field_opt['classes'] : 'arf_1';
3606                                        }
3607                                        $calculte_width = str_replace( '%', '', $field_resize_width[ $arf_field_front_counter ] ) - ( isset( $arf_column_field_custom_width[ $field_level_class ] ) ? $arf_column_field_custom_width[ $field_level_class ] : '0' );
3608
3609                                        $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container{';
3610                                                $arflite_form_all_footer_css .= 'width:' . $calculte_width . '%;';
3611                                        $arflite_form_all_footer_css     .= '}';
3612                                }
3613
3614                                if ( $field['type'] == 'confirm_email' ) {
3615                                        $class = isset( $field['confirm_email_inner_classes'] ) ? $field['confirm_email_inner_classes'] : 'arf_1col';
3616                                } else {
3617                                        $class = isset( $field_opt['inner_class'] ) ? $field_opt['inner_class'] : 'arf_1col';
3618                                }
3619                                array_push( $class_array, $class );
3620
3621                                $field['value'] = isset( $field['value'] ) ? $field['value'] : '';
3622
3623                                $field['id'] = $arflitefieldhelper->arfliteget_actual_id( $field['id'] );
3624
3625                                $field_name = 'item_meta[' . $field['id'] . ']';
3626
3627                                $allowed_html = arflite_retrieve_attrs_for_wp_kses();
3628
3629                                if ( isset( $is_confirmation_method ) && ! $is_confirmation_method || ! isset( $is_confirmation_method ) ) {
3630                                        if ( isset( $_REQUEST ) && isset( $_REQUEST['item_meta'] ) && array_key_exists( intval( $field['id'] ), $_REQUEST['item_meta'] ) ) {
3631
3632                                                $arflite_requested_itemid = !empty( $_REQUEST['item_meta'][ $field['id'] ] ) ? intval($_REQUEST['item_meta'][ $field['id'] ]) : '';
3633                                                $field['set_field_value'] = wp_kses( $arflite_requested_itemid , $allowed_html );
3634                                        }
3635                                }
3636
3637                               
3638                                $field = apply_filters( 'arflitebeforefielddisplay', $field );
3639
3640                                $required_class = '';
3641                                $required_class = ( $field['required'] == '0' ) ? '' : ' arffieldrequired';
3642
3643                                if ( $field['type'] == 'confirm_email' ) {
3644                                        $required_class .= ' confirm_email_container arf_confirm_email_field_' . $field['confirm_email_field'];
3645                                }
3646
3647                                $field_name = 'item_meta[' . $field['id'] . ']';
3648
3649                                $field_description = '';
3650                                if ( isset( $field['description'] ) && $field['description'] != '' ) {
3651
3652                                        $arf_textarea_charlimit_class = '';
3653                                        if ( $field['type'] == 'textarea' && $field['field_options']['max'] > 0 ) {
3654                                                $arf_textarea_charlimit_class = 'arf_textareachar_limit';
3655                                        }
3656
3657                                        $field_description = '<div class="arf_field_description ' . $arf_textarea_charlimit_class . '">' . $field['description'] . '</div>';
3658                                }
3659
3660                                if ( isset( $field['multiple'] ) && $field['multiple'] && ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) ) {
3661                                        $field_name .= '[]';
3662                                }
3663
3664                                $field_tooltip          = '';
3665                                $field_tooltip_class    = '';
3666                                $field_standard_tooltip = '';
3667                                if ( isset( $field['tooltip_text'] ) && $field['tooltip_text'] != '' ) {
3668                                        if ( $inputStyle == 'material' ) {
3669                                                $field_tooltip = $arflitefieldhelper->arflite_tooltip_display( $field['tooltip_text'], $inputStyle );
3670                                                if ( $field['type'] == 'text' || $field['type'] == 'textarea' || $field['type'] == 'email' || $field['type'] == 'number' || $field['type'] == 'phone' || $field['type'] == 'date' || $field['type'] == 'time' || $field['type'] == 'url' || $field['type'] == 'image' ) {
3671                                                        $field_tooltip_class = ' arfhelptipfocus ';
3672                                                } else {
3673                                                        $field_tooltip_class = ' arfhelptip ';
3674                                                }
3675                                        } else {
3676                                                $field_standard_tooltip = $arflitefieldhelper->arflite_tooltip_display( $field['tooltip_text'], $inputStyle );
3677                                        }
3678                                }
3679
3680                                $error_class = isset( $arflite_errors[ 'field' . $field['id'] ] ) ? ' arfblankfield' : '';
3681
3682                                $field['label'] = ( isset( $values['label_position'] ) && $values['label_position'] != '' ) ? $values['label_position'] : '';//$arflite_style_settings->position;
3683                                $error_class   .= ' ' . $field['label'] . '_container';
3684
3685                                if ( isset( $field['classes'] ) ) {
3686
3687                                        $error_class .= ' arfformfield';
3688
3689                                        global $arflite_column_classes, $arflite_is_multi_column_loaded;
3690
3691                                        if ( $field['type'] == 'confirm_email' ) {
3692                                                $field['classes'] = $field['confirm_email_classes'];
3693                                        }
3694                                        if ( isset( $field['classes'] ) && $field['classes'] == 'arf_2' && empty( $arflite_column_classes['two'] ) ) {
3695                                                $arflite_column_classes['two'] = '1';
3696                                                $arf_classes                   = 'frm_first_half';
3697
3698                                                $arflite_column_classes['three'] = '';
3699                                                $arflite_column_classes['four']  = '';
3700                                                $arflite_column_classes['five']  = '';
3701                                                $arflite_column_classes['six']   = '';
3702
3703                                                unset( $arflite_column_classes['three'] );
3704                                                unset( $arflite_column_classes['four'] );
3705                                                unset( $arflite_column_classes['five'] );
3706                                                unset( $arflite_column_classes['six'] );
3707
3708                                                $arflite_is_multi_column_loaded[] = $form->form_key;
3709                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_2' && isset( $arflite_column_classes['two'] ) && $arflite_column_classes['two'] == '1' ) {
3710                                                $arf_classes                     = 'frm_last_half';
3711                                                $arflite_column_classes['two']   = '';
3712                                                $arflite_column_classes['three'] = '';
3713                                                $arflite_column_classes['four']  = '';
3714                                                $arflite_column_classes['five']  = '';
3715                                                $arflite_column_classes['six']   = '';
3716                                                unset( $arflite_column_classes['two'] );
3717                                                unset( $arflite_column_classes['three'] );
3718                                                unset( $arflite_column_classes['four'] );
3719                                                unset( $arflite_column_classes['five'] );
3720                                                unset( $arflite_column_classes['six'] );
3721                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_3' && empty( $arflite_column_classes['three'] ) ) {
3722                                                $arflite_column_classes['three'] = '1';
3723                                                $arf_classes                     = 'frm_first_third';
3724
3725                                                $arflite_column_classes['two']  = '';
3726                                                $arflite_column_classes['four'] = '';
3727                                                $arflite_column_classes['five'] = '';
3728                                                $arflite_column_classes['six']  = '';
3729
3730                                                unset( $arflite_column_classes['two'] );
3731                                                unset( $arflite_column_classes['four'] );
3732                                                unset( $arflite_column_classes['five'] );
3733                                                unset( $arflite_column_classes['six'] );
3734
3735                                                $arflite_is_multi_column_loaded[] = $form->form_key;
3736                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_3' && isset( $arflite_column_classes['three'] ) && $arflite_column_classes['three'] == '1' ) {
3737                                                $arflite_column_classes['three'] = '2';
3738                                                $arf_classes                     = 'frm_third';
3739
3740                                                $arflite_column_classes['two']  = '';
3741                                                $arflite_column_classes['four'] = '';
3742                                                $arflite_column_classes['five'] = '';
3743                                                $arflite_column_classes['six']  = '';
3744
3745                                                unset( $arflite_column_classes['two'] );
3746                                                unset( $arflite_column_classes['four'] );
3747                                                unset( $arflite_column_classes['five'] );
3748                                                unset( $arflite_column_classes['six'] );
3749                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_3' && isset( $arflite_column_classes['three'] ) && $arflite_column_classes['three'] == '2' ) {
3750                                                $arf_classes = 'frm_last_third';
3751
3752                                                $arflite_column_classes['two']   = '';
3753                                                $arflite_column_classes['three'] = '';
3754                                                $arflite_column_classes['four']  = '';
3755                                                $arflite_column_classes['five']  = '';
3756                                                $arflite_column_classes['six']   = '';
3757                                                unset( $arflite_column_classes['two'] );
3758                                                unset( $arflite_column_classes['three'] );
3759                                                unset( $arflite_column_classes['four'] );
3760                                                unset( $arflite_column_classes['five'] );
3761                                                unset( $arflite_column_classes['six'] );
3762                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_4' && empty( $arflite_column_classes['four'] ) ) {
3763                                                $arflite_column_classes['four'] = '1';
3764                                                $arf_classes                    = 'frm_first_fourth';
3765
3766                                                $arflite_column_classes['two']   = '';
3767                                                $arflite_column_classes['three'] = '';
3768                                                $arflite_column_classes['five']  = '';
3769                                                $arflite_column_classes['six']   = '';
3770
3771                                                unset( $arflite_column_classes['two'] );
3772                                                unset( $arflite_column_classes['three'] );
3773                                                unset( $arflite_column_classes['five'] );
3774                                                unset( $arflite_column_classes['six'] );
3775
3776                                                $arflite_is_multi_column_loaded[] = $form->form_key;
3777                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_4' && isset( $arflite_column_classes['four'] ) && $arflite_column_classes['four'] == '1' ) {
3778                                                $arflite_column_classes['four'] = '2';
3779                                                $arf_classes                    = 'frm_fourth';
3780
3781                                                $arflite_column_classes['two']   = '';
3782                                                $arflite_column_classes['three'] = '';
3783                                                $arflite_column_classes['five']  = '';
3784                                                $arflite_column_classes['six']   = '';
3785
3786                                                unset( $arflite_column_classes['two'] );
3787                                                unset( $arflite_column_classes['three'] );
3788                                                unset( $arflite_column_classes['five'] );
3789                                                unset( $arflite_column_classes['six'] );
3790                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_4' && isset( $arflite_column_classes['four'] ) && $arflite_column_classes['four'] == '2' ) {
3791                                                $arflite_column_classes['four'] = '3';
3792                                                $arf_classes                    = 'frm_fourth';
3793
3794                                                $arflite_column_classes['two']   = '';
3795                                                $arflite_column_classes['three'] = '';
3796                                                $arflite_column_classes['five']  = '';
3797                                                $arflite_column_classes['six']   = '';
3798
3799                                                unset( $arflite_column_classes['two'] );
3800                                                unset( $arflite_column_classes['three'] );
3801                                                unset( $arflite_column_classes['five'] );
3802                                                unset( $arflite_column_classes['six'] );
3803                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_4' && isset( $arflite_column_classes['four'] ) && $arflite_column_classes['four'] == '3' ) {
3804                                                $arf_classes = 'frm_last_fourth';
3805
3806                                                $arflite_column_classes['two']   = '';
3807                                                $arflite_column_classes['three'] = '';
3808                                                $arflite_column_classes['four']  = '';
3809                                                $arflite_column_classes['five']  = '';
3810                                                $arflite_column_classes['six']   = '';
3811                                                unset( $arflite_column_classes['two'] );
3812                                                unset( $arflite_column_classes['three'] );
3813                                                unset( $arflite_column_classes['four'] );
3814                                                unset( $arflite_column_classes['five'] );
3815                                                unset( $arflite_column_classes['six'] );
3816
3817                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_5' && empty( $arflite_column_classes['five'] ) ) {
3818                                                $arflite_column_classes['five'] = '1';
3819                                                $arf_classes                    = 'frm_first_fifth';
3820
3821                                                $arflite_column_classes['two']   = '';
3822                                                $arflite_column_classes['three'] = '';
3823                                                $arflite_column_classes['four']  = '';
3824                                                $arflite_column_classes['six']   = '';
3825
3826                                                unset( $arflite_column_classes['two'] );
3827                                                unset( $arflite_column_classes['three'] );
3828                                                unset( $arflite_column_classes['four'] );
3829                                                unset( $arflite_column_classes['six'] );
3830
3831                                                $arflite_is_multi_column_loaded[] = $form->form_key;
3832                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_5' && isset( $arflite_column_classes['five'] ) && $arflite_column_classes['five'] == '1' ) {
3833                                                $arflite_column_classes['five'] = '2';
3834                                                $arf_classes                    = 'frm_fifth';
3835
3836                                                $arflite_column_classes['two']   = '';
3837                                                $arflite_column_classes['three'] = '';
3838                                                $arflite_column_classes['four']  = '';
3839                                                $arflite_column_classes['six']   = '';
3840
3841                                                unset( $arflite_column_classes['two'] );
3842                                                unset( $arflite_column_classes['three'] );
3843                                                unset( $arflite_column_classes['four'] );
3844                                                unset( $arflite_column_classes['six'] );
3845                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_5' && isset( $arflite_column_classes['five'] ) && $arflite_column_classes['five'] == '2' ) {
3846                                                $arflite_column_classes['five'] = '3';
3847                                                $arf_classes                    = 'frm_fifth';
3848
3849                                                $arflite_column_classes['two']   = '';
3850                                                $arflite_column_classes['three'] = '';
3851                                                $arflite_column_classes['four']  = '';
3852                                                $arflite_column_classes['six']   = '';
3853
3854                                                unset( $arflite_column_classes['two'] );
3855                                                unset( $arflite_column_classes['three'] );
3856                                                unset( $arflite_column_classes['four'] );
3857                                                unset( $arflite_column_classes['six'] );
3858                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_5' && isset( $arflite_column_classes['five'] ) && $arflite_column_classes['five'] == '3' ) {
3859                                                $arflite_column_classes['five'] = '4';
3860                                                $arf_classes                    = 'frm_fifth';
3861
3862                                                $arflite_column_classes['two']   = '';
3863                                                $arflite_column_classes['three'] = '';
3864                                                $arflite_column_classes['four']  = '';
3865                                                $arflite_column_classes['six']   = '';
3866
3867                                                unset( $arflite_column_classes['two'] );
3868                                                unset( $arflite_column_classes['three'] );
3869                                                unset( $arflite_column_classes['four'] );
3870                                                unset( $arflite_column_classes['six'] );
3871                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_5' && isset( $arflite_column_classes['five'] ) && $arflite_column_classes['five'] == '4' ) {
3872                                                $arf_classes = 'frm_last_fifth';
3873
3874                                                $arflite_column_classes['two']   = '';
3875                                                $arflite_column_classes['three'] = '';
3876                                                $arflite_column_classes['four']  = '';
3877                                                $arflite_column_classes['five']  = '';
3878                                                $arflite_column_classes['six']   = '';
3879                                                unset( $arflite_column_classes['two'] );
3880                                                unset( $arflite_column_classes['three'] );
3881                                                unset( $arflite_column_classes['four'] );
3882                                                unset( $arflite_column_classes['five'] );
3883                                                unset( $arflite_column_classes['six'] );
3884                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && empty( $arflite_column_classes['six'] ) ) {
3885                                                $arflite_column_classes['six'] = '1';
3886                                                $arf_classes                   = 'frm_first_six';
3887
3888                                                $arflite_column_classes['two']   = '';
3889                                                $arflite_column_classes['three'] = '';
3890                                                $arflite_column_classes['four']  = '';
3891                                                $arflite_column_classes['five']  = '';
3892
3893                                                unset( $arflite_column_classes['two'] );
3894                                                unset( $arflite_column_classes['three'] );
3895                                                unset( $arflite_column_classes['four'] );
3896                                                unset( $arflite_column_classes['five'] );
3897                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '1' ) {
3898                                                $arflite_column_classes['six'] = '2';
3899                                                $arf_classes                   = 'frm_six';
3900
3901                                                $arflite_column_classes['two']   = '';
3902                                                $arflite_column_classes['three'] = '';
3903                                                $arflite_column_classes['four']  = '';
3904                                                $arflite_column_classes['five']  = '';
3905
3906                                                unset( $arflite_column_classes['two'] );
3907                                                unset( $arflite_column_classes['three'] );
3908                                                unset( $arflite_column_classes['four'] );
3909                                                unset( $arflite_column_classes['five'] );
3910                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '2' ) {
3911                                                $arflite_column_classes['six'] = '3';
3912                                                $arf_classes                   = 'frm_six';
3913
3914                                                $arflite_column_classes['two']   = '';
3915                                                $arflite_column_classes['three'] = '';
3916                                                $arflite_column_classes['four']  = '';
3917                                                $arflite_column_classes['five']  = '';
3918
3919                                                unset( $arflite_column_classes['two'] );
3920                                                unset( $arflite_column_classes['three'] );
3921                                                unset( $arflite_column_classes['four'] );
3922                                                unset( $arflite_column_classes['five'] );
3923                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '3' ) {
3924                                                $arflite_column_classes['six'] = '4';
3925                                                $arf_classes                   = 'frm_six';
3926
3927                                                $arflite_column_classes['two']   = '';
3928                                                $arflite_column_classes['three'] = '';
3929                                                $arflite_column_classes['four']  = '';
3930                                                $arflite_column_classes['five']  = '';
3931
3932                                                unset( $arflite_column_classes['two'] );
3933                                                unset( $arflite_column_classes['three'] );
3934                                                unset( $arflite_column_classes['four'] );
3935                                                unset( $arflite_column_classes['five'] );
3936                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '4' ) {
3937                                                $arflite_column_classes['six'] = '5';
3938                                                $arf_classes                   = 'frm_six';
3939
3940                                                $arflite_column_classes['two']   = '';
3941                                                $arflite_column_classes['three'] = '';
3942                                                $arflite_column_classes['four']  = '';
3943                                                $arflite_column_classes['five']  = '';
3944
3945                                                unset( $arflite_column_classes['two'] );
3946                                                unset( $arflite_column_classes['three'] );
3947                                                unset( $arflite_column_classes['four'] );
3948                                                unset( $arflite_column_classes['five'] );
3949                                        } elseif ( isset( $field['classes'] ) && $field['classes'] == 'arf_6' && isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '5' ) {
3950                                                $arflite_column_classes['six'] = '6';
3951                                                $arf_classes                   = 'frm_last_six';
3952
3953                                                $arflite_column_classes['two']   = '';
3954                                                $arflite_column_classes['three'] = '';
3955                                                $arflite_column_classes['four']  = '';
3956                                                $arflite_column_classes['five']  = '';
3957                                                $arflite_column_classes['six']   = '';
3958
3959                                                unset( $arflite_column_classes['two'] );
3960                                                unset( $arflite_column_classes['three'] );
3961                                                unset( $arflite_column_classes['four'] );
3962                                                unset( $arflite_column_classes['five'] );
3963                                                unset( $arflite_column_classes['six'] );
3964                                        } else {
3965                                                $arflite_column_classes = array();
3966                                                $arf_classes            = '';
3967                                        }
3968
3969                                        if ( isset( $arflite_column_classes['six'] ) && $arflite_column_classes['six'] == '6' ) {
3970                                                $arflite_column_classes['six'] = '';
3971                                                unset( $arflite_column_classes['six'] );
3972                                        }
3973                                        if ( isset( $arflite_column_classes['five'] ) && $arflite_column_classes['five'] == '5' ) {
3974                                                $arflite_column_classes['five'] = '';
3975                                                unset( $arflite_column_classes['five'] );
3976                                        }
3977                                        if ( isset( $arflite_column_classes['four'] ) && $arflite_column_classes['four'] == '4' ) {
3978                                                $arflite_column_classes['four'] = '';
3979                                                unset( $arflite_column_classes['four'] );
3980                                        }
3981                                        if ( isset( $arflite_column_classes['three'] ) && $arflite_column_classes['three'] == '3' ) {
3982                                                $arflite_column_classes['three'] = '';
3983                                                unset( $arflite_column_classes['three'] );
3984                                        }
3985                                        if ( isset( $arflite_column_classes['two'] ) && $arflite_column_classes['two'] == '2' ) {
3986                                                $arflite_column_classes['two'] = '';
3987                                                unset( $arflite_column_classes['two'] );
3988                                        }
3989
3990                                        if ( $class == 'arf21colclass' ) {
3991                                                 $arf_classes = 'frm_first_half';
3992                                        } elseif ( $class == 'arf_2col' ) {
3993                                                 $arf_classes = 'frm_last_half';
3994                                        }
3995
3996                                        if ( $class == 'arf31colclass' ) {
3997                                                $arf_classes = 'frm_first_third';
3998                                        } elseif ( $class == 'arf_23col' ) {
3999                                                $arf_classes = 'frm_third';
4000                                        } elseif ( $class == 'arf_3col' ) {
4001                                                $arf_classes = 'frm_last_third';
4002                                        } elseif ( $class == 'arf41colclass' ) {
4003                                                $arf_classes = 'frm_first_fourth';
4004                                        } elseif ( $class == 'arf42colclass' || $class == 'arf43colclass' ) {
4005                                                $arf_classes = 'frm_fourth';
4006                                        } elseif ( $class == 'arf_4col' ) {
4007                                                $arf_classes = 'frm_last_fourth';
4008                                        } elseif ( $class == 'arf51colclass' ) {
4009                                                $arf_classes = 'frm_first_fifth';
4010                                        } elseif ( $class == 'arf52colclass' || $class == 'arf53colclass' || $class == 'arf54colclass' ) {
4011                                                $arf_classes = 'frm_fifth';
4012                                        } elseif ( $class == 'arf_5col' ) {
4013                                                $arf_classes = 'frm_last_fifth';
4014                                        } elseif ( $class == 'arf61colclass' ) {
4015                                                $arf_classes = 'frm_first_six';
4016                                        } elseif ( $class == 'arf62colclass' || $class == 'arf63colclass' || $class == 'arf64colclass' || $class == 'arf65colclass' ) {
4017                                                $arf_classes = 'frm_six';
4018                                        } elseif ( $class == 'arf_6col' ) {
4019                                                $arf_classes = 'frm_last_six';
4020                                        }
4021                                        $arf_classes  = isset( $arf_classes ) ? $arf_classes : '';
4022                                        $error_class .= ' ' . $arf_classes;
4023                                }
4024                                $prefix = $suffix = '';
4025                                if ( $inputStyle != 'material' ) {
4026                                        $prefix = $this->arflite_prefix_suffix( 'prefix', $field );
4027                                        $suffix = $this->arflite_prefix_suffix( 'suffix', $field );
4028                                }
4029
4030                                $arf_required = '';
4031                                if ( $field['required'] ) {
4032                                        $field['required_indicator'] = ( isset( $field['required_indicator'] ) && ( $field['required_indicator'] != '' ) ) ? $field['required_indicator'] : '*';
4033                                        $arf_required                = '<span class="arfcheckrequiredfield">' . $field['required_indicator'] . '</span>';
4034                                }
4035
4036                                $arf_main_label_cls = $this->arflite_label_top_position( $newarr['font_size'] );
4037
4038                                $arf_main_label = '';
4039
4040                                if ( $field['type'] == 'select' && $inputStyle == 'material' ) {
4041                                        $arf_main_label_cls .= ' selectpicker_active ';
4042                                }
4043
4044                                if ( $field['type'] == 'phone' && isset( $field['phonetype'] ) && $field['phonetype'] == 1 ) {
4045                                        $arf_main_label_cls .= ' arf_phone_label_cls ';
4046                                }
4047                                $arf_material_standard_cls = '';
4048                                if ( $field['name'] != '' ) {
4049
4050                                        $arf_label_for_attribute = 'for="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '"';
4051
4052                                        $arf_main_label .= '<label data-type="' . $field['type'] . '" ' . $arf_label_for_attribute . ' class="arf_main_label ' . $arf_main_label_cls . '">' . $field['name'];
4053                                        $arf_main_label .= $arf_required;
4054                                        $arf_main_label .= '</label>';
4055                                } else {
4056                                        $arf_material_standard_cls = ' arf_material_theme_display ';
4057                                }
4058
4059                                if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
4060                                        $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls{';
4061                                                $arflite_form_all_footer_css .= 'width:' . $field['field_width'] . 'px;';
4062                                        $arflite_form_all_footer_css     .= '}';
4063                                        if ( isset( $field['enable_arf_prefix'] ) && $field['enable_arf_prefix'] != 1 && isset( $field['enable_arf_suffix'] ) && $field['enable_arf_suffix'] != 1 ) {
4064                                                $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input{';
4065                                                        $arflite_form_all_footer_css .= 'width:' . $field['field_width'] . 'px;';
4066                                                $arflite_form_all_footer_css     .= '}';
4067                                        }
4068
4069                                        if ( 'textarea' == $field['type'] ) {
4070                                                $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls textarea{';
4071                                                        $arflite_form_all_footer_css .= 'width:' . $field['field_width'] . 'px !important;';
4072                                                $arflite_form_all_footer_css     .= '}';
4073                                        }
4074                                }
4075
4076                                $arf_input_field_html  = '';
4077                                $arf_input_field_html .= $arflitefieldcontroller->arflite_input_fieldhtml( $field, false );
4078                                $arf_input_field_html .= $arflitefieldcontroller->arflite_input_html( $field, false );
4079
4080                                $frm_opt = maybe_unserialize( $form_data->options );
4081
4082                                $required_class .= " arf_field_type_{$field['type']} ";
4083
4084                                if ( ! isset( $field['default_value'] ) ) {
4085                                        $field['default_value'] = isset( $field['field_options']['default_value'] ) ? $field['field_options']['default_value'] : '';
4086                                }
4087                                $parent_field_id = ! empty( $field['parent_field'] ) ? $field['parent_field'] : 0;
4088
4089                                switch ( $field['type'] ) {
4090                                        case 'text':
4091                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . '' . $error_class . ' arf_field_' . $field['id'] . '" data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '" >';
4092                                                if ( $inputStyle != 'material' ) {
4093                                                        $return_string .= $arf_main_label;
4094                                                }
4095                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
4096
4097                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
4098                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
4099                                                } else {
4100                                                        $return_string .= $prefix;
4101
4102                                                        $arf_single_custom_validation     = isset( $field['single_custom_validation'] ) ? $field['single_custom_validation'] : 'custom_validation_none';
4103                                                        $arf_custom_validation_expression = '';
4104                                                        if ( $arf_single_custom_validation == 'custom_validation_none' ) {
4105                                                                $arf_custom_validation_expression = '';
4106                                                        } elseif ( $arf_single_custom_validation == 'custom_validation_alpha' ) {
4107                                                                $arf_custom_validation_expression = '^[a-zA-Z\s]*$';
4108                                                        } elseif ( $arf_single_custom_validation == 'custom_validation_number' ) {
4109                                                                $arf_custom_validation_expression = '^[0-9]*$';
4110                                                        } elseif ( $arf_single_custom_validation == 'custom_validation_alphanumber' ) {
4111                                                                $arf_custom_validation_expression = '^[a-zA-Z0-9\s]*$';
4112                                                        } elseif ( $arf_single_custom_validation == 'custom_validation_regex' ) {
4113                                                                $arf_custom_validation_expression = isset( $field['arf_regular_expression'] ) ? $field['arf_regular_expression'] : '';
4114                                                        }
4115
4116                                                        $arf_regular_expression = ( isset( $field['single_custom_validation'] ) && $arf_custom_validation_expression != '' ) ? 'data-validation-regex-regex="' . esc_attr( $arf_custom_validation_expression ) . '"  data-validation-regex-message="' . esc_attr( $field['arf_regular_expression_msg'] ) . '"' : '';
4117
4118                                                        if ( 'material' == $inputStyle ) {
4119                                                                $material_standard_cls = '';
4120                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
4121                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
4122                                                                }
4123                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
4124                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
4125                                                                }
4126                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
4127                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
4128                                                                }
4129                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
4130                                                                        $material_standard_cls .= ' arf_both_icons ';
4131                                                                }
4132                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
4133
4134                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
4135                                                        }
4136
4137                                                        $return_string .= '<input ' . $arf_regular_expression . '  type="text" id="field_' . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . '" ';
4138                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
4139                                                                $return_string .= 'readonly="readonly" ';
4140                                                        }
4141                                                        $return_string .= 'name="' . esc_attr( $field_name ) . '" ';
4142
4143                                                        $return_string .= $arf_input_field_html;
4144
4145                                                        $default_value = isset( $field['default_value'] ) ? $field['default_value'] : '';
4146
4147                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4148
4149                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
4150                                                        }
4151
4152                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
4153                                                                $default_value = $field['set_field_value'];
4154                                                        }
4155
4156                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
4157
4158                                                        if ( $default_value != '' ) {
4159                                                                $return_string .= ' value="' . esc_attr( $default_value ) . '" ';
4160                                                        }
4161
4162                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
4163                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
4164                                                        }
4165
4166                                                        if ( isset( $field['clear_on_focus'] ) && $field['clear_on_focus'] ) {
4167                                                                $return_string .= ' onfocus="arflitecleardedaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
4168                                                                $return_string .= ' onblur="arflitereplacededaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
4169                                                        }
4170
4171                                                        if ( isset( $field['field_width'] ) and $field['field_width'] != '' and $field['enable_arf_prefix'] != 1 and $field['enable_arf_suffix'] != 1 ) {
4172                                                                $return_string .= ' style="width:' . $field['field_width'] . 'px !important;"';
4173                                                        }
4174
4175                                                        if ( isset( $field['required'] ) && $field['required'] ) {
4176                                                                $return_string .= ' data-validation-required-message="' . esc_html( $field['blank'] ) . '" ';
4177                                                        }
4178                                                        if ( isset($field['minlength']) && ($field['minlength'] != '' && 0 < $field['minlength']) ) {
4179                                                                $return_string .= 'minlength="' . $field['minlength'] . '" data-validation-minlength-message="' . esc_attr( $field['minlength_message'] ) . '"';
4180                                                        }
4181                                                        $return_string .= '  />';
4182
4183                                                        if ( 'material' == $inputStyle ) {
4184                                                                $return_string         .= '<div class="arf_material_standard">';
4185                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
4186                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
4187                                                                                $return_string .= $arf_main_label;
4188                                                                        $return_string     .= '</div>';
4189                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
4190                                                                $return_string         .= '</div>';
4191                                                                $return_string         .= '</div>';
4192                                                        }
4193
4194                                                        $return_string .= $suffix;
4195                                                        $return_string .= $field_standard_tooltip;
4196                                                        $return_string .= $field_description;
4197                                                }
4198                                                $return_string .= '</div>';
4199                                                $return_string .= '</div>';
4200                                                break;
4201
4202                                        case 'textarea':
4203                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . '' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
4204                                                if ( $inputStyle != 'material' ) {
4205                                                        $return_string .= $arf_main_label;
4206                                                }
4207                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
4208
4209                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
4210
4211                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
4212                                                } else {
4213
4214                                                        $arf_text_is_countable = ( ( isset($field['field_options']['max']) && $field['field_options']['max'] > 0) ) ? 'arf_text_is_countable' : '';
4215
4216                                                        if ( 'material' == $inputStyle ) {
4217                                                                $material_standard_cls = '';
4218                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
4219                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
4220                                                                }
4221                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
4222                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
4223                                                                }
4224                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
4225                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
4226                                                                }
4227                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
4228                                                                        $material_standard_cls .= ' arf_both_icons ';
4229                                                                }
4230                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
4231
4232                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
4233                                                        }
4234
4235                                                        $return_string .= '<textarea name="' . $field_name . '" id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '" ';
4236                                                        if ( isset( $field['max_rows'] ) && $field['max_rows'] ) {
4237                                                                $return_string .= ' rows="' . $field['max_rows'] . '" ';
4238                                                        }
4239                                                        $return_string .= $arf_input_field_html;
4240
4241                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
4242                                                                $return_string .= 'readonly="readonly" ';
4243                                                        }
4244
4245                                                        $default_value = $field['default_value'];
4246                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4247
4248                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
4249                                                        }
4250
4251                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
4252
4253                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
4254                                                                $default_value = $field['set_field_value'];
4255                                                        }
4256
4257                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
4258                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
4259                                                        }
4260
4261                                                        if ( isset( $field['clear_on_focus'] ) && $field['clear_on_focus'] ) {
4262                                                                $return_string .= ' onfocus="arflitecleardedaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
4263                                                                $return_string .= ' onblur="arflitereplacededaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
4264                                                        }
4265
4266                                                        if ( isset( $field['field_width'] ) and $field['field_width'] != '' ) {
4267                                                                $return_string .= ' style="width:' . $field['field_width'] . 'px !important;"';
4268                                                        }
4269
4270                                                        if ( isset( $field['required'] ) and $field['required'] ) {
4271                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '" ';
4272                                                        }
4273
4274                                                        if ( ( isset($field['max']) && $field['max'] != '') && 0 < $field['max'] ) {
4275                                                                $return_string .= ' maxlength="' . $field['max'] . '" data-validation-maxlength-message="' . __( 'Invalid maximum characters length', 'arforms-form-builder' ) . '" ';
4276                                                        }
4277
4278                                                        if ( ( isset( $field['minlength']) && $field['minlength'] != '') && 0 < $field['minlength'] ) {
4279                                                                $return_string .= ' minlength="' . $field['minlength'] . '" data-validation-minlength-message="' . esc_attr( $field['minlength_message'] ) . '" ';
4280                                                        }
4281
4282                                                        $return_string .= ' >';
4283                                                        if ( $default_value != '' ) {
4284                                                                $return_string .= $default_value;
4285                                                        }
4286
4287                                                        $return_string .= '</textarea>';
4288
4289                                                        if ( 'material' == $inputStyle ) {
4290                                                                $return_string         .= '<div class="arf_material_standard">';
4291                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
4292                                                                          $return_string   .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
4293                                                                                $return_string .= $arf_main_label;
4294                                                                        $return_string     .= '</div>';
4295                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
4296                                                                $return_string         .= '</div>';
4297                                                                $return_string         .= '</div>';
4298                                                        }
4299
4300                                                        $number_of_allowed_char = ( isset( $field['field_options']['max'] ) && $field['field_options']['max'] != '' ) ? $field['field_options']['max'] : '';
4301
4302                                                        if ( $number_of_allowed_char != '' ) {
4303
4304                                                                $number_of_default_value = '0';
4305
4306                                                                if ( $default_value != '' ) {
4307                                                                        $count_default_value     = strlen( $default_value );
4308                                                                        $number_of_default_value = ( isset( $count_default_value ) && $count_default_value > 0 ) ? $count_default_value : '0';
4309                                                                }
4310
4311                                                                        $return_string .= '<div class="arfcount_text_char_div"><span class="arftextarea_char_count">' . $number_of_default_value . '</span> / ' . $number_of_allowed_char . '</div>';
4312
4313                                                        }
4314
4315                                                        $return_string .= $field_standard_tooltip;
4316                                                        $return_string .= $field_description;
4317                                                }
4318                                                $return_string .= '</div>';
4319                                                $return_string .= '</div>';
4320                                                break;
4321                                        case 'checkbox':
4322                                                if ( $inputStyle == 'material' ) {
4323                                                        $alignment_class = ( isset( $field['align'] ) && $field['align'] == 'block' ) ? ' arf_vertical_radio' : ' arf_horizontal_radio';
4324                                                        $return_string  .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $alignment_class . ' ' . $required_class . ' ' . $error_class . ' ' . $class_position . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
4325                                                        $return_string  .= $arf_main_label;
4326
4327                                                        $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input{';
4328                                                                $arflite_form_all_footer_css .= 'padding-top: 5px;';
4329                                                        $arflite_form_all_footer_css     .= '}';
4330
4331                                                        $checked_values = '';
4332
4333                                                        if ( $arflite_preview ) {
4334                                                                if ( ! is_array( $field['field_options'] ) ) {
4335                                                                        $field['field_options'] = json_decode( $field['field_options'], true );
4336                                                                }
4337                                                                if ( isset( $field['field_options']['default_value'] ) && ! empty( $field['field_options']['default_value'] ) ) {
4338                                                                        $checked_values = $field['field_options']['default_value'];
4339                                                                }
4340
4341                                                                if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4342
4343                                                                        if ( is_array( $checked_values ) ) {
4344                                                                                array_push( $checked_values, $arf_arr_preset_data[ $field['id'] ] );
4345                                                                        } else {
4346
4347                                                                                $checked_values = array( $arf_arr_preset_data[ $field['id'] ] );
4348                                                                        }
4349                                                                }
4350                                                        } else {
4351
4352                                                                if ( isset( $field['default_value'] ) && ! empty( $field['default_value'] ) ) {
4353                                                                        $checked_values = $field['default_value'];
4354                                                                }
4355                                                                if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4356
4357                                                                        if ( is_array( $checked_values ) ) {
4358                                                                                array_push( $checked_values, $arf_arr_preset_data[ $field['id'] ] );
4359                                                                        } else {
4360                                                                                        $checked_values = array( $arf_arr_preset_data[ $field['id'] ] );
4361                                                                        }
4362                                                                }
4363                                                        }
4364
4365                                                        if ( isset( $field['set_field_value'] ) ) {
4366                                                                if ( is_array( $checked_values ) ) {
4367                                                                        if ( is_array( $field['set_field_value'] ) ) {
4368                                                                                $checked_values = array_unique( array_merge( $checked_values, $field['set_field_value'] ) );
4369                                                                        } else {
4370                                                                                array_push( $checked_values, $field['set_field_value'] );
4371                                                                        }
4372                                                                } else {
4373                                                                        $checked_values = array( $field['set_field_value'] );
4374                                                                }
4375                                                                if ( is_array( $checked_values ) ) {
4376                                                                        array_unique( $checked_values );
4377                                                                }
4378                                                        }
4379
4380                                                        if ( ! is_array( $checked_values ) ) {
4381                                                                $checked_values = array( $checked_values );
4382                                                        }
4383
4384                                                        $requested_checked_values = '';
4385                                                        if ( isset( $_REQUEST['checkbox_radio_style_requested'] ) ) {
4386                                                                $requested_checked_values = sanitize_text_field( $_REQUEST['checkbox_radio_style_requested'] );
4387                                                        }
4388
4389                                                        if ( $field['options'] ) {
4390                                                                $checkbox_class      = 'arf_material_checkbox';
4391                                                                $use_custom_checkbox = false;
4392                                                                if ( $form->form_css['arfcheckradiostyle'] == 'custom' ) {
4393                                                                        $checkbox_class      = 'arf_custom_checkbox';
4394                                                                        $use_custom_checkbox = true;
4395                                                                } elseif ( $form->form_css['arfcheckradiostyle'] == 'material' ) {
4396                                                                        $checkbox_class .= ' arf_default_material ';
4397                                                                } else {
4398                                                                        $checkbox_class .= ' arf_advanced_material ';
4399                                                                }
4400                                                                $return_string .= '<div class="setting_checkbox controls ' . $field_tooltip_class . ' ' . $checkbox_class . '" ' . $field_tooltip . '>';
4401                                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
4402
4403                                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
4404                                                                } else {
4405
4406                                                                        $field['options'] = $arflitefieldhelper->arflitechangeoptionorder( $field );
4407                                                                        $k                = 0;
4408
4409                                                                        $arf_chk_counter = 1;
4410
4411                                                                        if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
4412                                                                                $return_string .= '<div class="arf_chk_radio_col_two">';
4413                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
4414                                                                                $return_string .= '<div class="arf_chk_radio_col_thiree">';
4415                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
4416                                                                                $return_string .= '<div class="arf_chk_radio_col_four">';
4417                                                                        }
4418
4419                                                                        $chk_icon = '';
4420                                                                        if ( isset( $field['arflite_check_icon'] ) && $field['arflite_check_icon'] != '' ) {
4421                                                                                $chk_icon = $field['arflite_check_icon'];
4422                                                                        } else {
4423                                                                                $chk_icon = 'fas fa-check';
4424                                                                        }
4425
4426                                                                        $image_size = '';
4427                                                                        if ( isset( $field['image_width'] ) && $field['image_width'] != '' ) {
4428                                                                                $image_size = $field['image_width'];
4429                                                                        } else {
4430                                                                                $add_image_width = 'fixed';
4431                                                                                $image_size      = 120;
4432                                                                        }
4433
4434                                                                        foreach ( $field['options'] as $opt_key => $opt ) {
4435                                                                                $label_image = '';
4436                                                                                if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
4437                                                                                        continue;
4438                                                                                }
4439
4440                                                                                $field_val = apply_filters( 'arflitedisplaysavedfieldvalue', $opt, $opt_key, $field );
4441
4442                                                                                $opt = apply_filters( 'arflite_show_field_label', $opt, $opt_key, $field );
4443
4444                                                                                if ( is_array( $opt ) ) {
4445                                                                                        $label_image = isset( $opt['label_image'] ) ? $opt['label_image'] : '';
4446                                                                                        $opt         = $opt['label'];
4447                                                                                        $field_val   = ( isset( $field['separate_value'] ) ) ? $field_val['value'] : $opt;
4448                                                                                }
4449
4450                                                                                $arf_radion_image_class = '';
4451                                                                                if ( $field['use_image'] == 1 && $label_image != '' ) {
4452                                                                                        $arf_radion_image_class = 'arf_enable_checkbox_image';
4453                                                                                }
4454
4455                                                                                $checked     = '';
4456                                                                                $checked_cls = '';
4457                                                                                if ( is_array( $checked_values ) ) {
4458                                                                                        foreach ( $checked_values as $as_val ) {
4459                                                                                                $is_checkbox_checked = false;
4460                                                                                                if ( $as_val != '' || $field_val != '' ) {
4461                                                                                                        if ( is_array( $as_val ) ) {
4462                                                                                                                if ( in_array( $field_val, $as_val ) ) {
4463                                                                                                                        $is_checkbox_checked = true;
4464                                                                                                                        $checked             = ' checked="checked"';
4465                                                                                                                        $checked_cls         = ' arf_checked_checkbox ';
4466                                                                                                                }
4467                                                                                                        } else {
4468                                                                                                                if ( trim( esc_attr( $as_val ) ) === trim( esc_attr( $field_val ) ) ) {
4469                                                                                                                        $is_checkbox_checked = true;
4470                                                                                                                        $checked             = ' checked="checked"';
4471                                                                                                                        $checked_cls         = ' arf_checked_checkbox ';
4472                                                                                                                }
4473                                                                                                        }
4474                                                                                                }
4475                                                                                        }
4476                                                                                }
4477
4478                                                                                $return_string .= '<div class="arf_checkbox_style ' . $arf_radion_image_class . '" id="frm_checkbox_' . $field['id'] . '-' . $opt_key . '">';
4479                                                                                if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
4480                                                                                        $_REQUEST['arfaction'] = ( isset( $_REQUEST['arfaction'] ) ) ? sanitize_text_field( $_REQUEST['arfaction'] ) : '';
4481
4482                                                                                        $return_string .= "<div class='arf_checkbox_input_wrapper'>";
4483                                                                                        $return_string .= '<input type="checkbox" name="' . $field_name . '[]" data-type="checkbox" id="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" value="' . esc_attr( $field_val ) . '" ' . $checked . ' ';
4484
4485                                                                                        $return_string .= $arf_input_field_html;
4486                                                                                        if ( $k == 0 ) {
4487                                                                                                if ( isset( $field['required'] ) && $field['required'] ) {
4488                                                                                                        if ( isset( $field['min_opt_sel'] ) && $field['min_opt_sel'] != '' && $field['min_opt_sel'] > 0 ) {
4489                                                                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '" ';
4490                                                                                                        } else {
4491                                                                                                                $return_string .= 'data-validation-minchecked-minchecked="1" data-validation-minchecked-message="' . esc_attr( $field['blank'] ) . '"';
4492                                                                                                        }
4493                                                                                                }
4494                                                                                        }
4495                                                                                        if ( isset( $field['max_opt_sel'] ) && $field['max_opt_sel'] != '' && $field['max_opt_sel'] > 0 ) {
4496                                                                                                if ( $field['max_opt_sel'] > count( $field['options'] ) ) {
4497                                                                                                        $return_string .= 'data-validation-maxchecked-maxchecked="' . count( $field['options'] ) . '" data-validation-maxchecked-message="' . esc_attr( $field['max_opt_sel_msg'] ) . '"';
4498                                                                                                } else {
4499                                                                                                        $return_string .= 'data-validation-maxchecked-maxchecked="' . $field['max_opt_sel'] . '" data-validation-maxchecked-message="' . esc_attr( $field['max_opt_sel_msg'] ) . '"';
4500                                                                                                }
4501                                                                                        }
4502
4503                                                                                        if ( isset( $field['min_opt_sel'] ) && $field['min_opt_sel'] != '' && $field['min_opt_sel'] > 0 ) {
4504
4505                                                                                                if ( $field['min_opt_sel'] < count( $field['options'] ) ) {
4506
4507                                                                                                         $return_string .= 'data-validation-minchecked-minchecked="' . $field['min_opt_sel'] . '"  data-validation-minchecked-message="' . esc_attr( $field['min_opt_sel_msg'] ) . '"';
4508
4509                                                                                                } else {
4510                                                                                                        $return_string .= 'data-validation-minchecked-minchecked="' . count( $field['options'] ) . '" data-validation-minchecked-message="' . esc_attr( $field['min_opt_sel_msg'] ) . '"';
4511                                                                                                }
4512                                                                                        }
4513
4514                                                                                        $return_string .= ' />';
4515                                                                                        $return_string .= '<span>';
4516                                                                                        if ( $use_custom_checkbox == true ) {
4517                                                                                                $custom_checkbox = $form->form_css['arf_checked_checkbox_icon'];
4518                                                                                                $return_string  .= "<i class='{$custom_checkbox}'></i>";
4519                                                                                        }
4520                                                                                        $return_string .= '</span>';
4521                                                                                        $return_string .= '</div>';
4522                                                                                        $return_string .= '<label data-type="checkbox" for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" >';
4523                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
4524                                                                                                $temp_check = '';
4525
4526                                                                                                if ( $is_checkbox_checked ) {
4527                                                                                                        $temp_check = 'checked';
4528
4529                                                                                                }
4530
4531                                                                                                if ( $inputStyle == 'material' ) {
4532                                                                                                        $return_string          .= '<label for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="arf_checkbox_label_image ' . $temp_check . ' ' . $chk_icon . ' ">';
4533                                                                                                        $return_string          .= '<svg role"none" style="max-width:100%; width:' . $image_size . 'px; height:' . $image_size . 'px">';
4534                                                                                                                $return_string      .= '<mask id="clip-cutoff_field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '">';
4535                                                                                                                        $return_string  .= '<rect fill="white" x="0" y="0" rx="8" ry="8" width="' . $image_size . 'px" height="' . $image_size . 'px"></rect>';
4536                                                                                                                         $return_string .= '<rect fill="black" rx="4" ry="4" width="27" height="27" class="rect-cutoff"></rect>';
4537                                                                                                                $return_string      .= '</mask>';
4538                                                                                                                $return_string      .= '<g mask="url(#clip-cutoff_field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . ')">';
4539                                                                                                                        $return_string  .= '<image x="0" y="0" height="' . $image_size . 'px" preserveAspectRatio="xMidYMid slice" width="' . $image_size . 'px" href="' . esc_attr( $label_image ) . '"></image>';
4540                                                                                                                        $return_string  .= '<rect fill="none"x="0" y="0" rx="8" ry="8" width="' . $image_size . 'px" height="' . $image_size . 'px" class="img_stroke"></rect>';
4541                                                                                                                $return_string      .= '</g>';
4542                                                                                                        $return_string          .= '</svg>';
4543                                                                                                        $return_string          .= '</label>';
4544                                                                                                } else {
4545
4546                                                                                                        $return_string     .= '<span data-fid="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '"   class="arf_checkbox_label_image ' . $temp_check . ' ' . $chk_icon . ' ">';
4547                                                                                                                $return_string .= '<img src=' . esc_attr( $label_image ) . ' style="width:' . $image_size . 'px; height:' . $image_size . 'px; max-width:100%;">';
4548                                                                                                                $return_string .= '</span>';
4549                                                                                                }
4550                                                                                                $return_string .= '<span class="arf_checkbox_label" style="width:' . $image_size . 'px">';
4551                                                                                        }
4552
4553                                                                                        $return_string .= html_entity_decode( $opt );
4554                                                                                        $return_string .= '</label>';
4555
4556                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
4557                                                                                                $is_checkbox_img_enable = true;
4558                                                                                                $return_string         .= '</span>';
4559                                                                                        }
4560                                                                                }
4561                                                                                $return_string .= '</div>';
4562
4563                                                                                if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
4564                                                                                        if ( $arf_chk_counter % 2 == 0 ) {
4565                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_two">';
4566                                                                                        }
4567                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
4568                                                                                        if ( $arf_chk_counter % 3 == 0 ) {
4569                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_thiree">';
4570                                                                                        }
4571                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
4572                                                                                        if ( $arf_chk_counter % 4 == 0 ) {
4573                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_four">';
4574                                                                                        }
4575                                                                                }
4576                                                                                $k++;
4577                                                                                $arf_chk_counter++;
4578                                                                        }
4579
4580                                                                        if ( isset( $field['align'] ) && ( $field['align'] == 'arf_col_2' || $field['align'] == 'arf_col_3' || $field['align'] == 'arf_col_4' ) ) {
4581                                                                                $return_string .= '</div>';
4582                                                                        }
4583                                                                }
4584                                                                $return_string .= $field_standard_tooltip;
4585                                                                $return_string .= $field_description;
4586                                                                $return_string .= '</div>';
4587                                                        }
4588                                                        $return_string .= '</div>';
4589                                                } else {
4590                                                        $alignment_class = ( isset( $field['align'] ) && $field['align'] == 'block' ) ? ' arf_vertical_radio' : ' arf_horizontal_radio';
4591                                                        $return_string  .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $alignment_class . ' ' . $required_class . '  ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
4592                                                        $return_string  .= $arf_main_label;
4593
4594                                                        $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input{';
4595                                                                $arflite_form_all_footer_css .= 'padding-top:5px;';
4596                                                        $arflite_form_all_footer_css     .= '}';
4597
4598                                                        $checked_values = '';
4599
4600                                                        if ( $arflite_preview ) {
4601                                                                if ( isset( $field['field_options']['default_value'] ) && ! empty( $field['field_options']['default_value'] ) ) {
4602                                                                        $checked_values = $field['field_options']['default_value'];
4603                                                                }
4604
4605                                                                if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4606
4607                                                                        if ( is_array( $checked_values ) ) {
4608                                                                                array_push( $checked_values, $arf_arr_preset_data[ $field['id'] ] );
4609                                                                        } else {
4610                                                                                $checked_values = array( $arf_arr_preset_data[ $field['id'] ] );
4611                                                                        }
4612                                                                }
4613                                                        } else {
4614                                                                if ( isset( $field['default_value'] ) && ! empty( $field['default_value'] ) ) {
4615                                                                        $checked_values = $field['default_value'];
4616                                                                }
4617
4618                                                                if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
4619
4620                                                                        if ( is_array( $checked_values ) ) {
4621                                                                                array_push( $checked_values, $arf_arr_preset_data[ $field['id'] ] );
4622                                                                        } else {
4623                                                                                $checked_values = array( $arf_arr_preset_data[ $field['id'] ] );
4624                                                                        }
4625                                                                }
4626                                                        }
4627
4628                                                        if ( isset( $field['set_field_value'] ) ) {
4629                                                                if ( is_array( $checked_values ) ) {
4630                                                                        array_push( $checked_values, $field['set_field_value'] );
4631                                                                } else {
4632                                                                        $checked_values = array( $field['set_field_value'] );
4633                                                                }
4634                                                                if ( is_array( $checked_values ) ) {
4635                                                                        array_unique( $checked_values );
4636                                                                }
4637                                                        }
4638
4639                                                        if ( ! is_array( $checked_values ) ) {
4640                                                                $checked_values = array( $checked_values );
4641                                                        }
4642
4643                                                        $requested_checked_values = '';
4644                                                        if ( isset( $_REQUEST['checkbox_radio_style_requested'] ) ) {
4645                                                                $requested_checked_values = sanitize_text_field( $_REQUEST['checkbox_radio_style_requested'] );
4646                                                        }
4647
4648                                                        if ( $field['options'] ) {
4649                                                                $checkbox_class      = 'arf_standard_checkbox';
4650                                                                $use_custom_checkbox = false;
4651                                                                if ( $form->form_css['arfcheckradiostyle'] == 'custom' ) {
4652                                                                        $checkbox_class      = 'arf_custom_checkbox';
4653                                                                        $use_custom_checkbox = true;
4654                                                                }
4655                                                                if ( $form->form_css['arfinputstyle'] == 'rounded' && $form->form_css['arfcheckradiostyle'] != 'custom' ) {
4656                                                                        $checkbox_class      = 'arf_rounded_flat_checkbox';
4657                                                                        $use_custom_checkbox = false;
4658                                                                }
4659                                                                if ( $form->form_css['arfinputstyle'] == 'rounded' && $form->form_css['arfcheckradiostyle'] == 'custom' ) {
4660                                                                        $checkbox_class      = 'arf_rounded_flat_checkbox arf_custom_checkbox';
4661                                                                        $use_custom_checkbox = true;
4662                                                                }
4663                                                                $return_string .= '<div class="setting_checkbox controls ' . $checkbox_class . '" >';
4664                                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
4665
4666                                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
4667                                                                } else {
4668
4669                                                                        $field['options'] = $arflitefieldhelper->arflitechangeoptionorder( $field );
4670                                                                        $k                = 0;
4671
4672                                                                        $arf_chk_counter = 1;
4673
4674                                                                        if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
4675                                                                                $return_string .= '<div class="arf_chk_radio_col_two">';
4676                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
4677                                                                                $return_string .= '<div class="arf_chk_radio_col_thiree">';
4678                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
4679                                                                                $return_string .= '<div class="arf_chk_radio_col_four">';
4680                                                                        }
4681
4682                                                                         $chk_icon = '';
4683                                                                        if ( isset( $field['arflite_check_icon'] ) && $field['arflite_check_icon'] != '' ) {
4684                                                                                $chk_icon = $field['arflite_check_icon'];
4685                                                                        } else {
4686                                                                                $chk_icon = 'fas fa-check';
4687                                                                        }
4688
4689                                                                        $image_size = '';
4690                                                                        if ( isset( $field['image_width'] ) && $field['image_width'] != '' ) {
4691                                                                                $image_size = $field['image_width'];
4692                                                                        } else {
4693                                                                                $add_image_width = 'fixed';
4694                                                                                $image_size      = 120;
4695                                                                        }
4696
4697                                                                        foreach ( $field['options'] as $opt_key => $opt ) {
4698                                                                                $label_image = '';
4699                                                                                if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
4700                                                                                        continue;
4701                                                                                }
4702
4703                                                                                $field_val = apply_filters( 'arflitedisplaysavedfieldvalue', $opt, $opt_key, $field );
4704
4705                                                                                $opt = apply_filters( 'arflite_show_field_label', $opt, $opt_key, $field );
4706
4707                                                                                if ( is_array( $opt ) ) {
4708                                                                                        $label_image = isset( $opt['label_image'] ) ? $opt['label_image'] : '';
4709                                                                                        $opt         = $opt['label'];
4710                                                                                        $field_val   = ( isset( $field['separate_value'] ) ) ? $field_val['value'] : $opt;
4711                                                                                }
4712
4713                                                                                $arf_radion_image_class = '';
4714                                                                                if ( $field['use_image'] == 1 && $label_image != '' ) {
4715                                                                                        $is_checkbox_img_enable = true;
4716                                                                                        $arf_radion_image_class = 'arf_enable_checkbox_image';
4717                                                                                }
4718
4719                                                                                $checked = '';
4720
4721                                                                                if ( is_array( $checked_values ) ) {
4722                                                                                        foreach ( $checked_values as $as_val ) {
4723                                                                                                $is_checkbox_checked = false;
4724                                                                                                if ( $as_val != '' || $field_val != '' ) {
4725                                                                                                        if ( is_array( $as_val ) ) {
4726                                                                                                                if ( in_array( $field_val, $as_val ) ) {
4727                                                                                                                        $is_checkbox_checked = true;
4728                                                                                                                        $checked             = ' checked="checked"';
4729                                                                                                                }
4730                                                                                                        } else {
4731                                                                                                                if ( trim( esc_attr( $as_val ) ) === trim( esc_attr( $field_val ) ) ) {
4732                                                                                                                        $is_checkbox_checked = true;
4733                                                                                                                        $checked             = ' checked="checked"';
4734                                                                                                                }
4735                                                                                                        }
4736                                                                                                }
4737                                                                                        }
4738                                                                                }
4739
4740                                                                                $return_string .= '<div class="arf_checkbox_style ' . $arf_radion_image_class . '" id="frm_checkbox_' . $field['id'] . '-' . $opt_key . '">';
4741                                                                                if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
4742                                                                                        $_REQUEST['arfaction'] = ( isset( $_REQUEST['arfaction'] ) ) ? sanitize_text_field( $_REQUEST['arfaction'] ) : '';
4743
4744                                                                                        $return_string .= "<div class='arf_checkbox_input_wrapper'>";
4745                                                                                        $return_string .= '<input type="checkbox" name="' . $field_name . '[]" data-type="checkbox" id="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" value="' . esc_attr( $field_val ) . '" ' . $checked . ' ';
4746
4747                                                                                        $return_string .= $arf_input_field_html;
4748                                                                                        if ( $k == 0 ) {
4749                                                                                                if ( isset( $field['required'] ) && $field['required'] ) {
4750                                                                                                        if ( isset( $field['min_opt_sel'] ) && $field['min_opt_sel'] != '' && $field['min_opt_sel'] > 0 ) {
4751                                                                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '" ';
4752                                                                                                        } else {
4753                                                                                                                $return_string .= 'data-validation-minchecked-minchecked="1" data-validation-minchecked-message="' . esc_attr( $field['blank'] ) . '"';
4754                                                                                                        }
4755                                                                                                }
4756                                                                                        }
4757                                                                                        if ( isset( $field['max_opt_sel'] ) && $field['max_opt_sel'] != '' && $field['max_opt_sel'] > 0 ) {
4758                                                                                                if ( $field['max_opt_sel'] > count( $field['options'] ) ) {
4759                                                                                                        $return_string .= 'data-validation-maxchecked-maxchecked="' . count( $field['options'] ) . '" data-validation-maxchecked-message="' . esc_attr( $field['max_opt_sel_msg'] ) . '"';
4760                                                                                                } else {
4761                                                                                                        $return_string .= 'data-validation-maxchecked-maxchecked="' . $field['max_opt_sel'] . '" data-validation-maxchecked-message="' . esc_attr( $field['max_opt_sel_msg'] ) . '"';
4762                                                                                                }
4763                                                                                        }
4764                                                                                        if ( isset( $field['min_opt_sel'] ) && $field['min_opt_sel'] != '' && $field['min_opt_sel'] > 0 ) {
4765
4766                                                                                                if ( $field['min_opt_sel'] < count( $field['options'] ) ) {
4767
4768                                                                                                         $return_string .= 'data-validation-minchecked-minchecked="' . $field['min_opt_sel'] . '"  data-validation-minchecked-message="' . esc_attr( $field['min_opt_sel_msg'] ) . '"';
4769
4770                                                                                                } else {
4771                                                                                                        $return_string .= 'data-validation-minchecked-minchecked="' . count( $field['options'] ) . '" data-validation-minchecked-message="' . esc_attr( $field['min_opt_sel_msg'] ) . '"';
4772                                                                                                }
4773                                                                                        }
4774
4775                                                                                        $return_string .= ' />';
4776
4777                                                                                        $return_string .= '<span>';
4778                                                                                        if ( $use_custom_checkbox ) {
4779                                                                                                $custom_checkbox = $form->form_css['arf_checked_checkbox_icon'];
4780                                                                                                $return_string  .= "<i class='{$custom_checkbox}'></i>";
4781                                                                                        }
4782                                                                                        $return_string .= '</span>';
4783                                                                                        $return_string .= '</div>';
4784                                                                                        $return_string .= '<label data-type="checkbox" for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" >';
4785                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
4786                                                                                                $temp_check             = '';
4787                                                                                                $is_checkbox_img_enable = true;
4788                                                                                                if ( $is_checkbox_checked ) {
4789                                                                                                        $temp_check = 'checked';
4790                                                                                                }
4791
4792                                                                                                $return_string .= '<span data-fid="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '"   class="arf_checkbox_label_image ' . $temp_check . ' ' . $chk_icon . '">';
4793                                                                                                $return_string .= '<img src="' . esc_attr( $label_image ) . '" style="max-width:100%; width:' . $image_size . 'px; height:' . $image_size . 'px">';
4794                                                                                                $return_string .= '</span>';
4795                                                                                                $return_string .= '<span class="arf_checkbox_label" style="width:' . $image_size . 'px">';
4796
4797                                                                                        }
4798                                                                                        $return_string .= html_entity_decode( $opt );
4799
4800                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
4801                                                                                                $is_checkbox_img_enable = true;
4802                                                                                                $return_string         .= '</span>';
4803                                                                                        }
4804
4805                                                                                        $return_string .= '</label>';
4806
4807                                                                                }
4808                                                                                $return_string .= '</div>';
4809
4810                                                                                if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
4811                                                                                        if ( $arf_chk_counter % 2 == 0 ) {
4812                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_two">';
4813                                                                                        }
4814                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
4815                                                                                        if ( $arf_chk_counter % 3 == 0 ) {
4816                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_thiree">';
4817                                                                                        }
4818                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
4819                                                                                        if ( $arf_chk_counter % 4 == 0 ) {
4820                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_four">';
4821                                                                                        }
4822                                                                                }
4823                                                                                $k++;
4824                                                                                $arf_chk_counter++;
4825                                                                        }
4826
4827                                                                        if ( isset( $field['align'] ) && ( $field['align'] == 'arf_col_2' || $field['align'] == 'arf_col_3' || $field['align'] == 'arf_col_4' ) ) {
4828                                                                                $return_string .= '</div>';
4829                                                                        }
4830                                                                }
4831                                                                $return_string .= $field_standard_tooltip;
4832                                                                $return_string .= $field_description;
4833                                                                $return_string .= '</div>';
4834                                                        }
4835                                                        $return_string .= '</div>';
4836                                                }
4837                                                break;
4838                                        case 'radio':
4839                                                if ( $inputStyle == 'material' ) {
4840                                                        $alignment_class = ( isset( $field['align'] ) && $field['align'] == 'block' ) ? ' arf_vertical_radio' : ' arf_horizontal_radio';
4841                                                        $return_string  .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $alignment_class . ' ' . $required_class . ' ' . $error_class . ' ' . $class_position . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
4842                                                        $return_string  .= $arf_main_label;
4843
4844                                                        $requested_radio_checked_values = '';
4845                                                        if ( isset( $_REQUEST['checkbox_radio_style_requested'] ) ) {
4846                                                                $requested_radio_checked_values = sanitize_text_field( $_REQUEST['checkbox_radio_style_requested'] );
4847                                                        }
4848                                                        if ( isset( $field['set_field_value'] ) ) {
4849                                                                $field['value'] = $field['set_field_value'];
4850                                                        }
4851
4852                                                        $arf_radion_image_class = '';
4853                                                        if ( isset( $field['label_image'] ) && $field['label_image'] ) {
4854                                                                $arf_radion_image_class = 'arf_enable_radio_image';
4855                                                        }
4856
4857                                                        if ( is_array( $field['options'] ) ) {
4858
4859                                                                $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input{';
4860                                                                        $arflite_form_all_footer_css .= 'padding-top: 5px;';
4861                                                                $arflite_form_all_footer_css     .= '}';
4862                                                                $radio_class                      = 'arf_material_radio';
4863                                                                $use_custom_radio                 = false;
4864                                                                if ( $form->form_css['arfcheckradiostyle'] == 'custom' ) {
4865                                                                        $radio_class      = 'arf_custom_radio';
4866                                                                        $use_custom_radio = true;
4867                                                                } elseif ( $form->form_css['arfcheckradiostyle'] == 'material' ) {
4868                                                                        $radio_class .= ' arf_default_material ';
4869                                                                } else {
4870                                                                        $radio_class .= ' arf_advanced_material ';
4871                                                                }
4872
4873                                                                $return_string .= '<div class="setting_radio controls ' . $field_tooltip_class . ' ' . $radio_class . '" ' . $field_tooltip . '>';
4874                                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
4875
4876                                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
4877                                                                } else {
4878                                                                        $field['options'] = $arflitefieldhelper->arflitechangeoptionorder( $field );
4879
4880                                                                        $k               = 0;
4881                                                                        $arf_chk_counter = 1;
4882
4883                                                                        if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
4884                                                                                $return_string .= '<div class="arf_chk_radio_col_two">';
4885                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
4886                                                                                $return_string .= '<div class="arf_chk_radio_col_thiree">';
4887                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
4888                                                                                $return_string .= '<div class="arf_chk_radio_col_four">';
4889                                                                        }
4890
4891                                                                        $chk_icon = '';
4892                                                                        if ( isset( $field['arflite_check_icon'] ) && $field['arflite_check_icon'] != '' ) {
4893                                                                                $chk_icon = $field['arflite_check_icon'];
4894                                                                        } else {
4895                                                                                $chk_icon = 'fas fa-check';
4896                                                                        }
4897
4898                                                                        $image_size = '';
4899                                                                        if ( isset( $field['image_width'] ) && $field['image_width'] != '' ) {
4900                                                                                $image_size = $field['image_width'];
4901                                                                        } else {
4902                                                                                $image_size = 120;
4903                                                                        }
4904
4905                                                                        foreach ( $field['options'] as $opt_key => $opt ) {
4906                                                                                $label_image = '';
4907                                                                                if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
4908                                                                                        continue;
4909                                                                                }
4910
4911                                                                                $field_val = apply_filters( 'arflitedisplaysavedfieldvalue', $opt, $opt_key, $field );
4912
4913                                                                                $opt = apply_filters( 'arflite_show_field_label', $opt, $opt_key, $field );
4914                                                                                if ( is_array( $opt ) ) {
4915                                                                                        $label_image = isset( $opt['label_image'] ) ? $opt['label_image'] : '';
4916                                                                                        $opt         = $opt['label'];
4917                                                                                        $field_val   = ( isset( $field['separate_value'] ) ) ? $field_val['value'] : $opt;
4918                                                                                }
4919
4920                                                                                if ( isset( $field['value'] ) && isset( $field['set_field_value'] ) && $field['value'] != '' ) {
4921                                                                                        $field['default_value'] = $field['value'];
4922                                                                                }
4923
4924                                                                                $arf_radio_input_wrapper_cls = '';
4925                                                                                if ( $field['use_image'] == 1 && isset( $label_image ) && $label_image != '' ) {
4926                                                                                        $is_radio_img_enable         = true;
4927                                                                                        $arf_radio_input_wrapper_cls = 'arf_enable_radio_image';
4928                                                                                }
4929                                                                                $return_string .= '<div class="arf_radiobutton ' . $arf_radio_input_wrapper_cls . '">';
4930
4931                                                                                if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
4932
4933                                                                                        $return_string .= "<div class='arf_radio_input_wrapper'>";
4934
4935                                                                                        $return_string   .= '<input type="radio" name="' . $field_name . '" data-type="radio" id="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" data-unique-id="' . $arflite_data_uniq_id . '" value="' . esc_attr( $field_val ) . '" ';
4936                                                                                        $is_radio_checked = false;
4937                                                                                        if ( isset( $field['default_value'] ) && $field['default_value'] != '' && $field_val == $field['default_value'] ) {
4938                                                                                                $is_radio_checked = true;
4939                                                                                                $return_string   .= 'checked="checked" ';
4940                                                                                        }
4941
4942                                                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) && $field_val == $arf_arr_preset_data[ $field['id'] ] ) {
4943
4944                                                                                                $is_radio_checked = true;
4945                                                                                                $return_string   .= 'checked="checked" ';
4946                                                                                        }
4947
4948                                                                                        $return_string .= $arf_input_field_html;
4949
4950                                                                                        if ( $k == 0 ) {
4951                                                                                                if ( isset( $field['required'] ) && $field['required'] ) {
4952                                                                                                        $return_string .= ' data-validation-minchecked-minchecked="1" data-validation-minchecked-message="' . esc_attr( $field['blank'] ) . '"';
4953                                                                                                }
4954                                                                                        }
4955
4956                                                                                        $return_string .= ' />';
4957                                                                                        $return_string .= '<span>';
4958                                                                                        if ( $use_custom_radio == true ) {
4959                                                                                                $custom_radio   = $form->form_css['arf_checked_radio_icon'];
4960                                                                                                $return_string .= "<i class='{$custom_radio}'></i>";
4961                                                                                        }
4962                                                                                        $return_string         .= '</span>';
4963                                                                                        $return_string         .= '</div>';
4964                                                                                        $arf_radion_image_class = '';
4965                                                                                        if ( $field['use_image'] == 1 && isset( $label_image ) && $label_image != '' ) {
4966                                                                                                $is_radio_img_enable    = true;
4967                                                                                                $arf_radion_image_class = 'arf_enable_radio_image';
4968                                                                                        }
4969
4970                                                                                        $return_string .= '<label data-type="radio" for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="' . $arf_radion_image_class . '">';
4971                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
4972
4973                                                                                                $is_radio_img_enable = true;
4974
4975                                                                                                if ( $inputStyle == 'material' ) {
4976                                                                                                        $return_string .= '<label for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="arf_radio_label_image ' . $chk_icon . ' ' . ( ( $is_radio_checked ) ? ' checked ' : '' ) . '">';
4977
4978                                                                                                                        $return_string .= '<svg role"none" style="max-width:100%; width:' . $image_size . 'px; height:' . $image_size . 'px">';
4979
4980                                                                                                                                $return_string     .= '<mask id="clip-cutoff_field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '">';
4981                                                                                                                                        $return_string .= '<rect fill="white" x="0" y="0" rx="8" ry="8" width="' . $image_size . 'px" height="' . $image_size . 'px"></rect>';
4982                                                                                                                                        $return_string .= '<rect fill="black" rx="4" ry="4" width="27" height="27" class="rect-cutoff"></rect>';
4983                                                                                                                                $return_string     .= '</mask>';
4984                                                                                                                                $return_string     .= '<g mask="url(#clip-cutoff_field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . ')">';
4985                                                                                                                                        $return_string .= '<image x="0" y="0" height="' . $image_size . 'px" preserveAspectRatio="xMidYMid slice" width="' . $image_size . 'px" href="' . esc_attr( $label_image ) . '"></image>';
4986                                                                                                                                        $return_string .= '<rect fill="none"x="0" y="0" rx="8" ry="8" width="' . $image_size . 'px" height="' . $image_size . 'px" class="img_stroke"></rect>';
4987                                                                                                                                $return_string     .= '</g>';
4988                                                                                                                                $return_string     .= '</svg>';
4989                                                                                                                $return_string             .= '</label>';
4990                                                                                                } else {
4991
4992                                                                                                        $return_string .= '<span data-fid="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="arf_radio_label_image ' . $chk_icon . ' ' . ( ( $is_radio_checked ) ? ' checked ' : '' ) . '">';
4993                                                                                                        $return_string .= '<img src=' . esc_attr( $label_image ) . ' style="width: ' . $image_size . 'px; height: ' . $image_size . 'px; max-width:100%;"></span>';
4994
4995                                                                                                }
4996                                                                                                $return_string .= '<span class="arf_radio_label" style="width:' . $image_size . 'px">';
4997                                                                                        }
4998                                                                                        $return_string .= html_entity_decode( $opt );
4999                                                                                        if ( isset( $field['radio_use_image'] ) && $field['radio_use_image'] ) {
5000                                                                                                $is_radio_img_enable = true;
5001                                                                                                $return_string      .= '</span>';
5002                                                                                        }
5003
5004                                                                                        $return_string .= '</label>';
5005                                                                                }
5006                                                                                $return_string .= '</div>';
5007                                                                                if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
5008                                                                                        if ( $arf_chk_counter % 2 == 0 ) {
5009                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_two">';
5010                                                                                        }
5011                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
5012                                                                                        if ( $arf_chk_counter % 3 == 0 ) {
5013                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_thiree">';
5014                                                                                        }
5015                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
5016                                                                                        if ( $arf_chk_counter % 4 == 0 ) {
5017                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_four">';
5018                                                                                        }
5019                                                                                }
5020                                                                                $k++;
5021                                                                                $arf_chk_counter++;
5022                                                                        }
5023
5024                                                                        if ( isset( $field['align'] ) && ( $field['align'] == 'arf_col_2' || $field['align'] == 'arf_col_3' || $field['align'] == 'arf_col_4' ) ) {
5025                                                                                $return_string .= '</div>';
5026                                                                        }
5027                                                                }
5028                                                                $return_string .= $field_standard_tooltip;
5029                                                                $return_string .= $field_description;
5030
5031                                                                $return_string .= '</div>';
5032                                                        }
5033
5034                                                        $return_string .= '</div>';
5035                                                } else {
5036                                                        $alignment_class = ( isset( $field['align'] ) && $field['align'] == 'block' ) ? ' arf_vertical_radio' : ' arf_horizontal_radio';
5037                                                        $return_string  .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $alignment_class . ' ' . $required_class . '  ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5038                                                        $return_string  .= $arf_main_label;
5039
5040                                                        $requested_radio_checked_values = '';
5041                                                        if ( isset( $_REQUEST['checkbox_radio_style_requested'] ) ) {
5042                                                                $requested_radio_checked_values = sanitize_text_field( $_REQUEST['checkbox_radio_style_requested'] );
5043                                                        }
5044                                                        if ( isset( $field['set_field_value'] ) ) {
5045                                                                $field['value'] = $field['set_field_value'];
5046                                                        }
5047
5048                                                        $arf_radion_image_class = '';
5049                                                        if ( isset( $field['label_image'] ) && $field['label_image'] ) {
5050                                                                $arf_radion_image_class = 'arf_enable_radio_image';
5051                                                        }
5052
5053                                                        if ( is_array( $field['options'] ) ) {
5054
5055                                                                $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input{';
5056                                                                        $arflite_form_all_footer_css .= 'padding-top: 5px;';
5057                                                                $arflite_form_all_footer_css     .= '}';
5058                                                                $radio_class                      = 'arf_standard_radio';
5059                                                                $use_custom_radio                 = false;
5060                                                                if ( $form->form_css['arfcheckradiostyle'] == 'custom' ) {
5061                                                                        $radio_class      = 'arf_custom_radio';
5062                                                                        $use_custom_radio = true;
5063                                                                }
5064                                                                if ( $form->form_css['arfinputstyle'] == 'rounded' && $form->form_css['arfcheckradiostyle'] != 'custom' ) {
5065                                                                        $radio_class      = 'arf_rounded_flat_radio';
5066                                                                        $use_custom_radio = false;
5067                                                                }
5068
5069                                                                $return_string .= '<div class="setting_radio controls ' . $radio_class . ' ">';
5070                                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5071
5072                                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5073                                                                } else {
5074                                                                        $field['options'] = $arflitefieldhelper->arflitechangeoptionorder( $field );
5075
5076                                                                        $k               = 0;
5077                                                                        $arf_chk_counter = 1;
5078
5079                                                                        if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
5080                                                                                $return_string .= '<div class="arf_chk_radio_col_two">';
5081                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
5082                                                                                $return_string .= '<div class="arf_chk_radio_col_thiree">';
5083                                                                        } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
5084                                                                                $return_string .= '<div class="arf_chk_radio_col_four">';
5085                                                                        }
5086
5087                                                                         $chk_icon = '';
5088                                                                        if ( isset( $field['arflite_check_icon'] ) && $field['arflite_check_icon'] != '' ) {
5089                                                                                $chk_icon = $field['arflite_check_icon'];
5090                                                                        } else {
5091                                                                                $chk_icon = 'fas fa-check';
5092                                                                        }
5093
5094                                                                        $image_size = '';
5095                                                                        if ( isset( $field['image_width'] ) && $field['image_width'] != '' ) {
5096                                                                                $image_size = $field['image_width'];
5097                                                                        } else {
5098                                                                                $image_size = 120;
5099                                                                        }
5100
5101                                                                        foreach ( $field['options'] as $opt_key => $opt ) {
5102                                                                                $label_image = '';
5103                                                                                if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
5104                                                                                        continue;
5105                                                                                }
5106
5107                                                                                $field_val = apply_filters( 'arflitedisplaysavedfieldvalue', $opt, $opt_key, $field );
5108
5109                                                                                $opt = apply_filters( 'arflite_show_field_label', $opt, $opt_key, $field );
5110                                                                                if ( is_array( $opt ) ) {
5111                                                                                        $label_image = isset( $opt['label_image'] ) ? $opt['label_image'] : '';
5112                                                                                        $opt         = $opt['label'];
5113                                                                                        $field_val   = ( isset( $field['separate_value'] ) ) ? $field_val['value'] : $opt;
5114                                                                                }
5115                                                                                if ( isset( $field['value'] ) && isset( $field['set_field_value'] ) && $field['value'] != '' ) {
5116                                                                                        $field['default_value'] = $field['value'];
5117                                                                                }
5118
5119                                                                                        $arf_radion_image_class = '';
5120                                                                                if ( $field['use_image'] == 1 && isset( $label_image ) && $label_image != '' ) {
5121                                                                                        $is_radio_img_enable    = true;
5122                                                                                        $arf_radion_image_class = 'arf_enable_radio_image';
5123                                                                                }
5124                                                                                        $return_string .= '<div class="arf_radiobutton ' . $arf_radion_image_class . '">';
5125
5126                                                                                if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
5127
5128                                                                                        $return_string .= "<div class='arf_radio_input_wrapper'>";
5129
5130                                                                                                $return_string   .= '<input type="radio" name="' . $field_name . '" data-type="radio" id="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" data-unique-id="' . $arflite_data_uniq_id . '" value="' . esc_attr( $field_val ) . '" ';
5131                                                                                                $is_radio_checked = false;
5132                                                                                        if ( isset( $field['default_value'] ) && $field['default_value'] != '' && $field_val == $field['default_value'] ) {
5133                                                                                                $is_radio_checked = true;
5134                                                                                                $return_string   .= 'checked="checked" ';
5135                                                                                        }
5136
5137                                                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) && $field_val == $arf_arr_preset_data[ $field['id'] ] ) {
5138
5139                                                                                                $is_radio_checked = true;
5140                                                                                                $return_string   .= 'checked="checked" ';
5141                                                                                        }
5142
5143                                                                                        $return_string .= $arf_input_field_html;
5144
5145                                                                                        if ( $k == 0 ) {
5146                                                                                                if ( isset( $field['required'] ) && $field['required'] ) {
5147                                                                                                        $return_string .= ' data-validation-minchecked-minchecked="1" data-validation-minchecked-message="' . esc_attr( $field['blank'] ) . '"';
5148                                                                                                }
5149                                                                                        }
5150
5151                                                                                        $return_string .= ' />';
5152                                                                                        $return_string .= '<span>';
5153                                                                                        if ( $use_custom_radio == true ) {
5154                                                                                                $custom_radio   = $form->form_css['arf_checked_radio_icon'];
5155                                                                                                $return_string .= "<i class='{$custom_radio}'></i>";
5156                                                                                        }
5157                                                                                        $return_string .= '</span>';
5158                                                                                        $return_string .= '</div>';
5159
5160                                                                                        $return_string .= '<label data-type="radio" for="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="' . $arf_radion_image_class . '">';
5161
5162                                                                                        if ( $field['use_image'] == 1 && $label_image != '' ) {
5163
5164                                                                                                $is_radio_img_enable = true;
5165
5166                                                                                                 $return_string   .= '<span data-fid="field_' . $field['id'] . '-' . $opt_key . '-' . $arflite_data_uniq_id . '" class="arf_radio_label_image ' . $chk_icon . '' . ( ( $is_radio_checked ) ? ' checked ' : '' ) . '">';
5167                                                                                                   $return_string .= '<img src="' . esc_attr( $label_image ) . '" style="width:' . $image_size . 'px; height:' . $image_size . 'px; max-width:100%;"></span><span class="arf_radio_label" style="width:' . $image_size . 'px">';
5168                                                                                        }
5169
5170                                                                                        $return_string .= html_entity_decode( $opt );
5171
5172                                                                                        if ( $label_image != '' ) {
5173                                                                                                $return_string .= '</span>';
5174                                                                                        }
5175
5176                                                                                        $return_string .= '</label>';
5177                                                                                }
5178                                                                                $return_string .= '</div>';
5179                                                                                if ( isset( $field['align'] ) && $field['align'] == 'arf_col_2' ) {
5180                                                                                        if ( $arf_chk_counter % 2 == 0 ) {
5181                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_two">';
5182                                                                                        }
5183                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_3' ) {
5184                                                                                        if ( $arf_chk_counter % 3 == 0 ) {
5185                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_thiree">';
5186                                                                                        }
5187                                                                                } elseif ( isset( $field['align'] ) && $field['align'] == 'arf_col_4' ) {
5188                                                                                        if ( $arf_chk_counter % 4 == 0 ) {
5189                                                                                                $return_string .= '</div><div class="arf_chk_radio_col_four">';
5190                                                                                        }
5191                                                                                }
5192                                                                                $k++;
5193                                                                                $arf_chk_counter++;
5194                                                                        }
5195
5196                                                                        if ( isset( $field['align'] ) && ( $field['align'] == 'arf_col_2' || $field['align'] == 'arf_col_3' || $field['align'] == 'arf_col_4' ) ) {
5197                                                                                $return_string .= '</div>';
5198                                                                        }
5199                                                                }
5200                                                                $return_string .= $field_standard_tooltip;
5201                                                                $return_string .= $field_description;
5202
5203                                                                $return_string .= '</div>';
5204                                                        }
5205
5206                                                        $return_string .= '</div>';
5207                                                }
5208                                                break;
5209                                        case 'select':
5210                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield input-field control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5211                                                if ( $inputStyle != 'material' ) {
5212                                                        $return_string .= $arf_main_label;
5213                                                }
5214                                                $return_string .= '<div class=" sltstandard_front controls' . $field_tooltip_class . '" ' . $field_tooltip . '>';
5215
5216                                                $arfdefault_selected_val = ( isset( $field['separate_value'] ) && $field['separate_value'] ) ? $field['default_value'] : ( isset( $field['value'] ) ? $field['value'] : '' );
5217
5218                                                if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
5219
5220                                                        $arfdefault_selected_val = $arf_arr_preset_data[ $field['id'] ];
5221                                                }
5222
5223                                                if ( isset( $field['set_field_value'] ) ) {
5224                                                        $arfdefault_selected_val = $field['set_field_value'];
5225                                                }
5226                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5227
5228                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5229                                                } else {
5230                                                        $field['options'] = $arflitefieldhelper->arflitechangeoptionorder( $field );
5231
5232                                                        $select_attrs = array();
5233
5234                                                        $sel_field_id = 'field_' . $field['field_key'] . '_' . $arflite_data_uniq_id;
5235
5236                                                        $select_field_opts = array();
5237
5238                                                        $list_attrs            = array();
5239                                                        $arf_set_default_label = false;
5240
5241                                                        if ( ! empty( $field['options'] ) ) {
5242                                                                $count_i = 0;
5243                                                                foreach ( $field['options'] as $opt_key => $opt ) {
5244                                                                        $field_val = apply_filters( 'arflitedisplaysavedfieldvalue', $opt, $opt_key, $field );
5245
5246                                                                        $opt = apply_filters( 'arflite_show_field_label', $opt, $opt_key, $field );
5247
5248                                                                        if ( is_array( $opt ) ) {
5249                                                                                $opt = $opt['label'];
5250                                                                                if ( $field_val['value'] == '(Blank)' ) {
5251                                                                                        $field_val['value'] = '';
5252                                                                                }
5253                                                                                $field_val = ( isset( $field['separate_value'] ) ) ? $field_val['value'] : $opt;
5254                                                                        }
5255                                                                        if ( $count_i == 0 and $opt == '' ) {
5256                                                                                $opt = esc_html__( 'Please select', 'arforms-form-builder' );
5257                                                                        }
5258
5259                                                                        $field['value']          = isset( $field['value'] ) ? $field['value'] : '';
5260                                                                        $arfdefault_selected_val = ( isset( $field['separate_value'] ) ) ? $field['default_value'] : $field['value'];
5261                                                                        if ( isset( $field['set_field_value'] ) && ! empty( $field['set_field_value'] ) ) {
5262                                                                                $arfdefault_selected_val = $field['set_field_value'];
5263                                                                        }
5264
5265                                                                        if ( ! empty( $arfdefault_selected_val ) ) {
5266                                                                                $arf_set_default_label = false;
5267                                                                        }
5268
5269                                                                        $select_field_opts[ $field_val ] = $opt;
5270                                                                        $count_i++;
5271                                                                }
5272                                                        }
5273
5274                                                        $select_attrs['data-default-val'] = $arfdefault_selected_val;
5275                                                        if ( isset( $field['required'] ) and $field['required'] ) {
5276                                                                $select_attrs['data-validation-required-message'] = esc_attr( $field['blank'] );
5277                                                        }
5278
5279                                                        $select_attrs['data-field_id'] = $field['id'];
5280
5281                                                        if ( $inputStyle == 'material' ) {
5282                                                                $mo_active_container_cls = ( ! empty( $arfdefault_selected_val ) ) ? 'arf_material_active_container_open' : '';
5283                                                                $return_string          .= '<div class="arf_material_theme_container ' . $mo_active_container_cls . '">';
5284                                                        }
5285
5286                                                        if ( wp_is_mobile() ) {
5287                                                                $select_attrs['readonly'] = 'readonly';
5288                                                        }
5289
5290                                                        $return_string .= $arflitemaincontroller->arflite_selectpicker_dom( $field_name, $sel_field_id, ' arf_form_field_picker ', '', $arfdefault_selected_val, $select_attrs, $select_field_opts, false, array(), false, array(), true, $field, false, '', '', $arf_set_default_label );
5291
5292                                                        if ( $inputStyle == 'material' ) {
5293                                                                        $return_string         .= '<div class="arf_material_standard">';
5294                                                                                $return_string     .= '<div class="arf_material_theme_prefix"></div>';
5295                                                                                $return_string     .= '<div class="arf_material_theme_notch">';
5296                                                                                        $return_string .= $arf_main_label;
5297                                                                                $return_string     .= '</div>';
5298                                                                                $return_string     .= '<div class="arf_material_theme_suffix"></div>';
5299                                                                        $return_string         .= '</div>';
5300                                                                $return_string             .= '</div>';
5301                                                        }
5302
5303                                                        $return_string .= $field_standard_tooltip;
5304                                                }
5305                                                $return_string .= $field_description;
5306                                                $return_string .= '</div>';
5307                                                $return_string .= '</div>';
5308                                                break;
5309                                        case 'number':
5310                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $material_input_cls . ' ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5311
5312                                                if ( $inputStyle != 'material' ) {
5313                                                        $return_string .= $arf_main_label;
5314                                                }
5315
5316                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
5317
5318                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5319
5320                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5321                                                } else {
5322
5323                                                        $return_string .= $prefix;
5324                                                        $num_field_type = 'text';
5325                                                        $arflitehttpserver = !empty($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field($_SERVER['HTTP_USER_AGENT']) : '';
5326                                                        if ( wp_is_mobile() && strpos( $arflitehttpserver, 'Android' ) !== false ) {
5327                                                                $num_field_type = 'number';
5328                                                        }
5329                                                        if ( 'material' == $inputStyle ) {
5330
5331                                                                $material_standard_cls = '';
5332                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
5333                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
5334                                                                }
5335                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
5336                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
5337                                                                }
5338                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5339                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
5340                                                                }
5341                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5342                                                                        $material_standard_cls .= ' arf_both_icons ';
5343                                                                }
5344                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
5345
5346                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
5347                                                        }
5348                                                        $return_string .= '<input type="' . esc_attr( $num_field_type ) . '" class="arf_number_field" id="field_' . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . '" dir=" ';
5349
5350                                                        if ( isset( $field['text_direction'] ) && $field['text_direction'] == '0' ) {
5351                                                                $return_string .= 'rtl';
5352                                                        } else {
5353                                                                $return_string .= 'ltr';
5354                                                        }
5355                                                        $return_string .= '"';
5356                                                        $return_string .= 'name="' . esc_attr( $field_name ) . '" ';
5357
5358                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
5359                                                                $return_string .= 'readonly="readonly" ';
5360                                                        }
5361
5362                                                        $default_value = $field['default_value'];
5363
5364                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
5365                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
5366                                                        }
5367
5368                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
5369
5370                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
5371                                                                $default_value = $field['set_field_value'];
5372                                                        }
5373
5374                                                        if ( $default_value != '' ) {
5375                                                                $return_string .= ' value=' . esc_attr( $default_value ) . "'";
5376                                                        }
5377
5378                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
5379                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
5380                                                        }
5381
5382                                                        $return_string .= $arf_input_field_html;
5383
5384                                                        if ( isset( $field['required'] ) && $field['required'] ) {
5385                                                                $return_string .= 'data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
5386                                                        }
5387
5388                                                        if ( $field['type'] == 'number' && $field['maxnum'] != '' && $field['maxnum'] > 0 ) {
5389                                                                $return_string .= ' data-validation-max-message="' . esc_attr( $field['invalid'] ) . '" ';
5390                                                        }
5391
5392                                                        if ( $field['minnum'] != '' ) {
5393                                                                $return_string .= ' min="' . $field['minnum'] . '" ';
5394                                                        }
5395
5396                                                        if ( $field['maxnum'] != '' ) {
5397                                                                $return_string .= ' max="' . $field['maxnum'] . '" ';
5398                                                        }
5399
5400                                                        $return_string .= ' onkeydown="arflitevalidatenumber(this,event);" ';
5401                                                        if ( $field['minlength'] != '' && 0 < $field['minlength'] ) {
5402                                                                $return_string .= ' minlength="' . $field['minlength'] . '" data-validation-minlength-message="' . esc_attr( $field['minlength_message'] ) . '" ';
5403                                                        }
5404                                                        $return_string .= '/>';
5405                                                        if ( 'material' == $inputStyle ) {
5406                                                                $return_string         .= '<div class="arf_material_standard">';
5407                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
5408                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
5409                                                                                $return_string .= $arf_main_label;
5410                                                                        $return_string     .= '</div>';
5411                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
5412                                                                $return_string         .= '</div>';
5413                                                                $return_string         .= '</div>';
5414                                                        }
5415                                                        $return_string .= $suffix;
5416
5417                                                        $return_string .= $field_standard_tooltip;
5418                                                }
5419                                                $return_string .= $field_description;
5420                                                $return_string .= '</div>';
5421                                                $return_string .= '</div>';
5422                                                break;
5423                                        case 'phone':
5424                                        case 'tel':
5425                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5426                                                if ( $inputStyle != 'material' ) {
5427                                                        $return_string .= $arf_main_label;
5428                                                }
5429                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
5430
5431                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5432
5433                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5434                                                } else {
5435                                                        $return_string .= $prefix;
5436
5437                                                        if ( 'material' == $inputStyle ) {
5438                                                                $material_standard_cls = '';
5439                                                                $has_phone_with_utils  = false;
5440                                                                $phone_with_utils_cls  = '';
5441                                                                if ( isset( $field['phonetype'] ) ) {
5442                                                                        if ( $field['type'] == 'phone' && $field['phonetype'] == 1 ) {
5443                                                                                $has_phone_with_utils = true;
5444                                                                                $phone_with_utils_cls = 'arf_phone_with_flag';
5445                                                                        }
5446                                                                }
5447                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
5448                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons ' . $phone_with_utils_cls;
5449                                                                }
5450                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
5451                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
5452                                                                }
5453                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5454                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
5455                                                                }
5456                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5457                                                                        $material_standard_cls .= ' arf_both_icons ';
5458                                                                }
5459                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
5460
5461                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
5462                                                        }
5463
5464                                                        $return_string .= '<input type="text" data-type="phone"  id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '"';
5465                                                        $return_string .= 'name="' . $field_name . '"';
5466
5467                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
5468                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
5469                                                        }
5470
5471                                                        $return_string .= $arflitefieldcontroller->arflite_input_fieldhtml( $field, false );
5472                                                        $phone_flag     = false;
5473
5474                                                        if ( isset( $field['phonetype'] ) && $field['phonetype'] == 1 ) {
5475                                                                $phtypes = array();
5476                                                                foreach ( $field['phtypes'] as $key => $vphtype ) {
5477                                                                        if ( $vphtype != 0 ) {
5478                                                                                array_push( $phtypes, strtolower( str_replace( 'phtypes_', '', $key ) ) );
5479                                                                        }
5480                                                                }
5481
5482                                                                $return_string .= ' data-defaultCountryCode="' . $phtypes[0] . '" ';
5483
5484                                                                if ( isset( $field['country_validation'] ) && $field['country_validation'] == 1 ) {
5485                                                                        $return_string .= ' data-do-validation="true" ';
5486                                                                        $return_string .= 'data-invalid-format-message="' . esc_attr( $field['invalid'] ) . '"';
5487                                                                } else {
5488                                                                        $return_string .= ' data-do-validation="false" ';
5489                                                                }
5490                                                                $phone_flag = true;
5491                                                        }
5492
5493                                                        if ( isset( $field['required'] ) && $field['required'] ) {
5494                                                                $return_string .= 'data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
5495                                                        }
5496
5497                                                        if ( ! $phone_flag ) {
5498                                                                if ( $field['phone_validation'] == 'international' ) {
5499                                                                        $return_string .= 'data-validation-number-message="' . esc_attr( $field['invalid'] ) . '"';
5500                                                                        $phone_regex    = '';
5501                                                                        $inputmask      = '';
5502                                                                } else {
5503                                                                        if ( $field['phone_validation'] == 'custom_validation_1' ) {
5504                                                                                $phone_regex = '^[(]{1}[0-9]{3,4}[)]{1}[0-9]{3}[\s]{1,1}[0-9]{4}$';
5505                                                                                $inputmask   = '(999)999 9999';
5506                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_2' ) {
5507                                                                                $phone_regex = '^[(]{1}[0-9]{3,4}[)]{1}[\s]{1}[0-9]{3}[\s]{1}[0-9]{4}$';
5508                                                                                $inputmask   = '(999) 999 9999';
5509                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_3' ) {
5510                                                                                $phone_regex = '^[(]{1}[0-9]{3,4}[)]{1}[0-9]{3}[-]{1}[0-9]{4}$';
5511                                                                                $inputmask   = '(999)999-9999';
5512                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_4' ) {
5513                                                                                $phone_regex = '^[(]{1}[0-9]{3,4}[)]{1}[\s]{1}[0-9]{3}[-]{1}[0-9]{4}$';
5514                                                                                $inputmask   = '(999) 999-9999';
5515                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_5' ) {
5516                                                                                $phone_regex = '^[0-9]{3,4}[\s]{1}[0-9]{3}[\s]{1}[0-9]{4}$';
5517                                                                                $inputmask   = '999 999 9999';
5518                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_6' ) {
5519                                                                                $phone_regex = '^[0-9]{3,4}[\s]{1}[0-9]{3}[-]{1}[0-9]{4}$';
5520                                                                                $inputmask   = '999 999-9999';
5521                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_7' ) {
5522                                                                                $phone_regex = '^[0-9]{3,4}[-]{1}[0-9]{3}[-]{1}[0-9]{4}$';
5523                                                                                $inputmask   = '999-999-9999';
5524                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_8' ) {
5525                                                                                $phone_regex = '^[0-9]{4,5}[\s]{1}[0-9]{3}[\s]{1}[0-9]{3}$';
5526                                                                                $inputmask   = '99999 999 999';
5527                                                                        } elseif ( $field['phone_validation'] == 'custom_validation_9' ) {
5528                                                                                $phone_regex = '^[0-9]{4,5}[\s]{1}[0-9]{6}$';
5529                                                                                $inputmask   = '99999 999999';
5530                                                                        }
5531                                                                        $return_string .= ' data-validation-regex-regex="' . @$phone_regex . '"';
5532                                                                        $return_string .= ' data-mask="' . @$inputmask . '"';
5533                                                                        $return_string .= ' data-validation-regex-message="' . esc_attr( $field['invalid'] ) . '"';
5534                                                                }
5535                                                        }
5536
5537                                                        if ( wp_is_mobile() ) {
5538                                                                if ( isset( $inputmask ) && $inputmask != '' ) {
5539                                                                        $return_string .= ' data-mask-input="' . $inputmask . '"';
5540                                                                        $return_string .= ' data-ismask="true" ';
5541                                                                }
5542                                                        }
5543                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
5544                                                                $return_string .= 'readonly="readonly" ';
5545                                                        }
5546
5547                                                        $default_value = $field['default_value'];
5548
5549                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
5550                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
5551
5552                                                        }
5553
5554                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
5555
5556                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
5557                                                                $default_value = $field['set_field_value'];
5558                                                        }
5559
5560                                                        if ( $default_value != '' ) {
5561                                                                $return_string .= " value='{$default_value}'";
5562                                                        }
5563
5564                                                        $return_string .= '/>';
5565
5566                                                        if ( 'material' == $inputStyle ) {
5567                                                                $return_string         .= '<div class="arf_material_standard">';
5568                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
5569                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
5570                                                                                $return_string .= $arf_main_label;
5571                                                                        $return_string     .= '</div>';
5572                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
5573                                                                $return_string         .= '</div>';
5574                                                                $return_string         .= '</div>';
5575                                                        }
5576
5577                                                        $return_string .= $suffix;
5578                                                        $return_string .= $field_standard_tooltip;
5579                                                }
5580
5581                                                $return_string .= $field_description;
5582                                                $return_string .= '</div>';
5583                                                if ( isset( $field['phonetype'] ) && $field['phonetype'] == 1 ) {
5584
5585                                                        if ( isset( $phtypes ) && count( $phtypes ) > 0 ) {
5586                                                                $return_string .= "<input type='hidden' data-jqvalidate='false' id='field_" . esc_attr( $field['field_key'] ) . "_country_list' value='" . esc_attr( json_encode( $phtypes ) ) . "' />";
5587                                                        }
5588
5589                                                        $phone_hidden_name = 'item_meta[' . $field['id'] . '_country_code]';
5590
5591                                                        $return_string .= "<input type='hidden' data-jqvalidate='false' name='" . esc_attr( $phone_hidden_name ) . "' id='field_" . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . "_country_code' />";
5592
5593                                                        $default_country     = isset( $field['default_country'] ) ? $field['default_country'] : '';
5594                                                        $arf_default_country = '';
5595                                                        if ( $default_country != '' && in_array( $default_country, $phtypes ) ) {
5596                                                                $arf_default_country = $default_country;
5597                                                        }
5598
5599                                                        $return_string .= "<input type='hidden' data-jqvalidate='false' id='field_" . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . "_default_country' value='" . esc_attr( $arf_default_country ) . "' />";
5600                                                }
5601                                                $return_string .= '</div>';
5602                                                break;
5603                                        case 'url':
5604                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . '' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5605                                                if ( $inputStyle != 'material' ) {
5606                                                        $return_string .= $arf_main_label;
5607                                                }
5608
5609                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
5610
5611                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5612
5613                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5614                                                } else {
5615
5616                                                        $regex  = '((https?|ftp):\/\/)?';
5617                                                        $regex .= '((HTTPS?|ftp):\/\/)?';
5618                                                        $regex .= '([A-Za-z0-9+!*(),;?&=$_.-]+(:[A-Za-z0-9+!*(),;?&=$_.-]+)?@)?';
5619                                                        $regex .= '([A-Za-z0-9-.]*)\.([A-Za-z]+)';
5620                                                        $regex .= '(:[0-9]{2,5})?';
5621                                                        $regex .= '(\/([A-Za-z0-9+!$_-]\.?)+)*\/?';
5622                                                        $regex .= '(\?[A-Za-z+&$_.-][A-Za-z0-9;:@&%=+\/$_.-]*)?';
5623                                                        $regex .= '(#[A-Za-z_.-][A-Za-z0-9+$_.-]*)?';
5624
5625                                                        $return_string .= $prefix;
5626
5627                                                        if ( 'material' == $inputStyle ) {
5628                                                                $material_standard_cls = '';
5629                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
5630                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
5631                                                                }
5632                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
5633                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
5634                                                                }
5635                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5636                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
5637                                                                }
5638                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
5639                                                                        $material_standard_cls .= ' arf_both_icons ';
5640                                                                }
5641                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
5642
5643                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
5644                                                        }
5645
5646                                                        $return_string .= '<input type="url" id="field_' . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . '" ';
5647
5648                                                        $return_string .= 'name="' . esc_attr( $field_name ) . '" ';
5649
5650                                                        $default_value = $field['default_value'];
5651
5652                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
5653
5654                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
5655
5656                                                        }
5657
5658                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
5659
5660                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
5661                                                                $default_value = $field['set_field_value'];
5662                                                        }
5663                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
5664                                                                $return_string .= 'readonly="readonly" ';
5665                                                        }
5666
5667                                                        if ( $default_value != '' ) {
5668                                                                $return_string .= " value='" . esc_attr( $default_value ) . "'";
5669                                                        }
5670
5671                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
5672                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
5673                                                        }
5674
5675                                                        if ( isset( $field['clear_on_focus'] ) && $field['clear_on_focus'] ) {
5676                                                                $return_string .= ' onfocus="arflitecleardedaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
5677                                                                $return_string .= ' onblur="arflitereplacededaultvalueonfocus(\'' . $field['placeholdertext'] . '\',this,\'' . $is_default_blank . '\')"';
5678                                                        }
5679
5680                                                        $return_string .= $arf_input_field_html;
5681
5682                                                        if ( isset( $field['required'] ) && $field['required'] ) {
5683                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
5684                                                        }
5685                                                        $return_string .= ' data-validation-regex-regex="' . $regex . '" data-validation-regex-message="' . esc_attr( $field['invalid'] ) . '" ';
5686
5687                                                        $return_string .= '/>';
5688                                                        if ( 'material' == $inputStyle ) {
5689                                                                $return_string         .= '<div class="arf_material_standard">';
5690                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
5691                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
5692                                                                                $return_string .= $arf_main_label;
5693                                                                        $return_string     .= '</div>';
5694                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
5695                                                                $return_string         .= '</div>';
5696                                                                $return_string         .= '</div>';
5697                                                        }
5698                                                        $return_string .= $suffix;
5699
5700                                                        $return_string .= $field_standard_tooltip;
5701                                                }
5702                                                $return_string .= $field_description;
5703                                                $return_string .= '</div>';
5704                                                $return_string .= '</div>';
5705                                                break;
5706                                        case 'date':
5707                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
5708
5709                                                if ( $inputStyle != 'material' ) {
5710                                                        $return_string .= $arf_main_label;
5711                                                }
5712
5713                                                $return_string .= '<div class="controls arf_date_main_controls ' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
5714
5715                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
5716
5717                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
5718                                                } else {
5719
5720                                                        $return_string .= $prefix;
5721
5722                                                        $wp_format_date     = get_option( 'date_format' );
5723                                                        $defaultdate_format = '';
5724                                                        if ( $wp_format_date == 'F j, Y' || $wp_format_date == 'm/d/Y' ) {
5725                                                                if ( $field['arfnewdateformat'] == 'MMMM D, YYYY' ) {
5726                                                                        $defaultdate_format = 'F d, Y';
5727                                                                } elseif ( $field['arfnewdateformat'] == 'MMM D, YYYY' ) {
5728                                                                        $defaultdate_format = 'M d, Y';
5729                                                                } else {
5730                                                                        $defaultdate_format = 'm/d/Y';
5731                                                                }
5732                                                        } elseif ( $wp_format_date == 'd/m/Y' ) {
5733                                                                if ( $field['arfnewdateformat'] == 'D MMMM, YYYY' ) {
5734                                                                        $defaultdate_format = 'd F, Y';
5735                                                                } elseif ( $field['arfnewdateformat'] == 'D MMM, YYYY' ) {
5736                                                                        $defaultdate_format = 'd M, Y';
5737                                                                } else {
5738                                                                        $defaultdate_format = 'd/m/Y';
5739                                                                }
5740                                                        } elseif ( $wp_format_date == 'Y/m/d' ) {
5741                                                                if ( $field['arfnewdateformat'] == 'YYYY, MMMM D' ) {
5742                                                                        $defaultdate_format = 'Y, F d';
5743                                                                } elseif ( $field['arfnewdateformat'] == 'YYYY, MMM D' ) {
5744                                                                        $defaultdate_format = 'Y, M d';
5745                                                                } else {
5746                                                                        $defaultdate_format = 'Y/m/d';
5747                                                                }
5748                                                        } elseif ( $wp_format_date == 'd.F.y' || $wp_format_date == 'd.m.Y' || $wp_format_date == 'Y.m.d' || $wp_format_date == 'd. F Y' ) {
5749                                                                if ( $field['arfnewdateformat'] == 'D.MM.YYYY' ) {
5750                                                                        $defaultdate_format = 'd.m.Y';
5751                                                                } elseif ( $field['arfnewdateformat'] == 'D.MMMM.YY' ) {
5752                                                                        $defaultdate_format = 'd.F.y';
5753                                                                } elseif ( $field['arfnewdateformat'] == 'YYYY.MM.D' ) {
5754                                                                        $defaultdate_format = 'Y.m.d';
5755                                                                } elseif ( $field['arfnewdateformat'] == 'D. MMMM YYYY' ) {
5756                                                                        $defaultdate_format = 'd. F Y';
5757                                                                }
5758                                                        } else {
5759                                                                if ( $field['arfnewdateformat'] == 'MMMM D, YYYY' ) {
5760                                                                        $defaultdate_format = 'F d, Y';
5761                                                                } elseif ( $field['arfnewdateformat'] == 'MMM D, YYYY' ) {
5762                                                                        $defaultdate_format = 'M d, Y';
5763                                                                } elseif ( $field['arfnewdateformat'] == 'YYYY/MM/DD' ) {
5764                                                                        $defaultdate_format = 'Y/m/d';
5765                                                                } elseif ( $field['arfnewdateformat'] == 'MM/DD/YYYY' ) {
5766                                                                        $defaultdate_format = 'm/d/Y';
5767                                                                } else {
5768                                                                        $defaultdate_format = 'd/m/Y';
5769                                                                }
5770                                                        }
5771
5772                                                        if ( '' == $defaultdate_format ) {
5773                                                                $formate = ! empty( $form->form_css['date_format'] ) ? $form->form_css['date_format'] : $wp_format_date;
5774                                                                if ( $formate == 'MM/DD/YYYY' ) {
5775                                                                        $formate = 'm/d/Y';
5776                                                                } elseif ( $formate == 'MMM D, YYYY' ) {
5777                                                                        $formate = 'M d, Y';
5778                                                                } elseif ( $formate == 'MMMM D, YYYY' ) {
5779                                                                        $formate = 'F d, Y';
5780                                                                } elseif ( $formate == 'YYYY/MM/DD' ) {
5781                                                                        $formate = 'Y/m/d';
5782                                                                } elseif ( $formate == 'DD/MM/YYYY' ) {
5783                                                                        $formate = 'd/m/Y';
5784                                                                } elseif ( $formate == 'D.MM.YYYY' ) {
5785                                                                        $formate = 'd.m.Y';
5786                                                                } elseif ( $formate == 'D.MMMM.YY' ) {
5787                                                                        $formate = 'd.F.y';
5788                                                                } elseif ( $formate == 'YYYY.MM.D' ) {
5789                                                                        $formate = 'Y.m.d';
5790                                                                } elseif ( $formate == 'D. MMMM YYYY' ) {
5791                                                                        $formate = 'd. F Y';
5792                                                                }
5793
5794                                                                $defaultdate_format = $formate;
5795                                                        }
5796
5797                                                        $show_year_month_calendar = 'true';
5798
5799                                                        if ( isset( $field['show_year_month_calendar'] ) && $field['show_year_month_calendar'] < 1 ) {
5800                                                                $show_year_month_calendar = 'false';
5801                                                        }
5802
5803                                                        $show_time_calendar = 'true';
5804                                                        if ( @$field['show_time_calendar'] < 1 ) {
5805                                                                $show_time_calendar = 'false';
5806                                                        }
5807
5808                                                        $arf_show_min_current_date = 'true';
5809                                                        if ( @$field['arf_show_min_current_date'] < 1 ) {
5810                                                                $arf_show_min_current_date = 'false';
5811                                                        }
5812
5813                                                        if ( $arf_show_min_current_date == 'true' ) {
5814                                                                $field['start_date'] = current_time( 'd/m/Y' );
5815                                                        } else {
5816                                                                $field['start_date'] = $field['start_date'];
5817                                                        }
5818
5819                                                        $arf_show_max_current_date = 'true';
5820                                                        if ( @$field['arf_show_max_current_date'] < 1 ) {
5821                                                                $arf_show_max_current_date = 'false';
5822                                                        }
5823
5824                                                        if ( $arf_show_max_current_date == 'true' ) {
5825                                                                $field['end_date'] = current_time( 'd/m/Y' );
5826                                                        } else {
5827                                                                $field['end_date'] = $field['end_date'];
5828                                                        }
5829
5830                                                        $date = new DateTime();
5831
5832                                                        if ( $field['end_date'] == '' ) {
5833                                                                $field['end_date'] = '31/12/2050';
5834                                                        }
5835
5836                                                        if ( $field['start_date'] == '' ) {
5837                                                                $field['start_date'] = '01/01/1950';
5838                                                        }
5839
5840                                                        $end_date_temp = explode( '/', $field['end_date'] );
5841                                                        $date->setDate( $end_date_temp[2], $end_date_temp[1], $end_date_temp[0] );
5842                                                        $date1           = new DateTime();
5843                                                        $start_date_temp = explode( '/', $field['start_date'] );
5844                                                        $date1->setDate( $start_date_temp[2], $start_date_temp[1], $start_date_temp[0] );
5845
5846                                                        if ( $newarr['date_format'] == 'MM/DD/YYYY' || $newarr['date_format'] == 'MMMM D, YYYY' || $newarr['date_format'] == 'MMM D, YYYY' ) {
5847                                                                $start_date      = $date1->format( 'm/d/Y' );
5848                                                                $end_date        = $date->format( 'm/d/Y' );
5849                                                                $date_new_format = 'MM/DD/YYYY';
5850                                                        } elseif ( $newarr['date_format'] == 'DD/MM/YYYY' || $newarr['date_format'] == 'D MMMM, YYYY' || $newarr['date_format'] == 'D MMM, YYYY' ) {
5851                                                                $start_date      = $date1->format( 'd/m/Y' );
5852                                                                $end_date        = $date->format( 'd/m/Y' );
5853                                                                $date_new_format = 'DD-MM-YYYY';
5854                                                        } elseif ( $newarr['date_format'] == 'YYYY/MM/DD' || $newarr['date_format'] == 'YYYY, MMMM D' || $newarr['date_format'] == 'YYYY, MMM D' ) {
5855                                                                $start_date      = $date1->format( 'Y/m/d' );
5856                                                                $end_date        = $date->format( 'Y/m/d' );
5857                                                                $date_new_format = 'YYYY-MM-DD';
5858                                                        } else {
5859                                                                $start_date           = $date1->format( 'm/d/Y' );
5860                                                                $end_date             = $date->format( 'm/d/Y' );
5861                                                                $date_new_format      = 'MM/DD/YYYY';
5862                                                                $field['date_format'] = 'MMM D, YYYY';
5863                                                        }
5864
5865                                                        if ( $newarr['date_format'] == 'MM/DD/YYYY' ) {
5866                                                                $date_new_format_main = 'MM/DD/YYYY';
5867                                                        } elseif ( $newarr['date_format'] == 'DD/MM/YYYY' ) {
5868                                                                $date_new_format_main = 'DD/MM/YYYY';
5869                                                        } elseif ( $newarr['date_format'] == 'YYYY/MM/DD' ) {
5870                                                                $date_new_format_main = 'YYYY/MM/DD';
5871                                                        } elseif ( $newarr['date_format'] == 'MMM D, YYYY' ) {
5872                                                                $date_new_format_main = 'MMM D, YYYY';
5873                                                        } elseif ( $newarr['date_format'] == 'MM.D.YYYY' ) {
5874                                                                $date_new_format_main = 'MM.D.YYYY';
5875                                                        } elseif ( $newarr['date_format'] == 'MMMM.D.YY' ) {
5876                                                                $date_new_format_main = 'MMMM.D.YY';
5877                                                        } elseif ( $newarr['date_format'] == 'D.MM.YYYY' ) {
5878                                                                $date_new_format_main = 'D.MM.YYYY';
5879                                                        } elseif ( $newarr['date_format'] == 'D.MMMM.YY' ) {
5880                                                                $date_new_format_main = 'D.MMMM.YY';
5881                                                        } elseif ( $newarr['date_format'] == 'YYYY.MM.D' ) {
5882                                                                $date_new_format_main = 'YYYY.MM.D';
5883                                                        } elseif ( $newarr['date_format'] == 'D. MMMM YYYY' ) {
5884                                                                $date_new_format_main = 'D. MMMM YYYY';
5885                                                        } else {
5886                                                                $date_new_format_main = 'MMMM D, YYYY';
5887                                                        }
5888
5889                                                        if ( isset( $field['clock'] ) && $field['clock'] == '24' ) {
5890                                                                $format = 'H:mm';
5891                                                        } else {
5892                                                                $format = 'h:mm A';
5893                                                        }
5894
5895                                                        $off_days = array();
5896
5897                                                        if ( $field['off_days'] != '' ) {
5898                                                                $off_days = explode( ',', $field['off_days'] );
5899                                                        }
5900
5901                                                        $off_days_result = '';
5902                                                        $off_day_count   = '';
5903
5904                                                        $off_day_count1 = '';
5905                                                        foreach ( $off_days as $offday ) {
5906                                                                $off_day_count  .= ' day != ' . $offday . ' &&';
5907                                                                $off_day_count1 .= ' day == ' . $offday . ' ||';
5908                                                        }
5909
5910                                                        if ( $field['off_days'] != '' && $off_day_count != '' ) {
5911                                                                $off_day_count   = substr( $off_day_count, 0, -2 );
5912                                                                $off_days_result = ',beforeShowDay:function(date){ var day = date.getDay();return [(' . $off_day_count . ')]; }';
5913                                                        } else {
5914                                                                $off_days_result = ',beforeShowDay:function(date){ var day = date.getDay();return [true]; }';
5915                                                        }
5916                                                        $field['locale'] = ( $field['locale'] != '' ) ? $field['locale'] : 'en';
5917
5918                                                        $date_formate = $newarr['date_format'];
5919                                                        if ( $show_time_calendar == 'true' ) {
5920                                                                $field['clock']       = ( isset( $field['clock'] ) && $field['clock'] ) ? $field['clock'] : 'h:mm A';
5921                                                                $date_new_format_main = $date_new_format_main . ' ' . $format;
5922                                                                $date_formate        .= ' ' . $format;
5923                                                        }
5924
5925                                                        $arflite_form_all_footer_js .= 'setTimeout(function(){ jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").trigger("change");},200);';
5926
5927                                                        $datetimepicker_locale = ( in_array( $field['locale'], array( 'ms', 'zh-HK' ) ) ) ? '' : $field['locale'];
5928                                                        if ( $datetimepicker_locale == 'hy' ) {
5929                                                                $datetimepicker_locale = 'hy-am';
5930                                                        } elseif ( $datetimepicker_locale == 'no' ) {
5931                                                                $datetimepicker_locale = 'nb';
5932                                                        } elseif ( $datetimepicker_locale == 'tu' ) {
5933                                                                $datetimepicker_locale = 'tr';
5934                                                        }
5935
5936                                                        $step                        = ( isset( $field['step'] ) && $field['step'] ) ? $field['step'] : '30';
5937                                                        $arflite_form_all_footer_js .= 'var date_data_id = jQuery(this).attr("data-id"); jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").datetimepicker({';
5938
5939                                                        $cl_date_format = 'YYYY-MM-DD';
5940                                                        if ( $show_time_calendar == 'true' ) {
5941                                                                $arflite_form_all_footer_js .= 'stepping: ' . $step . ',';
5942                                                                $cl_date_format             .= ' ' . $format;
5943                                                        }
5944
5945                                                        if ( $field['currentdefaultdate'] == 1 ) {
5946                                                                $arflite_form_all_footer_js .= 'useCurrent:true,';
5947                                                        } else {
5948                                                                $arflite_form_all_footer_js .= 'useCurrent:false,';
5949                                                        }
5950
5951                                                        $arflite_form_all_footer_js .= 'format: "' . $date_formate . '",
5952                                locale: "' . $datetimepicker_locale . '",
5953                                minDate: moment("' . $start_date . ' 00:00 AM", "' . $date_new_format . '"),
5954                                maxDate: moment("' . $end_date . ' 11:59 PM", "' . $date_new_format . '"),
5955                                daysOfWeekDisabled: [' . $field['off_days'] . '],
5956                                keyBinds:"",';
5957                                                        if ( is_rtl() ) {
5958                                                                $arflite_form_all_footer_js .= 'widgetPositioning: {
5959                                        horizontal: "right",
5960                                        vertical: "auto"
5961                                    },';
5962                                                        }
5963                                                        $arflite_form_all_footer_js .= '});
5964
5965                            jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").on("dp.change", function(e) {
5966                                jQuery(this).trigger("change");
5967                                var act_val = jQuery(this).val();
5968                                if( "" == act_val ){
5969                                    jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").removeClass("arf_material_active");
5970                                    jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '_formatted").val(act_val).trigger("change");
5971                                } else {
5972                                            var formated_date = jQuery(this).data("DateTimePicker").viewDate();
5973                                            var formatted_date = formated_date._d;
5974                                            var data = moment(formatted_date).format("' . $cl_date_format . '");
5975                                    jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").addClass("arf_material_active");
5976                                            jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '_formatted").val(data).trigger("change");
5977                                        }
5978                            });
5979
5980                            jQuery(document).on("click",".arf_submit_btn",function(){
5981                                jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").trigger("blur");
5982                            });';
5983
5984                                                        $arflite_form_all_footer_js .= 'var date_settings={';
5985
5986                                                        $cl_date_format = 'YYYY-MM-DD';
5987                                                        if ( $show_time_calendar == 'true' ) {
5988                                                                $arflite_form_all_footer_js .= 'stepping: ' . $step . ',';
5989                                                                $cl_date_format             .= ' ' . $format;
5990                                                        }
5991
5992                                                        if ( $field['currentdefaultdate'] == 1 ) {
5993                                                                $arflite_form_all_footer_js .= 'useCurrent:true,';
5994                                                        } else {
5995                                                                $arflite_form_all_footer_js .= 'useCurrent:false,';
5996                                                        }
5997
5998                                                        $arflite_form_all_footer_js .= 'format: "' . $date_formate . '",
5999                                locale: "' . $datetimepicker_locale . '",
6000                                minDate: moment("' . $start_date . ' 00:00 AM", "' . $date_new_format . '"),
6001                                maxDate: moment("' . $end_date . ' 11:59 PM", "' . $date_new_format . '"),
6002                                daysOfWeekDisabled: [' . $field['off_days'] . '],
6003                                keyBinds:"",';
6004                                                        if ( is_rtl() ) {
6005                                                                $arflite_form_all_footer_js .= 'widgetPositioning: {
6006                                        horizontal: "right",
6007                                        vertical: "auto"
6008                                    },';
6009                                                        }
6010                                                        $arflite_form_all_footer_js .= '};';
6011
6012                                                        $set_default_date = '';
6013
6014                                                        if ( isset( $field['set_field_value'] ) ) {
6015                                                                $set_default_date = $arflitemainhelper->arfliteconvert_date( $field['set_field_value'], 'd/m/Y', $defaultdate_format );
6016
6017                                                                $field['default_blank'] = 1;
6018                                                                $set_default_date       = date( $wp_format_date, strtotime( $field['set_field_value'] ) );
6019
6020                                                        } else {
6021
6022                                                                if ( isset( $field['currentdefaultdate'] ) && $field['currentdefaultdate'] == 1 ) {
6023
6024                                                                        $set_default_date = date( $wp_format_date, current_time( 'timestamp' ) );
6025
6026                                                                } elseif ( isset( $field['selectdefaultdate'] ) && $field['selectdefaultdate'] != '' ) {
6027
6028                                                                        $set_default_date = $field['selectdefaultdate'];
6029                                                                }
6030                                                        }
6031
6032                                                        $data_off_days = '';
6033                                                        if ( ! empty( $off_days ) ) {
6034                                                                $data_off_days = "data-off-days='" . json_encode( $off_days ) . "'";
6035                                                        }
6036
6037                                                        if ( 'material' == $inputStyle ) {
6038                                                                $material_standard_cls = '';
6039                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
6040                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
6041                                                                }
6042                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
6043                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
6044                                                                }
6045                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6046                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
6047                                                                }
6048                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6049                                                                        $material_standard_cls .= ' arf_both_icons ';
6050                                                                }
6051                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
6052
6053                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
6054                                                        }
6055
6056                                                        $return_string .= '<input type="text" data-date-format="' . $date_formate . '" data-start-date="' . $start_date . ' 00:00 AM" data-cl-format="' . $cl_date_format . '" data-date-new-format="' . $date_new_format . '" data-end-date="' . $end_date . ' 11:59 PM" data-default-date="' . $set_default_date . '" id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '" ' . $data_off_days . ' ';
6057
6058                                                        $return_string .= $arf_input_field_html;
6059
6060                                                        $return_string .= " data-name='" . $field_name . "'";
6061                                                        $return_string .= " data-format='" . $date_formate . "'";
6062
6063                                                        $date_field_options = $this->arflite_html_entity_decode( $field['field_options'] );
6064
6065                                                        $return_string .= ' data-field-options="' . htmlspecialchars( json_encode( $date_field_options ) ) . '"';
6066
6067                                                        $is_default_blank = 1;
6068
6069                                                        $placeholdertext_date = $field['placeholdertext'];
6070
6071                                                        if ( isset( $placeholdertext_date ) && $placeholdertext_date != '' ) {
6072                                                                $return_string .= ' placeholder="' . esc_attr( $placeholdertext_date ) . '" ';
6073                                                        }
6074                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
6075                                                                $return_string .= 'readonly="readonly" ';
6076                                                        }
6077                                                        if ( $field['currentdefaultdate'] == 1 ) {
6078                                                                if ( $datetimepicker_locale != 'en' ) {
6079                                                                        $return_string .= ' data-default-value="' . $arflitefieldhelper->arflite_get_date_with_locale( $set_default_date, $defaultdate_format, $datetimepicker_locale ) . '" value="' . $set_default_date . '"';
6080                                                                } else {
6081                                                                        $return_string .= ' data-default-value="' . $set_default_date . '" value="' . $set_default_date . '"';
6082                                                                }
6083                                                        } elseif ( $set_default_date != '' ) {
6084                                                                if ( $datetimepicker_locale != 'en' ) {
6085                                                                        $return_string .= ' data-default-value="' . $set_default_date . '" value="' . $set_default_date . '"';
6086                                                                } else {
6087                                                                        $return_string .= ' data-default-value="' . $set_default_date . '" value="' . $set_default_date . '"';
6088                                                                }
6089                                                        }
6090
6091                                                        if ( isset( $field['required'] ) && $field['required'] ) {
6092                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
6093                                                        }
6094
6095                                                        $return_string .= ' />';
6096
6097                                                        $return_string .= '<input type="hidden" name="' . $field_name . '" id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '_formatted"';
6098                                                        if ( $field['currentdefaultdate'] == 1 ) {
6099                                                                $return_string .= ' value="' . $set_default_date . '"';
6100                                                        } elseif ( isset( $field['selectdefaultdate'] ) && $field['selectdefaultdate'] != '' ) {
6101                                                                $return_string .= ' value="' . $field['selectdefaultdate'] . '"';
6102                                                        }
6103                                                        $return_string .= ' />';
6104
6105                                                        if ( 'material' == $inputStyle ) {
6106                                                                $return_string         .= '<div class="arf_material_standard">';
6107                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
6108                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
6109                                                                                $return_string .= $arf_main_label;
6110                                                                        $return_string     .= '</div>';
6111                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
6112                                                                $return_string         .= '</div>';
6113                                                                $return_string         .= '</div>';
6114                                                        }
6115
6116                                                        $return_string .= $suffix;
6117                                                        $return_string .= $field_standard_tooltip;
6118                                                }
6119                                                $return_string .= $field_description;
6120                                                $return_string .= '</div>';
6121                                                $return_string .= '</div>';
6122                                                break;
6123                                        case 'time':
6124                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
6125
6126                                                if ( $inputStyle != 'material' ) {
6127                                                        $return_string .= $arf_main_label;
6128                                                }
6129
6130                                                $return_string .= '<div class="sltstandard_time controls arf_time_main_controls arf_cal_theme_' . $newarr['arfcalthemecss'] . ' ' . $field_tooltip_class . '" ' . $field_tooltip . '>';
6131
6132                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
6133                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
6134                                                } else {
6135
6136                                                        $arflite_form_all_footer_js .= 'setTimeout(function(){
6137                                jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").trigger("change");
6138                                jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").attr("data-value",jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").val());
6139                            },200);';
6140
6141                                                        $field['clock']              = ( isset( $field['clock'] ) && $field['clock'] == 24 ) ? 'H:mm' : 'h:mm A';
6142                                                        $field['step']               = ( isset( $field['step'] ) && $field['step'] ) ? $field['step'] : '30';
6143                                                        $field['default_hour']       = ( isset( $field['default_hour'] ) && $field['default_hour'] != '' ) ? $field['default_hour'] : '00';
6144                                                        $field['default_minutes']    = ( isset( $field['default_minutes'] ) && $field['default_minutes'] != '' ) ? $field['default_minutes'] : '00';
6145                                                        $arflite_form_all_footer_js .= 'jQuery("#field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '").datetimepicker({
6146                                format: "' . $field['clock'] . '",
6147                                stepping: ' . $field['step'] . ',';
6148                                                        if ( is_rtl() ) {
6149                                                                $arflite_form_all_footer_js .= 'widgetPositioning: {
6150                                            horizontal: "right",
6151                                            vertical: "auto"
6152                                        },';
6153                                                        }
6154                                                        $arflite_form_all_footer_js .= '});';
6155
6156                                                        $return_string .= $prefix;
6157
6158                                                        if ( 'material' == $inputStyle ) {
6159                                                                $material_standard_cls = '';
6160                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
6161                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
6162                                                                }
6163                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
6164                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
6165                                                                }
6166                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6167                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
6168                                                                }
6169                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6170                                                                        $material_standard_cls .= ' arf_both_icons ';
6171                                                                }
6172                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
6173
6174                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
6175                                                        }
6176
6177                                                        $default_value = $field['default_value'];
6178                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
6179                                                                $default_value = $field['set_field_value'];
6180                                                        }
6181                                                        $return_string .= '<input type="text" name="' . $field_name . '" class="arf_timepciker" id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '" value="' . $field['default_value'] . '" ';
6182
6183                                                        $time_field_options = $this->arflite_html_entity_decode( $field['field_options'] );
6184
6185                                                        $return_string .= ' data-field-options="' . htmlspecialchars( json_encode( $time_field_options ) ) . '"';
6186
6187                                                        if ( isset( $field['required'] ) && $field['required'] ) {
6188                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
6189                                                        }
6190                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
6191                                                                $return_string .= 'readonly="readonly" ';
6192                                                        }
6193                                                        if ( isset( $field['placeholdertext'] ) && '' != $field['placeholdertext'] ) {
6194                                                                $return_string .= 'placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
6195                                                        }
6196                                                        $date_field_options = $this->arflite_html_entity_decode( $field['field_options'] );
6197
6198                                                        $return_string .= ' data-field-options="' . htmlspecialchars( json_encode( $date_field_options ) ) . '"';
6199                                                        $return_string .= '/>';
6200
6201                                                        if ( 'material' == $inputStyle ) {
6202                                                                $return_string         .= '<div class="arf_material_standard">';
6203                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
6204                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
6205                                                                                $return_string .= $arf_main_label;
6206                                                                        $return_string     .= '</div>';
6207                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
6208                                                                $return_string         .= '</div>';
6209                                                                $return_string         .= '</div>';
6210                                                        }
6211
6212                                                        $return_string .= $suffix;
6213
6214                                                        $return_string .= $field_standard_tooltip;
6215                                                }
6216                                                $return_string .= $field_description;
6217                                                $return_string .= '</div>';
6218                                                $return_string .= '</div>';
6219                                                break;
6220                                        case 'image':
6221                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '"  data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
6222
6223                                                if ( $inputStyle != 'material' ) {
6224                                                        $return_string .= $arf_main_label;
6225                                                }
6226
6227                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
6228
6229                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
6230
6231                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
6232                                                } else {
6233                                                        $return_string .= $prefix;
6234
6235                                                        if ( 'material' == $inputStyle ) {
6236                                                                $material_standard_cls = '';
6237                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
6238                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
6239                                                                }
6240                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
6241                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
6242                                                                }
6243                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6244                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
6245                                                                }
6246                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6247                                                                        $material_standard_cls .= ' arf_both_icons ';
6248                                                                }
6249                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
6250
6251                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
6252                                                        }
6253
6254                                                        $return_string .= '<input type="url" id="field_' . esc_attr( $field['field_key'] . '_' . $arflite_data_uniq_id ) . '" name="' . esc_attr( $field_name ) . '" ';
6255                                                        if ( isset( $field['set_field_value'] ) ) {
6256                                                                $return_string .= ' value="' . esc_attr( $field['set_field_value'] ) . '"';
6257                                                        }
6258
6259                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
6260                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
6261                                                        }
6262                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
6263                                                                $return_string .= 'readonly="readonly" ';
6264                                                        }
6265
6266                                                        $default_value = $field['default_value'];
6267
6268                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
6269
6270                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
6271                                                                $default_value = $field['set_field_value'];
6272                                                        }
6273
6274                                                        if ( $default_value != '' ) {
6275                                                                $return_string .= " value='{$default_value}'";
6276                                                        }
6277
6278                                                        $return_string .= $arf_input_field_html;
6279
6280                                                        if ( isset( $field['required'] ) && $field['required'] ) {
6281                                                                $return_string .= 'data-validation-required-message="' . esc_attr( $field['blank'] ) . '"';
6282                                                        }
6283                                                        $return_string .= '/>';
6284
6285                                                        if ( 'material' == $inputStyle ) {
6286                                                                $return_string         .= '<div class="arf_material_standard">';
6287                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
6288                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
6289                                                                                $return_string .= $arf_main_label;
6290                                                                        $return_string     .= '</div>';
6291                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
6292                                                                $return_string         .= '</div>';
6293                                                                $return_string         .= '</div>';
6294                                                        }
6295
6296                                                        $return_string .= $suffix;
6297                                                        $return_string .= $field_standard_tooltip;
6298                                                }
6299                                                $return_string .= $field_description;
6300                                                $return_string .= '</div>';
6301                                                $return_string .= '</div>';
6302                                                break;
6303                                        case 'hidden':
6304                                                $arfaction = ( isset( $_GET ) && isset( $_GET['arfaction'] ) ) ? 'arfaction' : 'action';
6305
6306                                                if ( is_admin() && ( ! isset( $_GET[ $arfaction ] ) || sanitize_text_field( $_GET[ $arfaction ] ) != 'new' ) ) {
6307
6308                                                        global $is_divibuilder ,$is_fusionbuilder;
6309                                                        if($is_divibuilder == false && $is_fusionbuilder == false)
6310                                                        {
6311                                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield arfmainformfield top_container arf_field_' . $field['id'] . ']">';
6312                                                                $return_string .= '<label class="arf_main_label">' . $field['name'] . ':</label>';
6313                                                                $return_string .= $field['value'];
6314                                                                $return_string .= '</div>';
6315                                                        }
6316                                                }
6317
6318                                                if ( ! is_admin() && apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
6319
6320                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
6321                                                } else {
6322
6323                                                        if ( isset( $field['set_field_value'] ) ) {
6324                                                                $return_string .= '<input type="hidden" id="field_' . $field['field_key'] . '" name="' . $field_name . '" value="' . esc_attr( $field['set_field_value'] ) . '" />';
6325                                                        } else {
6326                                                                if ( isset( $field['value'] ) && is_array( $field['value'] ) ) {
6327                                                                        foreach ( $field['value'] as $checked ) {
6328                                                                                $checked        = apply_filters( 'arflitehiddenvalue', $checked, $field );
6329                                                                                $return_string .= '<input type="hidden" name="' . $field_name . '[]" value="' . esc_attr( $checked ) . '" />';
6330                                                                        }
6331                                                                } else {
6332                                                                        $hidden_field_value = isset( $field['default_value'] ) ? $field['default_value'] : '';
6333                                                                        $arf_current_user   = wp_get_current_user();
6334
6335                                                                        if ( preg_match( '/\[ARF_current_user_id\]/', $hidden_field_value ) ) {
6336                                                                                $hidden_field_value = str_replace( '[ARF_current_user_id]', $arf_current_user->ID, $hidden_field_value );
6337                                                                        }
6338                                                                        if ( preg_match( '/\[ARF_current_user_name\]/', $hidden_field_value ) ) {
6339                                                                                $hidden_field_value = str_replace( '[ARF_current_user_name]', $arf_current_user->user_login, $hidden_field_value );
6340                                                                        }
6341                                                                        if ( preg_match( '/\[ARF_current_user_email\]/', $hidden_field_value ) ) {
6342                                                                                $hidden_field_value = str_replace( '[ARF_current_user_email]', $arf_current_user->user_email, $hidden_field_value );
6343                                                                        }
6344                                                                        if ( preg_match( '/\[ARF_current_date\]/', $hidden_field_value ) ) {
6345                                                                                $wp_format_date     = get_option( 'date_format' );
6346                                                                                $arf_current_date   = date( $wp_format_date, current_time( 'timestamp' ) );
6347                                                                                $hidden_field_value = str_replace( '[ARF_current_date]', $arf_current_date, $hidden_field_value );
6348                                                                        }
6349
6350                                                                        $hidden_field_value = apply_filters( 'arflite_replace_default_value_shortcode', $hidden_field_value, $field, $form );
6351
6352                                                                        $return_string .= '<input type="hidden" id="field_' . $field['field_key'] . '" name="' . $field_name . '" value="' . esc_attr( $hidden_field_value ) . '" />';
6353                                                                }
6354                                                        }
6355                                                }
6356                                                break;
6357                                        case 'html':
6358                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '" data-field-type="html" data-parent_field="' . $parent_field_id . '" >';
6359                                                $return_string .= '<div class="arf_htmlfield_control">';
6360
6361                                                $html_field_description = $this->arflite_html_entity_decode( $field['description'] );
6362
6363                                                $return_string .= do_shortcode( $html_field_description );
6364
6365                                                $return_string .= '</div>';
6366                                                $return_string .= '</div>';
6367                                                break;
6368                                        case 'email':
6369                                        case 'confirm_email':
6370                                                $return_string .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '" data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
6371
6372                                                if ( $inputStyle != 'material' ) {
6373                                                        $return_string .= $arf_main_label;
6374                                                }
6375
6376                                                $return_string .= '<div class="controls' . $field_tooltip_class . '" ' . $field_tooltip . ' >';
6377
6378                                                if ( apply_filters( 'arflite_check_for_draw_outside', false, $field ) ) {
6379
6380                                                        $return_string = apply_filters( 'arflite_drawthisfieldfromoutside', $return_string, $field, $arflite_data_uniq_id );
6381                                                } else {
6382                                                        $return_string .= $prefix;
6383
6384                                                        $confirm_email_field = '0';
6385                                                        if ( $field['type'] == 'email' && isset( $field['confirm_email_arr'][ $field['id'] ] ) && $field['confirm_email_arr'][ $field['id'] ] != '' ) {
6386                                                                $confirm_email_field = $field['confirm_email_arr'][ $field['id'] ];
6387                                                        }
6388                                                        if ( $field['type'] == 'confirm_email' ) {
6389                                                                $field['value']           = $field['confirm_email_placeholder'];
6390                                                                $field['placeholdertext'] = $field['confirm_email_placeholder'];
6391                                                        }
6392
6393                                                        if ( 'material' == $inputStyle ) {
6394                                                                $material_standard_cls = '';
6395                                                                if ( ! empty( $field['enable_arf_prefix'] ) || ! empty( $field['enable_arf_suffix'] ) ) {
6396                                                                        $material_standard_cls = 'arf_material_theme_container_with_icons';
6397                                                                }
6398                                                                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
6399                                                                        $material_standard_cls .= ' arf_only_leading_icon ';
6400                                                                }
6401                                                                if ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6402                                                                        $material_standard_cls .= ' arf_only_trailing_icon ';
6403                                                                }
6404                                                                if ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
6405                                                                        $material_standard_cls .= ' arf_both_icons ';
6406                                                                }
6407                                                                $return_string .= '<div class="arf_material_theme_container ' . $material_standard_cls . ' ">';
6408
6409                                                                $return_string .= $this->arflite_prefix_suffix_for_material( $field );
6410                                                        }
6411
6412                                                        $return_string .= '<input type="text" id="field_' . $field['field_key'] . '_' . $arflite_data_uniq_id . '" name="' . $field_name . '" ';
6413
6414                                                        if ( isset( $field['placeholdertext'] ) && $field['placeholdertext'] != '' ) {
6415                                                                $return_string .= ' placeholder="' . esc_attr( $field['placeholdertext'] ) . '" ';
6416                                                        }
6417                                                        if ( isset( $field['arf_enable_readonly'] ) && $field['arf_enable_readonly'] == 1 ) {
6418                                                                $return_string .= 'readonly="readonly" ';
6419                                                        }
6420
6421                                                        $default_value = $field['default_value'];
6422
6423                                                        if ( isset( $arf_arr_preset_data ) && count( $arf_arr_preset_data ) > 0 && isset( $arf_arr_preset_data[ $field['id'] ] ) ) {
6424
6425                                                                $default_value = $arf_arr_preset_data[ $field['id'] ];
6426                                                        }
6427
6428                                                        $default_value = apply_filters( 'arflite_replace_default_value_shortcode', $default_value, $field, $form );
6429
6430                                                        if ( isset( $field['set_field_value'] ) && $field['set_field_value'] != '' ) {
6431                                                                $default_value = $field['set_field_value'];
6432                                                        }
6433
6434                                                        if ( $default_value != '' ) {
6435                                                                $return_string .= " value='{$default_value}'";
6436                                                        }
6437
6438                                                        $return_string .= $arf_input_field_html;
6439
6440                                                        if ( isset( $field['required'] ) && $field['required'] ) {
6441                                                                $return_string .= ' data-validation-required-message="' . esc_attr( $field['blank'] ) . '" ';
6442                                                        }
6443
6444                                                        $return_string .= ' data-validation-regex-regex="[\p{L}0-9._-]+@[\p{L}0-9.-]+\.[\p{L}]+" data-validation-regex-message="' . esc_attr( $field['invalid'] ) . '" ';
6445
6446                                                        if ( $field['type'] == 'confirm_email' ) {
6447                                                                $return_string .= ' data-validation-match-match="item_meta[' . $field['confirm_email_field'] . ']" data-cpass="1" data-validation-match-message="' . esc_attr( $field['invalid'] ) . '"';
6448                                                        }
6449
6450                                                        $return_string .= ' />';
6451
6452                                                        if ( 'material' == $inputStyle ) {
6453                                                                $return_string         .= '<div class="arf_material_standard">';
6454                                                                        $return_string     .= '<div class="arf_material_theme_prefix"></div>';
6455                                                                        $return_string     .= '<div class="arf_material_theme_notch ' . $arf_material_standard_cls . '">';
6456                                                                                $return_string .= $arf_main_label;
6457                                                                        $return_string     .= '</div>';
6458                                                                        $return_string     .= '<div class="arf_material_theme_suffix"></div>';
6459                                                                $return_string         .= '</div>';
6460                                                                $return_string         .= '</div>';
6461                                                        }
6462
6463                                                        $return_string .= $suffix;
6464
6465                                                        $return_string .= $field_standard_tooltip;
6466                                                }
6467                                                $return_string .= $field_description;
6468                                                $return_string .= '</div>';
6469                                                $return_string .= '</div>';
6470                                                break;
6471                                        default:
6472                                                if ( apply_filters( 'arflite_wrap_input_field', true, $field['type'] ) ) {
6473                                                        $arf_material_input_cls = apply_filters( 'arflite_add_material_input_cls', $material_input_cls, $field['type'], $inputStyle );
6474                                                        $return_string         .= '<div id="arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container" class="arfformfield control-group arfmainformfield ' . $arf_material_input_cls . ' ' . $required_class . ' ' . $class_position . ' ' . $error_class . ' arf_field_' . $field['id'] . '" data-field-type="' . $field['type'] . '" data-parent_field="' . $parent_field_id . '">';
6475                                                        if ( $inputStyle != 'material' ) {
6476                                                                $return_string .= $arf_main_label;
6477                                                        }
6478                                                        if ( $inputStyle != 'material' ) {
6479                                                                $field_tooltip = $field_standard_tooltip;
6480                                                        }
6481
6482                                                        $return_string = apply_filters( 'arflite_form_fields', $return_string, $form, $field_name, $arflite_data_uniq_id, $field, $field_tooltip, $field_description, $OFData, $inputStyle, $arf_main_label );
6483
6484                                                        $return_string .= '</div>';
6485                                                } else {
6486                                                        $return_string = apply_filters( 'arflite_form_fields', $return_string, $form, $field_name, $arflite_data_uniq_id, $field, $field_tooltip, $field_description, $OFData, $inputStyle, $arf_main_label );
6487                                                }
6488                                }
6489
6490                                global $arflite_column_classes;
6491
6492                                if ( ! isset( $field['inner_class'] ) ) {
6493                                        $field['inner_class'] = 'arf_1col';
6494                                }
6495
6496                                if ( $field['type'] == 'confirm_email' ) {
6497                                        $field['inner_class'] = $field['confirm_email_inner_classes'];
6498                                }
6499
6500                                if ( $field['inner_class'] == 'arf_1col' || $field['inner_class'] == 'arf_2col' || $field['inner_class'] == 'arf_3col' || $field['inner_class'] == 'arf_4col' || $field['inner_class'] == 'arf_5col' || $field['inner_class'] == 'arf_6col' ) {
6501                                                $return_string .= '<div class="arflite_clear_both"></div>';
6502                                } elseif ( $field['inner_class'] == 'arf21colclass' || $field['inner_class'] == 'arf31colclass' || $field['inner_class'] == 'arf41colclass' || $field['inner_class'] == 'arf42colclass' || $field['inner_class'] == 'arf43colclass' || $field['inner_class'] == 'arf51colclass' || $field['inner_class'] == 'arf52colclass' || $field['inner_class'] == 'arf53colclass' || $field['inner_class'] == 'arf54colclass' || $field['inner_class'] == 'arf61colclass' || $field['inner_class'] == 'arf62colclass' || $field['inner_class'] == 'arf63colclass' || $field['inner_class'] == 'arf64colclass' || $field['inner_class'] == 'arf65colclass' ) {
6503                                        $return_string .= '<div class="arf_half_middle"></div>';
6504                                } elseif ( $field['inner_class'] == 'arf_23col' ) {
6505                                        $return_string .= '<div class="arf_third_middle"></div>';
6506                                }
6507                        } else {
6508                                $field_ext_extract       = explode( '|', $field );
6509                                $field_level_class_blank = '';
6510
6511                                $arf_classes_blank_0  = $field_ext_extract[0];
6512                                $arf_next_div_classes = '';
6513
6514                                if ( $arf_classes_blank_0 == 'arf21colclass' ) {
6515                                         $arf_classes_blank       = 'frm_first_half';
6516                                         $arf_next_div_classes    = 'arf_half_middle';
6517                                         $field_level_class_blank = 'arf_2';
6518                                } elseif ( $arf_classes_blank_0 == 'arf_2col' ) {
6519                                         $arf_classes_blank       = 'frm_last_half';
6520                                         $field_level_class_blank = 'arf_2';
6521
6522                                }
6523                                if ( $arf_classes_blank_0 == 'arf31colclass' ) {
6524                                        $arf_classes_blank       = 'frm_first_third';
6525                                        $arf_next_div_classes    = 'arf_half_middle';
6526                                        $field_level_class_blank = 'arf_3';
6527                                } elseif ( $arf_classes_blank_0 == 'arf_23col' ) {
6528                                        $arf_classes_blank       = 'frm_third';
6529                                        $arf_next_div_classes    = 'arf_half_middle';
6530                                        $field_level_class_blank = 'arf_3';
6531                                } elseif ( $arf_classes_blank_0 == 'arf_3col' ) {
6532                                        $arf_classes_blank       = 'frm_last_third';
6533                                        $field_level_class_blank = 'arf_3';
6534                                } elseif ( $arf_classes_blank_0 == 'arf41colclass' ) {
6535                                        $arf_classes_blank       = 'frm_first_fourth';
6536                                        $arf_next_div_classes    = 'arf_half_middle';
6537                                        $field_level_class_blank = 'arf_4';
6538                                } elseif ( $arf_classes_blank_0 == 'arf42colclass' || $arf_classes_blank_0 == 'arf43colclass' ) {
6539                                        $arf_classes_blank       = 'frm_fourth';
6540                                        $arf_next_div_classes    = 'arf_half_middle';
6541                                        $field_level_class_blank = 'arf_4';
6542                                } elseif ( $arf_classes_blank_0 == 'arf_4col' ) {
6543                                        $arf_classes_blank       = 'frm_last_fourth';
6544                                        $field_level_class_blank = 'arf_4';
6545                                } elseif ( $arf_classes_blank_0 == 'arf51colclass' ) {
6546                                        $arf_classes_blank       = 'frm_first_fifth';
6547                                        $arf_next_div_classes    = 'arf_half_middle';
6548                                        $field_level_class_blank = 'arf_5';
6549                                } elseif ( $arf_classes_blank_0 == 'arf52colclass' || $arf_classes_blank_0 == 'arf53colclass' || $arf_classes_blank_0 == 'arf54colclass' ) {
6550                                        $arf_classes_blank       = 'frm_fifth';
6551                                        $arf_next_div_classes    = 'arf_half_middle';
6552                                        $field_level_class_blank = 'arf_5';
6553                                } elseif ( $arf_classes_blank_0 == 'arf_5col' ) {
6554                                        $arf_classes_blank       = 'frm_last_fifth';
6555                                        $field_level_class_blank = 'arf_5';
6556                                } elseif ( $arf_classes_blank_0 == 'arf61colclass' ) {
6557                                        $arf_classes_blank       = 'frm_first_six';
6558                                        $arf_next_div_classes    = 'arf_half_middle';
6559                                        $field_level_class_blank = 'arf_6';
6560                                } elseif ( $arf_classes_blank_0 == 'arf62colclass' || $arf_classes_blank_0 == 'arf63colclass' || $arf_classes_blank_0 == 'arf64colclass' || $arf_classes_blank_0 == 'arf65colclass' ) {
6561                                        $arf_classes_blank       = 'frm_six';
6562                                        $arf_next_div_classes    = 'arf_half_middle';
6563                                        $field_level_class_blank = 'arf_6';
6564                                } elseif ( $arf_classes_blank_0 == 'arf_6col' ) {
6565                                        $arf_classes_blank       = 'frm_last_six';
6566                                        $field_level_class_blank = 'arf_6';
6567                                }
6568
6569                                $calculte_width = @$field_resize_width[ $arf_field_front_counter ] - ( isset( $arf_column_field_custom_width[ $field_level_class_blank ] ) ? @$arf_column_field_custom_width[ $field_level_class_blank ] : '0' );
6570
6571                                $return_string                   .= '<div data-field-counter="' . $form_data->id . '_' . $arf_field_front_counter . '_' . $arflite_data_uniq_id . '" class="arfformfield control-group arfmainformfield arfformfield arfemptyfield ' . $arf_classes_blank . '"></div>';
6572                                $arflite_form_all_footer_css     .= '.arflite_main_div_' . $form_data->id . ' .arfemptyfield.arfformfield.' . $arf_classes_blank . "[data-field-counter='" . $form_data->id . '_' . $arf_field_front_counter . '_' . $arflite_data_uniq_id . "']{";
6573                                        $arflite_form_all_footer_css .= 'width:' . $calculte_width . '%;';
6574                                $arflite_form_all_footer_css     .= '}';
6575
6576                                if ( $arf_next_div_classes == '' ) {
6577                                        $return_string .= '<div class="arflite_clear_both"></div>';
6578                                } else {
6579                                        $return_string .= '<div class="' . $arf_next_div_classes . '"></div>';
6580                                }
6581                        }
6582
6583                        do_action( 'arfliteafterdisplayfield', $field );
6584                        $arf_field_front_counter++;
6585                }
6586
6587                return $return_string;
6588        }
6589
6590        function arflite_field_wise_js_css() {
6591
6592                global $arformsmain;
6593
6594                if( $arformsmain->arforms_is_pro_active() ){
6595                        global $arformcontroller;
6596                        $arflite_field_wise_js_css = $arformcontroller->arf_field_wise_js_css();
6597                } else {       
6598                        $arflite_field_wise_js_css = apply_filters(
6599                                'arflite_field_wise_js_css',
6600                                array(
6601                                        'dropdown'    => array(
6602                                                'title'  => addslashes( esc_html__( 'Drop Down', 'arforms-form-builder' ) ),
6603                                                'handle' => array(
6604                                                        'js'  => array( 'arformslite_selectpicker' ),
6605                                                        'css' => array( 'arformslite_selectpicker' ),
6606                                                ),
6607                                        ),
6608                                        'date_time'   => array(
6609                                                'title'  => __( 'Datepicker / Timepicker', 'arforms-form-builder' ),
6610                                                'handle' => array(
6611                                                        'js'  => array( 'bootstrap-moment-with-locales', 'bootstrap-datetimepicker' ),
6612                                                        'css' => array( 'bootstrap-datetimepicker' ),
6613                                                ),
6614                                        ),
6615                                        'fontawesome' => array(
6616                                                'title'  => __( 'Font Awesome', 'arforms-form-builder' ),
6617                                                'handle' => array(
6618                                                        'css' => array( 'arflite-font-awesome' ),
6619                                                ),
6620                                        ),
6621                                        'mask_input'  => array(
6622                                                'title'  => __( 'Mask Input', 'arforms-form-builder' ),
6623                                                'handle' => array(
6624                                                        'js' => array( 'bootstrap-inputmask', 'jquery-maskedinput', 'intltelinput', 'arformslite_phone_utils' ),
6625                                                ),
6626                                        ),
6627                                        'tooltip'     => array(
6628                                                'title'  => __( 'Tooltip', 'arforms-form-builder' ),
6629                                                'handle' => array(
6630                                                        'js'  => array( 'tipso' ),
6631                                                        'css' => array( 'tipso' ),
6632                                                ),
6633                                        ),
6634                                        'material'    => array(
6635                                                'title'  => __( 'Material', 'arforms-form-builder' ),
6636                                                'handle' => array(
6637                                                        'css' => array( 'materialize' ),
6638                                                        'js'  => array( 'materialize' ),
6639                                                ),
6640                                        ),
6641                                )
6642                        );
6643                }
6644                return $arflite_field_wise_js_css;
6645        }
6646
6647        function arflite_get_form_style( $id, $arflite_data_uniq_id = '', $type = '', $position = '', $bgcolor = '', $txtcolor = '', $btn_angle = '', $modal_bgcolor = '', $overlay_value = '', $is_fullscrn = '', $inactive_min = '', $modal_effect = '' ) {
6648
6649                global $arflite_loaded_form_unique_id_array, $arflitefieldhelper, $arfliterecordhelper, $arfliteform, $arflitemainhelper, $arfliteformcontroller,$arflitesettingcontroller;
6650                $return_css = '';
6651                if ( $arflite_data_uniq_id == '' ) {
6652                        $arflite_data_uniq_id = rand( 1, 99999 );
6653
6654                        if ( empty( $arflite_data_uniq_id ) || $arflite_data_uniq_id == '' ) {
6655                                $arflite_data_uniq_id = $id;
6656                        }
6657
6658                        if ( $type != '' ) {
6659                                if ( $position != '' ) {
6660                                        $arflite_loaded_form_unique_id_array[ $id ]['type'][ $type ][ $position ][] = $arflite_data_uniq_id;
6661                                } else {
6662                                        $arflite_loaded_form_unique_id_array[ $id ]['type'][ $type ][] = $arflite_data_uniq_id;
6663                                }
6664                        } else {
6665                                $arflite_loaded_form_unique_id_array[ $id ]['normal'][] = $arflite_data_uniq_id;
6666                        }
6667                }
6668
6669                $form = $arfliteform->arflitegetOne( (int) $id );
6670
6671                if ( ! isset( $form ) ) {
6672                        return;
6673                }
6674
6675                $form->options = maybe_unserialize( $form->options );
6676                $css_data_arr  = $form->form_css;
6677
6678                $arr = maybe_unserialize( $css_data_arr );
6679
6680                $newarr      = array();
6681                $newarr      = $arr;
6682                $return_css .= '<style type="text/css" id="' . $id . '" data-form-unique-id="' . $arflite_data_uniq_id . '" >';
6683
6684                $form->form_css = maybe_unserialize( $form->form_css );
6685
6686                $loaded_field = isset( $form->options['arf_loaded_field'] ) ? $form->options['arf_loaded_field'] : array();
6687               
6688                global $arformsmain;
6689        $arf_global_css = !empty( get_option('arf_global_css') ) ? stripslashes_deep(get_option('arf_global_css')) : stripslashes_deep($arformsmain->arforms_get_settings('arf_global_css','general_settings'));
6690        $return_css .= $arf_global_css;
6691
6692                $fields = $arflitefieldhelper->arflite_get_form_fields_tmp( false, $form->id, false, 0 );
6693
6694                $return_css                         .= stripslashes_deep( get_option( 'arflite_global_css' ) );
6695                $form->options['arf_form_other_css'] = $arfliteformcontroller->arflitebr2nl( $form->options['arf_form_other_css'] );
6696                $return_css                         .= $arflitemainhelper->arflite_esc_textarea( $form->options['arf_form_other_css'] );
6697
6698                $newFields = array();
6699
6700                foreach ( $fields as $k => $f ) {
6701
6702                        if ( is_array( $f ) ) {
6703                                foreach ( $f as $n => $i ) {
6704                                        $newFields[ $k ][ $n ] = $i;
6705                                }
6706                        } elseif ( is_object( $f ) ) {
6707                                $fi = $this->arfliteObjtoArray( $f );
6708                                foreach ( $fi as $n => $i ) {
6709                                        $newFields[ $k ][ $n ] = $i;
6710                                }
6711                        } else {
6712                                $newFields[ $k ] = $f;
6713                        }
6714                }
6715                unset( $k );
6716                unset( $f );
6717                unset( $n );
6718                unset( $i );
6719                unset( $fi );
6720
6721                $values['fields'] = $this->arfliteObjtoArray( $newFields );
6722
6723                $custom_css_array_form = array(
6724                        'arf_form_outer_wrapper'   => '.arf_form_outer_wrapper|.arfmodal',
6725                        'arf_form_inner_wrapper'   => '.arf_fieldset|.arfmodal',
6726                        'arf_form_title'           => '.formtitle_style',
6727                        'arf_form_description'     => 'div.formdescription_style',
6728                        'arf_form_element_wrapper' => '.arfformfield',
6729                        'arf_form_element_label'   => 'label.arf_main_label',
6730                        'arf_form_elements'        => '.controls',
6731                        'arf_submit_outer_wrapper' => 'div.arfsubmitbutton',
6732                        'arf_form_submit_button'   => '.arfsubmitbutton button.arf_submit_btn',
6733                        'arf_form_success_message' => '#arf_message_success',
6734                        'arf_form_error_message'   => '.control-group.arf_error .help-block|.control-group.arf_warning .help-block|.control-group.arf_warning .help-inline|.control-group.arf_warning .control-label|.control-group.arf_error .popover|.control-group.arf_warning .popover',
6735                );
6736
6737                foreach ( $custom_css_array_form as $custom_css_block_form => $custom_css_classes_form ) {
6738
6739                        if ( isset( $form->options[ $custom_css_block_form ] ) && $form->options[ $custom_css_block_form ] != '' ) {
6740
6741                                $form->options[ $custom_css_block_form ] = $arfliteformcontroller->arflitebr2nl( $form->options[ $custom_css_block_form ] );
6742
6743                                if ( $custom_css_block_form == 'arf_form_outer_wrapper' ) {
6744                                        $arf_form_outer_wrapper_array = explode( '|', $custom_css_classes_form );
6745
6746                                        foreach ( $arf_form_outer_wrapper_array as $arf_form_outer_wrapper1 ) {
6747                                                if ( $arf_form_outer_wrapper1 == '.arf_form_outer_wrapper' ) {
6748                                                        $return_css .= '.arflite_main_div_' . $form->id . '.arf_form_outer_wrapper { ' . $form->options[ $custom_css_block_form ] . ' } ';
6749                                                }
6750                                                if ( $arf_form_outer_wrapper1 == '.arfmodal' ) {
6751                                                        $return_css .= '#popup-form-' . $form->id . '.arfmodal{ ' . $form->options[ $custom_css_block_form ] . ' } ';
6752                                                }
6753                                        }
6754                                } elseif ( $custom_css_block_form == 'arf_form_inner_wrapper' ) {
6755                                        $arf_form_inner_wrapper_array = explode( '|', $custom_css_classes_form );
6756                                        foreach ( $arf_form_inner_wrapper_array as $arf_form_inner_wrapper1 ) {
6757                                                if ( $arf_form_inner_wrapper1 == '.arf_fieldset' ) {
6758                                                        $return_css .= '.arflite_main_div_' . $form->id . ' ' . $arf_form_inner_wrapper1 . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6759                                                }
6760                                                if ( $arf_form_inner_wrapper1 == '.arfmodal' ) {
6761                                                        $return_css .= '.arfmodal .arfmodal-body .arflite_main_div_' . $form->id . ' .arf_fieldset { ' . $form->options[ $custom_css_block_form ] . ' } ';
6762                                                }
6763                                        }
6764                                } elseif ( $custom_css_block_form == 'arf_form_error_message' ) {
6765                                        $arf_form_error_message_array = explode( '|', $custom_css_classes_form );
6766
6767                                        foreach ( $arf_form_error_message_array as $arf_form_error_message1 ) {
6768                                                $return_css .= '.arflite_main_div_' . $form->id . ' ' . $arf_form_error_message1 . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6769                                        }
6770                                } else {
6771                                        $return_css .= '.arflite_main_div_' . $form->id . ' ' . $custom_css_classes_form . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6772                                }
6773                        }
6774                }
6775
6776                foreach ( $values['fields'] as $field ) {
6777                        foreach ( $field['field_options'] as $f => $fopt ) {
6778                                $field[ $f ] = $fopt;
6779                        }
6780                        $field['id'] = $arflitefieldhelper->arfliteget_actual_id( $field['id'] );
6781
6782                        if ( $field['type'] == 'select' ) {
6783                                if ( isset( $field['size'] ) && $field['size'] != 1 ) {
6784                                        if ( $newarr['auto_width'] != '1' ) {
6785
6786                                                if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6787
6788                                                        $return_css .= '.arflite_main_div_' . $field['form_id'] . ' .select_controll_' . $field['id'] . ':not([class*="span"]):not([class*="col-"]):not([class*="form-control"]){width:' . $field['field_width'] . 'px !important;}';
6789                                                }
6790                                        }
6791                                }
6792                        } elseif ( $field['type'] == 'time' ) {
6793                                if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6794                                        $return_css .= '.arflite_main_div_' . $field['form_id'] . ' .time_controll_' . $field['id'] . ':not([class*="span"]):not([class*="col-"]):not([class*="form-control"]){width:' . $field['field_width'] . 'px !important;}';
6795                                }
6796                        }
6797
6798                        if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6799                                $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .help-block { width: ' . $field['field_width'] . 'px; } ';
6800                        }
6801
6802                        $custom_css_array = array(
6803                                'css_outer_wrapper' => '.arf_form_outer_wrapper',
6804                                'css_label'         => '.css_label',
6805                                'css_input_element' => '.css_input_element',
6806                                'css_description'   => '.arf_field_description',
6807                        );
6808
6809                        if ( in_array( $field['type'], array( 'text', 'email', 'date', 'time', 'number', 'image', 'url', 'phone', 'number' ) ) ) {
6810                                $custom_css_array['css_add_icon'] = '.arf_prefix, .arf_suffix';
6811                        }
6812
6813                        foreach ( $custom_css_array as $custom_css_block => $custom_css_classes ) {
6814                                if ( isset( $field[ $custom_css_block ] ) && $field[ $custom_css_block ] != '' ) {
6815
6816                                        $field[ $custom_css_block ] = $arfliteformcontroller->arflitebr2nl( $field[ $custom_css_block ] );
6817
6818                                        if ( $custom_css_block == 'css_outer_wrapper' ) {
6819                                                $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container { ' . $field[ $custom_css_block ] . ' } ';
6820                                        } elseif ( $custom_css_block == 'css_outer_wrapper' ) {
6821                                                $return_css .= ' .arflite_main_div_' . $form->id . ' #heading_' . $field['id'] . ' { ' . $field[ $custom_css_block ] . ' } ';
6822                                        } elseif ( $custom_css_block == 'css_label' ) {
6823                                                $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container label.arf_main_label { ' . $field[ $custom_css_block ] . ' } ';
6824                                        } elseif ( $custom_css_block == 'css_label' ) {
6825                                                $return_css .= ' .arflite_main_div_' . $form->id . ' #heading_' . $field['id'] . ' h2.arf_sec_heading_field { ' . $field[ $custom_css_block ] . ' } ';
6826                                        } elseif ( $custom_css_block == 'css_input_element' ) {
6827
6828                                                if ( $field['type'] == 'textarea' ) {
6829                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls textarea { ' . $field[ $custom_css_block ] . ' } ';
6830                                                } elseif ( $field['type'] == 'select' ) {
6831                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls select { ' . $field[ $custom_css_block ] . ' } ';
6832                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls .arfbtn.dropdown-toggle { ' . $field[ $custom_css_block ] . ' } ';
6833                                                } elseif ( $field['type'] == 'radio' ) {
6834                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_radiobutton label { ' . $field[ $custom_css_block ] . ' } ';
6835                                                } elseif ( $field['type'] == 'checkbox' ) {
6836                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_checkbox_style label { ' . $field[ $custom_css_block ] . ' } ';
6837                                                } else {
6838                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input { ' . $field[ $custom_css_block ] . ' } ';
6839                                                        if ( $field['type'] == 'email' ) {
6840                                                                $return_css .= '.arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container + .confirm_email_container .controls input {' . $field[ $custom_css_block ] . '}';
6841                                                                $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container + .confirm_email_container .arf_prefix_suffix_wrapper{ ' . $field[ $custom_css_block ] . ' }';
6842                                                        }
6843                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_prefix_suffix_wrapper { ' . $field[ $custom_css_block ] . ' } ';
6844                                                }
6845                                        } elseif ( $custom_css_block == 'css_description' ) {
6846                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_field_description { ' . $field[ $custom_css_block ] . ' } ';
6847                                        } elseif ( $custom_css_block == 'css_add_icon' ) {
6848                                                $return_css .= '.arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_prefix, .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_suffix { ' . $field[ $custom_css_block ] . ' } ';
6849                                                if ( $field['type'] == 'email' ) {
6850                                                        $return_css .= '.arflite_main_div_' . $form->id . ' .arf_confirm_email_field_' . $field['id'] . ' .arf_prefix, .arflite_main_div_' . $form->id . ' .arf_confirm_email_field_' . $field['id'] . ' .arf_suffix {' . $field[ $custom_css_block ] . ' } ';
6851                                                }
6852                                        }
6853
6854                                        do_action( 'arflite_add_css_from_outside', $field, $custom_css_block, $arflite_data_uniq_id );
6855                                }
6856                        }
6857                }
6858                $return_css .= '</style>';
6859                return $return_css;
6860        }
6861
6862        function arflite_prefix_suffix_for_material( $field ) {
6863                $return_string        = '';
6864                $has_phone_with_utils = false;
6865                if ( isset( $field['phonetype'] ) ) {
6866                        if ( $field['type'] == 'phone' && $field['phonetype'] == 1 ) {
6867                                $has_phone_with_utils = true;
6868                        }
6869                }
6870                if ( ! empty( $field['enable_arf_prefix'] ) && $has_phone_with_utils == false ) {
6871                        $return_string .= '<i class="arf_leading_icon ' . $field['arf_prefix_icon'] . '"></i>';
6872                }
6873                if ( ! empty( $field['enable_arf_suffix'] ) ) {
6874                        $return_string .= '<i class="arf_trailing_icon ' . $field['arf_suffix_icon'] . '"></i>';
6875                }
6876
6877                return $return_string;
6878        }
6879
6880        function arflite_get_form_style_for_preview( $form, $id, $fields, $arflite_data_uniq_id = '' ) {
6881
6882                global $arflite_loaded_form_unique_id_array, $arflitefieldhelper, $arfliterecordhelper, $arfliteform, $arflitemainhelper, $arfliteformcontroller;
6883                $return_css = '';
6884                $type       = '';
6885                if ( $arflite_data_uniq_id == '' ) {
6886                        $arflite_data_uniq_id = rand( 1, 99999 );
6887                        if ( empty( $arflite_data_uniq_id ) || $arflite_data_uniq_id == '' ) {
6888                                $arflite_data_uniq_id = $id;
6889                        }
6890
6891                        if ( $type != '' ) {
6892                                if ( $position != '' ) {
6893                                        $arflite_loaded_form_unique_id_array[ $id ]['type'][ $type ][ $position ][] = $arflite_data_uniq_id;
6894                                } else {
6895                                        $arflite_loaded_form_unique_id_array[ $id ]['type'][ $type ][] = $arflite_data_uniq_id;
6896                                }
6897                        } else {
6898                                $arflite_loaded_form_unique_id_array[ $id ]['normal'][] = $arflite_data_uniq_id;
6899                        }
6900                }
6901
6902                $css_data_arr = $form->form_css;
6903
6904                $arr = maybe_unserialize( $css_data_arr );
6905
6906                $newarr = array();
6907                $newarr = $arr;
6908
6909                $return_css .= '<style type="text/css" id="arf_form_' . $id . '" data-form-unique-id="' . $arflite_data_uniq_id . '" >';
6910
6911                        $form->form_css = maybe_unserialize( $form->form_css );
6912
6913                        $loaded_field = isset( $form->options['arf_loaded_field'] ) ? $form->options['arf_loaded_field'] : array();
6914
6915                        $return_css                         .= stripslashes_deep( get_option( 'arflite_global_css' ) );
6916                        $form->options['arf_form_other_css'] = $arfliteformcontroller->arflitebr2nl( $form->options['arf_form_other_css'] );
6917                        $return_css                         .= stripslashes( $arflitemainhelper->arflite_esc_textarea( $form->options['arf_form_other_css'] ) );
6918
6919                        $custom_css_array_form = array(
6920                                'arf_form_outer_wrapper'   => '.arf_form_outer_wrapper|.arfmodal',
6921                                'arf_form_inner_wrapper'   => '.arf_fieldset|.arfmodal',
6922                                'arf_form_title'           => '.formtitle_style',
6923                                'arf_form_description'     => 'div.formdescription_style',
6924                                'arf_form_element_wrapper' => '.arfformfield',
6925                                'arf_form_element_label'   => 'label.arf_main_label',
6926                                'arf_form_elements'        => '.controls',
6927                                'arf_submit_outer_wrapper' => 'div.arfsubmitbutton',
6928                                'arf_form_submit_button'   => '.arfsubmitbutton button.arf_submit_btn',
6929                                'arf_form_success_message' => '#arf_message_success',
6930                                'arf_form_error_message'   => '.control-group.arf_error .help-block|.control-group.arf_warning .help-block|.control-group.arf_warning .help-inline|.control-group.arf_warning .control-label|.control-group.arf_error .popover|.control-group.arf_warning .popover',
6931                        );
6932
6933                        foreach ( $custom_css_array_form as $custom_css_block_form => $custom_css_classes_form ) {
6934
6935                                if ( isset( $form->options[ $custom_css_block_form ] ) && $form->options[ $custom_css_block_form ] != '' ) {
6936
6937                                        $form->options[ $custom_css_block_form ] = $arfliteformcontroller->arflitebr2nl( $form->options[ $custom_css_block_form ] );
6938
6939                                        if ( $custom_css_block_form == 'arf_form_outer_wrapper' ) {
6940                                                $arf_form_outer_wrapper_array = explode( '|', $custom_css_classes_form );
6941
6942                                                foreach ( $arf_form_outer_wrapper_array as $arf_form_outer_wrapper1 ) {
6943                                                        if ( $arf_form_outer_wrapper1 == '.arf_form_outer_wrapper' ) {
6944                                                                $return_css .= '.arflite_main_div_' . $form->id . '.arf_form_outer_wrapper { ' . $form->options[ $custom_css_block_form ] . ' } ';
6945                                                        }
6946                                                        if ( $arf_form_outer_wrapper1 == '.arfmodal' ) {
6947                                                                $return_css .= '#popup-form-' . $form->id . '.arfmodal{ ' . $form->options[ $custom_css_block_form ] . ' } ';
6948                                                        }
6949                                                }
6950                                        } elseif ( $custom_css_block_form == 'arf_form_inner_wrapper' ) {
6951                                                $arf_form_inner_wrapper_array = explode( '|', $custom_css_classes_form );
6952                                                foreach ( $arf_form_inner_wrapper_array as $arf_form_inner_wrapper1 ) {
6953                                                        if ( $arf_form_inner_wrapper1 == '.arf_fieldset' ) {
6954                                                                $return_css .= '.arflite_main_div_' . $form->id . ' ' . $arf_form_inner_wrapper1 . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6955                                                        }
6956                                                        if ( $arf_form_inner_wrapper1 == '.arfmodal' ) {
6957                                                                $return_css .= '.arfmodal .arfmodal-body .arflite_main_div_' . $form->id . ' .arf_fieldset { ' . $form->options[ $custom_css_block_form ] . ' } ';
6958                                                        }
6959                                                }
6960                                        } elseif ( $custom_css_block_form == 'arf_form_error_message' ) {
6961                                                $arf_form_error_message_array = explode( '|', $custom_css_classes_form );
6962
6963                                                foreach ( $arf_form_error_message_array as $arf_form_error_message1 ) {
6964                                                        $return_css .= '.arflite_main_div_' . $form->id . ' ' . $arf_form_error_message1 . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6965                                                }
6966                                        } else {
6967                                                $return_css .= '.arflite_main_div_' . $form->id . ' ' . $custom_css_classes_form . ' { ' . $form->options[ $custom_css_block_form ] . ' } ';
6968                                        }
6969                                }
6970                        }
6971
6972                        foreach ( $fields as $field ) {
6973                                $field       = $this->arfliteObjtoArray( $field );
6974                                $field['id'] = $arflitefieldhelper->arfliteget_actual_id( $field['id'] );
6975
6976                                if ( $field['type'] == 'select' ) {
6977                                        if ( isset( $field['size'] ) && $field['size'] != 1 ) {
6978                                                if ( $newarr['auto_width'] != '1' ) {
6979
6980                                                        if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6981
6982                                                                $return_css .= '.arflite_main_div_' . $field['form_id'] . ' .select_controll_' . $field['id'] . ':not([class*="span"]):not([class*="col-"]):not([class*="form-control"]){width:' . $field['field_width'] . 'px !important;}';
6983                                                        }
6984                                                }
6985                                        }
6986                                } elseif ( $field['type'] == 'time' ) {
6987                                        if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6988                                                $return_css .= '.arflite_main_div_' . $field['form_id'] . ' .time_controll_' . $field['id'] . ':not([class*="span"]):not([class*="col-"]):not([class*="form-control"]){width:' . $field['field_width'] . 'px !important;}';
6989                                        }
6990                                }
6991
6992                                if ( isset( $field['field_width'] ) && $field['field_width'] != '' ) {
6993                                        $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .help-block { width: ' . $field['field_width'] . 'px; } ';
6994                                }
6995
6996                                $custom_css_array = array(
6997                                        'css_outer_wrapper' => '.arf_form_outer_wrapper',
6998                                        'css_label'         => '.css_label',
6999                                        'css_input_element' => '.css_input_element',
7000                                        'css_description'   => '.arf_field_description',
7001                                );
7002
7003                                if ( in_array( $field['type'], array( 'text', 'email', 'date', 'time', 'number', 'image', 'url', 'phone', 'number' ) ) ) {
7004                                        $custom_css_array['css_add_icon'] = '.arf_prefix, .arf_suffix';
7005                                }
7006
7007                                foreach ( $custom_css_array as $custom_css_block => $custom_css_classes ) {
7008                                        if ( isset( $field[ $custom_css_block ] ) && $field[ $custom_css_block ] != '' ) {
7009
7010                                                $field[ $custom_css_block ] = $arfliteformcontroller->arflitebr2nl( $field[ $custom_css_block ] );
7011
7012                                                if ( $custom_css_block == 'css_outer_wrapper' ) {
7013                                                        $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container { ' . $field[ $custom_css_block ] . ' } ';
7014                                                } elseif ( $custom_css_block == 'css_label' ) {
7015                                                        $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container label.arf_main_label { ' . $field[ $custom_css_block ] . ' } ';
7016                                                } elseif ( $custom_css_block == 'css_input_element' ) {
7017
7018                                                        if ( $field['type'] == 'textarea' ) {
7019                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls textarea { ' . $field[ $custom_css_block ] . ' } ';
7020                                                        } elseif ( $field['type'] == 'select' ) {
7021                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls select { ' . $field[ $custom_css_block ] . ' } ';
7022                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls .arfbtn.dropdown-toggle { ' . $field[ $custom_css_block ] . ' } ';
7023                                                        } elseif ( $field['type'] == 'radio' ) {
7024                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_radiobutton label { ' . $field[ $custom_css_block ] . ' } ';
7025                                                        } elseif ( $field['type'] == 'checkbox' ) {
7026                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_checkbox_style label { ' . $field[ $custom_css_block ] . ' } ';
7027                                                        } else {
7028                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .controls input { ' . $field[ $custom_css_block ] . ' } ';
7029                                                                if ( $field['type'] == 'email' ) {
7030                                                                        $return_css .= '.arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container + .confirm_email_container .controls input {' . $field[ $custom_css_block ] . '}';
7031                                                                        $return_css .= ' .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container + .confirm_email_container .arf_prefix_suffix_wrapper{ ' . $field[ $custom_css_block ] . ' }';
7032                                                                }
7033                                                                $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_prefix_suffix_wrapper { ' . $field[ $custom_css_block ] . ' } ';
7034                                                        }
7035                                                } elseif ( $custom_css_block == 'css_description' ) {
7036                                                        $return_css .= ' .arflite_main_div_' . $form->id . '  #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_field_description { ' . $field[ $custom_css_block ] . ' } ';
7037                                                } elseif ( $custom_css_block == 'css_add_icon' ) {
7038                                                        $return_css .= '.arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_prefix,
7039                                .arflite_main_div_' . $form->id . ' #arf_field_' . $field['id'] . '_' . $arflite_data_uniq_id . '_container .arf_suffix { ' . $field[ $custom_css_block ] . ' } ';
7040                                                        if ( $field['type'] == 'email' ) {
7041                                                                $return_css .= '.arflite_main_div_' . $form->id . ' .arf_confirm_email_field_' . $field['id'] . ' .arf_prefix,
7042                                        .arflite_main_div_' . $form->id . ' .arf_confirm_email_field_' . $field['id'] . ' .arf_suffix {' . $field[ $custom_css_block ] . ' } ';
7043                                                        }
7044                                                }
7045
7046                                                do_action( 'arflite_add_css_from_outside', $field, $custom_css_block, $arflite_data_uniq_id );
7047                                        }
7048                                }
7049                        }
7050
7051                        $return_css .= '</style>';
7052
7053                        return $return_css;
7054        }
7055
7056        function arflite_prefix_suffix( $prefix_suffix, $field ) {
7057                $return_string = '';
7058
7059                $has_phone_with_utils = false;
7060                $phone_with_utils_cls = '';
7061                if ( isset( $field['phonetype'] ) ) {
7062                        if ( $field['type'] == 'phone' && $field['phonetype'] == 1 ) {
7063                                $has_phone_with_utils = true;
7064                                $phone_with_utils_cls = 'arf_phone_with_flag';
7065                        }
7066                }
7067
7068                $wrapper_cls = '';
7069                if ( ! empty( $field['enable_arf_prefix'] ) && empty( $field['enable_arf_suffix'] ) ) {
7070                        $wrapper_cls = ' arf_prefix_only ';
7071                } elseif ( empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
7072                        $wrapper_cls = ' arf_suffix_only ';
7073                } elseif ( ! empty( $field['enable_arf_prefix'] ) && ! empty( $field['enable_arf_suffix'] ) ) {
7074                        $wrapper_cls = ' arf_both_pre_suffix ';
7075                        if ( $field['type'] == 'phone' && $field['phonetype'] == 1 ) {
7076                                        $wrapper_cls = ' arf_suffix_only';
7077                        }
7078                }
7079
7080                if ( $prefix_suffix == 'prefix' ) {
7081                        if ( ( isset( $field['enable_arf_prefix'] ) && $field['enable_arf_prefix'] == 1 ) || ( isset( $field['enable_arf_suffix'] ) && $field['enable_arf_suffix'] == 1 ) ) {
7082                                $return_string .= '<div class="arf_prefix_suffix_wrapper ' . $wrapper_cls . ' ' . $phone_with_utils_cls . '">';
7083                                if ( $field['enable_arf_prefix'] == 1 ) {
7084                                        if ( $has_phone_with_utils == false ) {
7085                                                $return_string .= '<span id="arf_prefix_' . $field['field_key'] . '" class="arf_prefix" onclick="arfliteFocusInputField(this,\'' . $field['field_key'] . '\');"><i class="' . $field['arf_prefix_icon'] . '"></i></span>';
7086                                        }
7087                                }
7088                        }
7089                } else {
7090                        if ( ( isset( $field['enable_arf_prefix'] ) && $field['enable_arf_prefix'] == 1 ) || ( isset( $field['enable_arf_suffix'] ) && $field['enable_arf_suffix'] == 1 ) ) {
7091                                if ( $field['enable_arf_suffix'] == 1 ) {
7092                                        $return_string .= '<span id="arf_suffix_' . $field['field_key'] . '" class="arf_suffix" onclick="arfliteFocusInputField(this,\'' . $field['field_key'] . '\');"><i class="' . $field['arf_suffix_icon'] . '"></i></span>';
7093                                }
7094                                $return_string .= '</div>';
7095                        }
7096                }
7097                return $return_string;
7098        }
7099
7100        function arfliteObjtoArray( $obj ) {
7101                if ( is_object( $obj ) ) {
7102                        $obj = get_object_vars( $obj );
7103                }
7104                if ( is_array( $obj ) ) {
7105                        return array_map( array( $this, __FUNCTION__ ), $obj );
7106                } else {
7107                        return $obj;
7108                }
7109        }
7110
7111        function arfliteArraytoObj( $array ) {
7112                if ( is_array( $array ) ) {
7113                        $array = json_decode( json_encode( $array ) );
7114                }
7115                return $array;
7116        }
7117
7118        function arflite_csv_form_function() {
7119
7120                $form_id  = isset( $_REQUEST['form_id'] ) ? intval( $_REQUEST['form_id'] ) : '';
7121                $data_url = site_url() . '/index.php?plugin=ARFormslite&controller=entries&form=' . $form_id . '&arfaction=csv';
7122
7123                echo json_encode(
7124                        array(
7125                                'url_data' => $data_url,
7126                                'error'    => false,
7127                                'message'  =>
7128                                        __(
7129                                                'CSV generated successfully.',
7130                                                'arforms-form-builder'
7131                                        ),
7132                        )
7133                );
7134                die();
7135        }
7136
7137        function get_arflite_default_fonts() {
7138                return array(
7139                        'Arial'               => 'Arial',
7140                        'Helvetica'           => 'Helvetica',
7141                        'sans-serif'          => 'sans-serif',
7142                        'Lucida Grande'       => 'Lucida Grande',
7143                        'Lucida Sans Unicode' => 'Lucida Sans Unicode',
7144                        'Tahoma'              => 'Tahoma',
7145                        'Times New Roman'     => 'Times New Roman',
7146                        'Courier New'         => 'Courier New',
7147                        'Verdana'             => 'Verdana',
7148                        'Geneva'              => 'Geneva',
7149                        'Courier'             => 'Courier',
7150                        'Monospace'           => 'Monospace',
7151                        'Times'               => 'Times',
7152                );
7153        }
7154
7155        function arflite_delete_form_function() {
7156                global $wpdb, $ARFLiteMdlDb,$arfliteform,$arflitemaincontroller, $tbl_arf_forms;
7157
7158                $arflite_validate_request = $arflitemaincontroller->arflite_check_user_cap( 'arfdeleteforms', true );
7159
7160                if ( 'success' != $arflite_validate_request ) {
7161                        $validate_data = json_decode( $arflite_validate_request, true );
7162
7163                        echo json_encode(
7164                                array(
7165                                        'error'       => true,
7166                                        'message'     => addslashes( $validate_data[0] ),
7167                                        'total_forms' => 0,
7168                                )
7169                        );
7170                        die;
7171                }
7172
7173                $total_forms = 0;
7174                $form_id     = isset( $_REQUEST['form_id'] ) ? intval( $_REQUEST['form_id'] ) : '';
7175                if ( $form_id == '' ) {
7176                        echo json_encode(
7177                                array(
7178                                        'error'       => true,
7179                                        'message'     => __( 'Please select valid form', 'arforms-form-builder' ),
7180                                        'total_forms' => $total_forms,
7181                                )
7182                        );
7183                        die();
7184                }
7185
7186                $result = $arfliteform->arflitedestroy( $form_id );
7187                if ( $result ) {
7188                        echo json_encode(
7189                                array(
7190                                        'error'       => true,
7191                                        'message'     => __( 'Please select valid form', 'arforms-form-builder' ),
7192                                        'total_forms' => $total_forms,
7193                                )
7194                        );
7195                } else {
7196                        $where       = "WHERE 1=1 AND is_template = %d AND (status is NULL OR status = '' OR status = 'published') ";
7197                        $totalRecord = $wpdb->get_results( $wpdb->prepare( 'SELECT COUNT(*) as total_forms FROM ' . $tbl_arf_forms . ' ' . $where . ' ', 0 ) ); //phpcs:ignore
7198                        $total_forms = $totalRecord[0]->total_forms;
7199                        echo json_encode(
7200                                array(
7201                                        'error'       => false,
7202                                        'message'     => __( 'Record is deleted successfully.', 'arforms-form-builder' ),
7203                                        'total_forms' => $total_forms,
7204                                )
7205                        );
7206                }
7207
7208                die();
7209        }
7210
7211        function arflite_change_input_style() {
7212
7213                global $arflitemaincontroller, $arflite_intval_keys;
7214
7215                $arflite_validate_request = $arflitemaincontroller->arflite_check_user_cap( 'arfeditforms', true );
7216
7217                if ( 'success' != $arflite_validate_request ) {
7218                        $validate_data   = json_decode( $arflite_validate_request, true );
7219                        $return['error'] = true;
7220                        echo json_encode( $return );
7221                        die();
7222                }
7223
7224                $form_id      = $id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : ''; //phpcs:ignore
7225                $style        = isset( $_POST['style'] ) ? sanitize_text_field( $_POST['style'] ) : 'material'; //phpcs:ignore
7226                $styling_opts = isset( $_POST['styling_opts'] ) ? json_decode( stripslashes_deep( sanitize_text_field( $_POST['styling_opts'] ) ), true ) : array(); //phpcs:ignore
7227
7228                $field_order        = isset( $_POST['field_order'] ) ? json_decode( stripslashes_deep( sanitize_text_field( $_POST['field_order'] ) ), true ) : ''; //phpcs:ignore
7229                $field_resize_width = isset( $_POST['field_resize_width'] ) ? json_decode( stripslashes_deep( sanitize_text_field( $_POST['field_resize_width'] ) ), true ) : ''; //phpcs:ignore
7230
7231                foreach ( $field_order as $field_id => $order ) {
7232                        $field_order[ $field_id ] = sanitize_text_field( $order );
7233                }
7234
7235                foreach ( $field_resize_width as $field_id => $order ) {
7236                        $field_resize_width[ $field_id ] = sanitize_text_field( $order );
7237                }
7238
7239                if ( $form_id == '' || $form_id < 100 ) {
7240                        $return['error'] = true;
7241                        echo json_encode( $return );
7242                        die();
7243                }
7244                global $wpdb, $ARFLiteMdlDb, $tbl_arf_fields;
7245
7246                $unsaved_fields = ( isset( $_REQUEST['extra_fields'] ) && $_REQUEST['extra_fields'] != '' ) ? json_decode( stripslashes_deep( sanitize_text_field($_REQUEST['extra_fields']) ), true ) : array();
7247
7248                $arf_fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . $tbl_arf_fields . '` WHERE `form_id` = %d', $form_id ), ARRAY_A ); //phpcs:ignore
7249                asort( $field_order );
7250                $arf_sorted_fields = array();
7251                foreach ( $field_order as $field_id => $order ) {
7252                        if ( is_int( $field_id ) ) {
7253                                foreach ( $arf_fields as $field ) {
7254                                        if ( $field_id == $field['id'] && ! array_key_exists( $field_id, $unsaved_fields ) ) {
7255                                                $arf_sorted_fields[] = $field;
7256                                        }
7257                                }
7258                        } else {
7259                                $arf_sorted_fields[] = $field_id;
7260                        }
7261                }
7262
7263                if ( isset( $arf_sorted_fields ) ) {
7264                        $arf_fields = $arf_sorted_fields;
7265                }
7266                $field_data = file_get_contents( ARFLITE_VIEWS_PATH . '/arflite_editor_data.json' );
7267
7268                $field_data_obj  = json_decode( $field_data );
7269                $return['error'] = false;
7270                $content         = '';
7271                if ( ! empty( $unsaved_fields ) ) {
7272                        $arf_sorted_unsave_fields = array();
7273                        foreach ( $field_order as $field_id => $order ) {
7274                                foreach ( $unsaved_fields as $fid => $field_data ) {
7275                                        if ( $field_id == $fid ) {
7276                                                $arf_sorted_unsave_fields[ $fid ] = $field_data;
7277                                        }
7278                                }
7279                        }
7280
7281                        $unsaved_fields = $arf_sorted_unsave_fields;
7282
7283                        $temp_fields = array();
7284                        foreach ( $unsaved_fields as $key => $value ) {
7285                                $opts = json_decode( $value, true );
7286                                if ( json_last_error() != JSON_ERROR_NONE ) {
7287                                        $opts = maybe_unserialize( $value );
7288                                }
7289                                foreach ( $opts as $k => $val ) {
7290                                        if ( $k == 'key' ) {
7291                                                $temp_fields[ $key ]['field_key'] = $val;
7292                                        } elseif ( $k == 'options' || $k == 'default_value' ) {
7293                                                $temp_fields[ $key ][ $k ] = ( $val != '' ) ? json_encode( $val ) : '';
7294                                        } else {
7295                                                $temp_fields[ $key ][ $k ] = $val;
7296                                        }
7297                                }
7298                                $temp_fields[ $key ]['field_options'] = $value;
7299                                $temp_fields[ $key ]['id']            = $key;
7300                        }
7301                        $arf_fields = array_merge( $arf_fields, $temp_fields );
7302                }
7303
7304                $arf_sorted_fields_new = array();
7305                foreach ( $field_order as $field_id => $order ) {
7306                        if ( is_int( $field_id ) ) {
7307                                foreach ( $arf_fields as $field ) {
7308                                        if ( isset( $field['id'] ) && ( $field_id == $field['id'] ) ) {
7309                                                $arf_sorted_fields_new[] = $field;
7310                                        }
7311                                }
7312                        } else {
7313                                $arf_sorted_fields_new[] = $field_id;
7314                        }
7315                }
7316                $arf_fields = $arf_sorted_fields_new;
7317
7318                $allowed_html = arflite_retrieve_attrs_for_wp_kses();
7319
7320                foreach ( $arf_fields as $fk => $fval ) {
7321
7322                        if ( is_array( $fval ) ) {
7323                                foreach ( $fval as $fki => $fvali ) {
7324                                        if ( 'name' == $fki || 'description' == $fki || 'arf_tooltip' == $fki || 'tooltip_text' == $fki ) {
7325                                                $arf_fields[ $fk ][ $fki ] = wp_kses( $fvali, $allowed_html );
7326                                        } elseif ( 'field_options' == $fki ) {
7327                                                $fvali_arr = json_decode( $fvali, true );
7328                                                foreach ( $fvali_arr as $fopt_k => $fopt_v ) {
7329                                                        if ( 'name' == $fopt_k || 'description' == $fopt_k || 'arf_tooltip' == $fopt_k || 'tooltip_text' == $fopt_k ) {
7330                                                                $fvali_arr[ $fopt_k ] = wp_kses( $fopt_v, $allowed_html );
7331                                                        } elseif ( in_array( $fopt_k, $arflite_intval_keys ) ) {
7332                                                                $fvali_arr[ $fopt_k ] = intval( $fopt_v );
7333                                                        } elseif ( $fopt_k == 'phtypes' ) {
7334                                                                foreach ( $fopt_v as $fipot_k => $fipt_v ) {
7335                                                                        $fvali_arr[ $fopt_k ][ $fipot_k ] = sanitize_text_field( $fipt_v );
7336                                                                }
7337                                                        } else {
7338                                                                if ( is_array( $fopt_v ) ) {
7339                                                                        $fvali_arr[ $fopt_k ] = array_map( 'sanitize_text_field', $fopt_v ); // sanitize_text_field( $fopt_v );
7340                                                                } else {
7341                                                                        $fvali_arr[ $fopt_k ] = sanitize_text_field( $fopt_v );
7342                                                                }
7343                                                        }
7344                                                }
7345                                                $arf_fields[ $fk ][ $fki ] = json_encode( $fvali_arr );
7346                                        } elseif ( in_array( $fki, $arflite_intval_keys ) ) {
7347                                                $arf_fields[ $fk ][ $fki ] = intval( $fvali );
7348                                        } elseif ( $fki == 'phtypes' ) {
7349                                                foreach ( $fvali as $fipot_k => $fipt_v ) {
7350                                                        $fvali_arr[ $fki ][ $fipot_k ] = sanitize_text_field( $fipt_v );
7351                                                }
7352                                        } else {
7353                                                if ( is_array( $fvali ) ) {
7354
7355                                                        $fvali_arr[ $fk ] = array_map( 'sanitize_text_field', $fvali );
7356                                                } else {
7357                                                        $arf_fields[ $fk ][ $fki ] = sanitize_text_field( $fvali );
7358                                                }
7359                                        }
7360                                }
7361                        }
7362                }
7363
7364                $class_array       = array();
7365                $arf_field_counter = 1;
7366                $index_arf_fields  = 0;
7367                if ( is_array( $styling_opts ) && ! empty( $styling_opts ) && count( $styling_opts ) > 0 ) {
7368                        $form_css                                        = array();
7369                        $form_css['arfmainformwidth']                    = isset( $styling_opts['arffw'] ) ? intval( $styling_opts['arffw'] ) : '';
7370                        $form_css['arfmainformwidth_tablet'] = isset($styling_opts['arffw_tablet']) ? $styling_opts['arffw_tablet'] : '';
7371            $form_css['arfmainformwidth_mobile'] = isset($styling_opts['arffw_mobile']) ? $styling_opts['arffw_mobile'] : '';
7372                        $form_css['form_width_unit']                     = isset( $styling_opts['arffu'] ) ? sanitize_text_field( $styling_opts['arffu'] ) : '';
7373                        $form_css['text_direction']                      = isset( $styling_opts['arftds'] ) ? intval( $styling_opts['arftds'] ) : '';
7374                        $form_css['form_align']                          = isset( $styling_opts['arffa'] ) ? sanitize_text_field( $styling_opts['arffa'] ) : '';
7375                        $form_css['arfmainfieldsetpadding']              = isset( $styling_opts['arfmfsp'] ) ? sanitize_text_field( $styling_opts['arfmfsp'] ) : '';
7376                        $form_css['arfmainfieldsetpadding_tablet']              = isset( $styling_opts['arfmfsp_tablet'] ) ? sanitize_text_field( $styling_opts['arfmfsp_tablet'] ) : '';
7377                        $form_css['arfmainfieldsetpadding_mobile']              = isset( $styling_opts['arfmfsp_mobile'] ) ? sanitize_text_field( $styling_opts['arfmfsp_mobile'] ) : '';
7378                        $form_css['form_border_shadow']                  = isset( $styling_opts['arffbs'] ) ? sanitize_text_field( $styling_opts['arffbs'] ) : '';
7379                        $form_css['fieldset']                            = isset( $styling_opts['arfmfis'] ) ? intval( $styling_opts['arfmfis'] ) : '';
7380                        $form_css['arfmainfieldsetradius']               = isset( $styling_opts['arfmfsr'] ) ? intval( $styling_opts['arfmfsr'] ) : '';
7381                        $form_css['arfmainfieldsetcolor']                = isset( $styling_opts['arfmfsc'] ) ? sanitize_text_field( $styling_opts['arfmfsc'] ) : '';
7382                        $form_css['arfmainformbordershadowcolorsetting'] = isset( $styling_opts['arffboss'] ) ? sanitize_text_field( $styling_opts['arffboss'] ) : '';
7383                        $form_css['arfmainformtitlecolorsetting']        = isset( $styling_opts['arfftc'] ) ? sanitize_text_field( $styling_opts['arfftc'] ) : '';
7384                        $form_css['check_weight_form_title']             = isset( $styling_opts['arfftws'] ) ? sanitize_text_field( $styling_opts['arfftws'] ) : '';
7385                        $form_css['form_title_font_size']                = isset( $styling_opts['arfftfss'] ) ? intval( $styling_opts['arfftfss'] ) : '';
7386                        $form_css['arfmainformtitlepaddingsetting']      = isset( $styling_opts['arfftps'] ) ? sanitize_text_field( $styling_opts['arfftps'] ) : '';
7387                        $form_css['arfmainformbgcolorsetting']           = isset( $styling_opts['arffbcs'] ) ? sanitize_text_field( $styling_opts['arffbcs'] ) : '';
7388                        $form_css['font']                                = isset( $styling_opts['arfmfs'] ) ? sanitize_text_field( $styling_opts['arfmfs'] ) : '';
7389                        $form_css['label_color']                         = isset( $styling_opts['arflcs'] ) ? sanitize_text_field( $styling_opts['arflcs'] ) : '';
7390                        $form_css['weight']                              = isset( $styling_opts['arfmfws'] ) ? sanitize_text_field( $styling_opts['arfmfws'] ) : '';
7391                        $form_css['font_size']                           = isset( $styling_opts['arffss'] ) ? intval( $styling_opts['arffss'] ) : '';
7392                        $form_css['align']                               = isset( $styling_opts['arffrma'] ) ? sanitize_text_field( $styling_opts['arffrma'] ) : '';
7393                        $form_css['position']                            = isset( $styling_opts['arfmps'] ) ? sanitize_text_field( $styling_opts['arfmps'] ) : '';
7394                        $form_css['width']                               = isset( $styling_opts['arfmws'] ) ? intval( $styling_opts['arfmws'] ) : '';
7395                        $form_css['width_unit']                          = isset( $styling_opts['arfmwu'] ) ? sanitize_text_field( $styling_opts['arfmwu'] ) : '';
7396                        $form_css['arfdescfontsizesetting']              = isset( $styling_opts['arfdfss'] ) ? intval( $styling_opts['arfdfss'] ) : '';
7397                        $form_css['arfdescalighsetting']                 = isset( $styling_opts['arfdas'] ) ? sanitize_text_field( $styling_opts['arfdas'] ) : '';
7398                        $form_css['hide_labels']                         = isset( $styling_opts['arfhl'] ) ? intval( $styling_opts['arfhl'] ) : '';
7399                        $form_css['check_font']                          = isset( $styling_opts['arfcbfs'] ) ? sanitize_text_field( $styling_opts['arfcbfs'] ) : '';
7400                        $form_css['check_weight']                        = isset( $styling_opts['arfcbws'] ) ? sanitize_text_field( $styling_opts['arfcbws'] ) : '';
7401                        $form_css['field_font_size']                     = isset( $styling_opts['arfffss'] ) ? intval( $styling_opts['arfffss'] ) : '';
7402                        $form_css['text_color']                          = isset( $styling_opts['arftcs'] ) ? sanitize_text_field( $styling_opts['arftcs'] ) : '';
7403                        $form_css['border_radius']                       = isset( $styling_opts['arfmbs'] ) ? intval( $styling_opts['arfmbs'] ) : '';
7404                        $form_css['border_radius_tablet']                = isset($styling_opts['arfmbs_tablet']) ? $styling_opts['arfmbs_tablet'] : '';
7405            $form_css['border_radius_mobile']                = isset($styling_opts['arfmbs_mobile']) ? $styling_opts['arfmbs_mobile'] : '';
7406                        $form_css['border_color']                        = isset( $styling_opts['arffmboc'] ) ? sanitize_text_field( $styling_opts['arffmboc'] ) : '';
7407                        $form_css['arffieldborderwidthsetting']          = isset( $styling_opts['arffbws'] ) ? intval( $styling_opts['arffbws'] ) : '';
7408                        $form_css['arffieldborderstylesetting']          = isset( $styling_opts['arffbss'] ) ? sanitize_text_field( $styling_opts['arffbss'] ) : '';
7409
7410                        $form_css['arf_bg_position_x'] = ( isset( $styling_opts['arf_bg_position_x'] ) && $styling_opts['arf_bg_position_x'] != '' ) ? sanitize_text_field( $styling_opts['arf_bg_position_x'] ) : 'left';
7411                        $form_css['arf_bg_position_y'] = ( isset( $styling_opts['arf_bg_position_y'] ) && $styling_opts['arf_bg_position_y'] != '' ) ? sanitize_text_field( $styling_opts['arf_bg_position_y'] ) : 'top';
7412
7413                        $form_css['arf_bg_position_input_x'] = ( isset( $styling_opts['arf_bg_position_input_x'] ) && $styling_opts['arf_bg_position_input_x'] != '' ) ? intval( $styling_opts['arf_bg_position_input_x'] ) : '';
7414
7415                        $arf_bg_position_input_y = ( isset( $_REQUEST['arf_bg_position_input_y'] ) && $_REQUEST['arf_bg_position_input_y'] != '' ) ? intval( $_REQUEST['arf_bg_position_input_y'] ) : '';
7416
7417                        $form_css['arf_bg_position_input_y'] = ( isset( $styling_opts['arf_bg_position_input_y'] ) && $styling_opts['arf_bg_position_input_y'] != '' ) ? intval( $arf_bg_position_input_y ) : '';
7418
7419                        if ( isset( $styling_opts['arffiu'] ) && $styling_opts['arffiu'] == '%' && isset( $styling_opts['arfmfiws'] ) && $styling_opts['arfmfiws'] > '100' ) {
7420                                $form_css['field_width'] = '100';
7421                        } else {
7422                                $form_css['field_width'] = isset( $styling_opts['arfmfiws'] ) ? intval( $styling_opts['arfmfiws'] ) : '';
7423                        }
7424                        $form_css['field_width_unit']                   = isset( $styling_opts['arffiu'] ) ? sanitize_text_field( $styling_opts['arffiu'] ) : '';
7425
7426                        if ( isset( $styling_opts['arffiu_tablet'] ) && $styling_opts['arffiu_tablet'] == '%' && isset( $styling_opts['arfmfiws_tablet'] ) && $styling_opts['arfmfiws_tablet'] > '100' ) {
7427                                $form_css['field_width_tablet'] = '100';
7428                        } else {
7429                                $form_css['field_width_tablet'] = isset( $styling_opts['arfmfiws_tablet'] ) ? intval( $styling_opts['arfmfiws_tablet'] ) : '';
7430                        }
7431                        $form_css['field_width_unit_tablet']                   = isset( $styling_opts['arffiu_tablet'] ) ? sanitize_text_field( $styling_opts['arffiu_tablet'] ) : '';
7432
7433                        if ( isset( $styling_opts['arffiu_mobile'] ) && $styling_opts['arffiu_mobile'] == '%' && isset( $styling_opts['arfmfiws_mobile'] ) && $styling_opts['arfmfiws_mobile'] > '100' ) {
7434                                $form_css['field_width_mobile'] = '100';
7435                        } else {
7436                                $form_css['field_width_mobile'] = isset( $styling_opts['arfmfiws_mobile'] ) ? intval( $styling_opts['arfmfiws_mobile'] ) : '';
7437                        }
7438                        $form_css['field_width_unit_mobile']                   = isset( $styling_opts['arffiu_mobile'] ) ? sanitize_text_field( $styling_opts['arffiu_mobile'] ) : '';
7439
7440                        $form_css['arffieldmarginssetting']             = isset( $styling_opts['arffms'] ) ? intval( $styling_opts['arffms'] ) : '';
7441                        $form_css['arffieldinnermarginssetting']        = isset( $styling_opts['arffims'] ) ? sanitize_text_field( $styling_opts['arffims'] ) : '';
7442                        $form_css['bg_color']                           = isset( $styling_opts['arffmbc'] ) ? sanitize_text_field( $styling_opts['arffmbc'] ) : '';
7443                        $form_css['arfbgactivecolorsetting']            = isset( $styling_opts['arfbcas'] ) ? sanitize_text_field( $styling_opts['arfbcas'] ) : '';
7444                        $form_css['arfborderactivecolorsetting']        = isset( $styling_opts['arfbacs'] ) ? sanitize_text_field( $styling_opts['arfbacs'] ) : '';
7445                        $form_css['arferrorbgcolorsetting']             = isset( $styling_opts['arfbecs'] ) ? sanitize_text_field( $styling_opts['arfbecs'] ) : '';
7446                        $form_css['arferrorbordercolorsetting']         = isset( $styling_opts['arfboecs'] ) ? sanitize_text_field( $styling_opts['arfboecs'] ) : '';
7447                        $form_css['arfradioalignsetting']               = isset( $styling_opts['arfras'] ) ? sanitize_text_field( $styling_opts['arfras'] ) : '';
7448                        $form_css['arfcheckboxalignsetting']            = isset( $styling_opts['arfcbas'] ) ? sanitize_text_field( $styling_opts['arfcbas'] ) : '';
7449                        $form_css['auto_width']                         = isset( $styling_opts['arfautowidthsetting'] ) ? sanitize_text_field( $styling_opts['arfautowidthsetting'] ) : '';
7450                        $form_css['arfcalthemename']                    = isset( $styling_opts['arffths'] ) ? sanitize_text_field( $styling_opts['arffths'] ) : '';
7451                        $form_css['arfcalthemecss']                     = isset( $styling_opts['arffthc'] ) ? sanitize_text_field( $styling_opts['arffthc'] ) : '';
7452                        $form_css['date_format']                        = isset( $styling_opts['arffdaf'] ) ? sanitize_text_field( $styling_opts['arffdaf'] ) : '';
7453                        $form_css['arfsubmitbuttontext']                = isset( $styling_opts['arfsubmitbuttontext'] ) ? sanitize_text_field( $styling_opts['arfsubmitbuttontext'] ) : '';
7454                        $form_css['arfsubmitweightsetting']             = isset( $styling_opts['arfsbwes'] ) ? sanitize_text_field( $styling_opts['arfsbwes'] ) : '';
7455                        $form_css['arfsubmitbuttonfontsizesetting']     = isset( $styling_opts['arfsbfss'] ) ? intval( $styling_opts['arfsbfss'] ) : '';
7456                        $form_css['arfsubmitbuttonwidthsetting']        = isset( $styling_opts['arfsbws'] ) ? sanitize_text_field( $styling_opts['arfsbws'] ) : '';
7457                        $form_css['arfsubmitbuttonwidthsetting_tablet']        = isset( $styling_opts['arfsbws_tablet'] ) ? sanitize_text_field( $styling_opts['arfsbws_tablet'] ) : '';
7458                        $form_css['arfsubmitbuttonwidthsetting_mobile']        = isset( $styling_opts['arfsbws_mobile'] ) ? sanitize_text_field( $styling_opts['arfsbws_mobile'] ) : '';
7459                        $form_css['arfsubmitbuttonheightsetting']       = isset( $styling_opts['arfsbhs'] ) ? intval( $styling_opts['arfsbhs'] ) : '';
7460                        $form_css['submit_bg_color']                    = isset( $styling_opts['arfsbbcs'] ) ? sanitize_text_field( $styling_opts['arfsbbcs'] ) : '';
7461                        $form_css['arfsubmitbuttonbgcolorhoversetting'] = isset( $styling_opts['arfsbchs'] ) ? sanitize_text_field( $styling_opts['arfsbchs'] ) : '';
7462                        $form_css['arfsubmitbgcolor2setting']           = isset( $styling_opts['arfsbcs'] ) ? sanitize_text_field( $styling_opts['arfsbcs'] ) : '';
7463                        $form_css['arfsubmittextcolorsetting']          = isset( $styling_opts['arfsbtcs'] ) ? sanitize_text_field( $styling_opts['arfsbtcs'] ) : '';
7464                        $form_css['arfsubmitbordercolorsetting']        = isset( $styling_opts['arfsbobcs'] ) ? sanitize_text_field( $styling_opts['arfsbobcs'] ) : '';
7465                        $form_css['arfsubmitborderwidthsetting']        = isset( $styling_opts['arfsbbws'] ) ? intval( $styling_opts['arfsbbws'] ) : '';
7466
7467                        $form_css['arfsubmitboxxoffsetsetting']       = isset( $styling_opts['arfsbxos'] ) ? intval( $styling_opts['arfsbxos'] ) : '';
7468                        $form_css['arfsubmitboxyoffsetsetting']       = isset( $styling_opts['arfsbyos'] ) ? intval( $styling_opts['arfsbyos'] ) : '';
7469                        $form_css['arfsubmitboxblursetting']          = isset( $styling_opts['arfsbbs'] ) ? intval( $styling_opts['arfsbbs'] ) : '';
7470                        $form_css['arfsubmitboxshadowsetting']        = isset( $styling_opts['arfsbsps'] ) ? intval( $styling_opts['arfsbsps'] ) : '';
7471                        $form_css['arfsubmitborderradiussetting']     = isset( $styling_opts['arfsbbrs'] ) ? intval( $styling_opts['arfsbbrs'] ) : '';
7472                        $form_css['arfsubmitshadowcolorsetting']      = isset( $styling_opts['arfsbscs'] ) ? sanitize_text_field( $styling_opts['arfsbscs'] ) : '';
7473                        $form_css['arfsubmitbuttonmarginsetting']     = isset( $styling_opts['arfsbms'] ) ? sanitize_text_field( $styling_opts['arfsbms'] ) : '';
7474                        $form_css['submit_bg_img']                    = isset( $styling_opts['arfsbis'] ) ? esc_url_raw( $styling_opts['arfsbis'] ) : '';
7475                        $form_css['submit_hover_bg_img']              = isset( $styling_opts['arfsbhis'] ) ? esc_url_raw( $styling_opts['arfsbhis'] ) : '';
7476                        $form_css['error_font']                       = isset( $styling_opts['arfmefs'] ) ? sanitize_text_field( $styling_opts['arfmefs'] ) : '';
7477                        $form_css['error_font_other']                 = isset( $styling_opts['arfmofs'] ) ? sanitize_text_field( $styling_opts['arfmofs'] ) : '';
7478                        $form_css['arffontsizesetting']               = isset( $styling_opts['arfmefss'] ) ? intval( $styling_opts['arfmefss'] ) : '';
7479                        $form_css['arferrorbgsetting']                = isset( $styling_opts['arfmebs'] ) ? sanitize_text_field( $styling_opts['arfmebs'] ) : '';
7480                        $form_css['arferrortextsetting']              = isset( $styling_opts['arfmets'] ) ? sanitize_text_field( $styling_opts['arfmets'] ) : '';
7481                        $form_css['arferrorbordersetting']            = isset( $styling_opts['arfmebos'] ) ? sanitize_text_field( $styling_opts['arfmebos'] ) : '';
7482                        $form_css['arfsucessbgcolorsetting']          = isset( $styling_opts['arfmsbcs'] ) ? sanitize_text_field( $styling_opts['arfmsbcs'] ) : '';
7483                        $form_css['arfsucessbordercolorsetting']      = isset( $styling_opts['arfmsbocs'] ) ? sanitize_text_field( $styling_opts['arfmsbocs'] ) : '';
7484                        $form_css['arfsucesstextcolorsetting']        = isset( $styling_opts['arfmstcs'] ) ? sanitize_text_field( $styling_opts['arfmstcs'] ) : '';
7485                        $form_css['arfformerrorbgcolorsettings']      = isset( $styling_opts['arffebgc'] ) ? sanitize_text_field( $styling_opts['arffebgc'] ) : '';
7486                        $form_css['arfformerrorbordercolorsettings']  = isset( $styling_opts['arffebrdc'] ) ? sanitize_text_field( $styling_opts['arffebrdc'] ) : '';
7487                        $form_css['arfformerrortextcolorsettings']    = isset( $styling_opts['arffetxtc'] ) ? sanitize_text_field( $styling_opts['arffetxtc'] ) : '';
7488                        $form_css['arfsubmitalignsetting']            = isset( $styling_opts['arfmsas'] ) ? sanitize_text_field( $styling_opts['arfmsas'] ) : '';
7489                        $form_css['checkbox_radio_style']             = isset( $styling_opts['arfcrs'] ) ? sanitize_text_field( $styling_opts['arfcrs'] ) : '';
7490                        $form_css['arfmainform_bg_img']               = isset( $styling_opts['arfmfbi'] ) ? esc_url_raw( $styling_opts['arfmfbi'] ) : '';
7491                        $form_css['arfmainform_color_skin']           = isset( $styling_opts['arfmcs'] ) ? sanitize_text_field( $styling_opts['arfmcs'] ) : '';
7492                        $form_css['arfinputstyle']                    = isset( $styling_opts['arfinpst'] ) ? sanitize_text_field( $styling_opts['arfinpst'] ) : 'standard';
7493                        $form_css['arfsubmitfontfamily']              = isset( $styling_opts['arfsff'] ) ? sanitize_text_field( $styling_opts['arfsff'] ) : '';
7494                        $form_css['arfcommonfont']                    = isset( $styling_opts['arfcommonfont'] ) ? sanitize_text_field( $styling_opts['arfcommonfont'] ) : 'Helvetica';
7495                        $form_css['arfmainfieldcommonsize']           = isset( $styling_opts['arfmainfieldcommonsize'] ) ? intval( $styling_opts['arfmainfieldcommonsize'] ) : '3';
7496                        $form_css['arfdatepickerbgcolorsetting']      = isset( $styling_opts['arfdbcs'] ) ? sanitize_text_field( $styling_opts['arfdbcs'] ) : '#23b7e5';
7497                        $form_css['arfuploadbtntxtcolorsetting']      = isset( $styling_opts['arfuptxt'] ) ? sanitize_text_field( $styling_opts['arfuptxt'] ) : '#ffffff';
7498                        $form_css['arfuploadbtnbgcolorsetting']       = isset( $styling_opts['arfupbg'] ) ? sanitize_text_field( $styling_opts['arfupbg'] ) : '#077BDD';
7499                        $form_css['arfdatepickertextcolorsetting']    = isset( $styling_opts['arfdtcs'] ) ? sanitize_text_field( $styling_opts['arfdtcs'] ) : '#ffffff';
7500
7501                        $form_css['arfmainfieldsetpadding_1']         = ( isset( $styling_opts['arfmainfieldsetpadding_1'] ) && $styling_opts['arfmainfieldsetpadding_1'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_1'] ) : 0;
7502                        $form_css['arfmainfieldsetpadding_2']         = ( isset( $styling_opts['arfmainfieldsetpadding_2'] ) && $styling_opts['arfmainfieldsetpadding_2'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_2'] ) : 0;
7503                        $form_css['arfmainfieldsetpadding_3']         = ( isset( $styling_opts['arfmainfieldsetpadding_3'] ) && $styling_opts['arfmainfieldsetpadding_3'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_3'] ) : 0;
7504                        $form_css['arfmainfieldsetpadding_4']         = ( isset( $styling_opts['arfmainfieldsetpadding_4'] ) && $styling_opts['arfmainfieldsetpadding_4'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_4'] ) : 0;
7505
7506                        $form_css['arfmainfieldsetpadding_1_tablet']         = ( isset( $styling_opts['arfmainfieldsetpadding_1_tablet'] ) && $styling_opts['arfmainfieldsetpadding_1_tablet'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_1'] ) : '';
7507                        $form_css['arfmainfieldsetpadding_2_tablet']         = ( isset( $styling_opts['arfmainfieldsetpadding_2_tablet'] ) && $styling_opts['arfmainfieldsetpadding_2_tablet'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_2_tablet'] ) : '';
7508                        $form_css['arfmainfieldsetpadding_3_tablet']         = ( isset( $styling_opts['arfmainfieldsetpadding_3_tablet'] ) && $styling_opts['arfmainfieldsetpadding_3_tablet'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_3_tablet'] ) : '';
7509                        $form_css['arfmainfieldsetpadding_4']         = ( isset( $styling_opts['arfmainfieldsetpadding_4_tablet'] ) && $styling_opts['arfmainfieldsetpadding_4_tablet'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_4_tablet'] ) : '';
7510
7511                        $form_css['arfmainfieldsetpadding_1_mobile']         = ( isset( $styling_opts['arfmainfieldsetpadding_1_mobile'] ) && $styling_opts['arfmainfieldsetpadding_1_mobile'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_1'] ) : '';
7512                        $form_css['arfmainfieldsetpadding_2_mobile']         = ( isset( $styling_opts['arfmainfieldsetpadding_2_mobile'] ) && $styling_opts['arfmainfieldsetpadding_2_mobile'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_2_mobile'] ) : '';
7513                        $form_css['arfmainfieldsetpadding_3_mobile']         = ( isset( $styling_opts['arfmainfieldsetpadding_3_mobile'] ) && $styling_opts['arfmainfieldsetpadding_3_mobile'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_3_mobile'] ) : '';
7514                        $form_css['arfmainfieldsetpadding_4']         = ( isset( $styling_opts['arfmainfieldsetpadding_4_mobile'] ) && $styling_opts['arfmainfieldsetpadding_4_mobile'] != '' ) ? intval( $styling_opts['arfmainfieldsetpadding_4_mobile'] ) : '';
7515
7516               
7517
7518                        $form_css['arfmainformtitlepaddingsetting_1'] = ( isset( $styling_opts['arfformtitlepaddingsetting_1'] ) && $styling_opts['arfformtitlepaddingsetting_1'] != '' ) ? intval( $styling_opts['arfformtitlepaddingsetting_1'] ) : 0;
7519                        $form_css['arfmainformtitlepaddingsetting_2'] = ( isset( $styling_opts['arfformtitlepaddingsetting_2'] ) && $styling_opts['arfformtitlepaddingsetting_2'] != '' ) ? intval( $styling_opts['arfformtitlepaddingsetting_2'] ) : 0;
7520                        $form_css['arfmainformtitlepaddingsetting_3'] = ( isset( $styling_opts['arfformtitlepaddingsetting_3'] ) && $styling_opts['arfformtitlepaddingsetting_3'] != '' ) ? intval( $styling_opts['arfformtitlepaddingsetting_3'] ) : 0;
7521                        $form_css['arfmainformtitlepaddingsetting_4'] = ( isset( $styling_opts['arfformtitlepaddingsetting_4'] ) && $styling_opts['arfformtitlepaddingsetting_4'] != '' ) ? intval( $styling_opts['arfformtitlepaddingsetting_4'] ) : 0;
7522                        $form_css['arffieldinnermarginssetting_1']    = ( isset( $styling_opts['arffieldinnermarginsetting_1'] ) && $styling_opts['arffieldinnermarginsetting_1'] != '' ) ? intval( $styling_opts['arffieldinnermarginsetting_1'] ) : 0;
7523                        $form_css['arffieldinnermarginssetting_2']    = ( isset( $styling_opts['arffieldinnermarginsetting_2'] ) && $styling_opts['arffieldinnermarginsetting_2'] != '' ) ? intval( $styling_opts['arffieldinnermarginsetting_2'] ) : 0;
7524                        $form_css['arffieldinnermarginssetting_3']    = ( isset( $styling_opts['arffieldinnermarginsetting_3'] ) && $styling_opts['arffieldinnermarginsetting_3'] != '' ) ? intval( $styling_opts['arffieldinnermarginsetting_3'] ) : 0;
7525                        $form_css['arffieldinnermarginssetting_4']    = ( isset( $styling_opts['arffieldinnermarginsetting_4'] ) && $styling_opts['arffieldinnermarginsetting_4'] != '' ) ? intval( $styling_opts['arffieldinnermarginsetting_4'] ) : 0;
7526                        $form_css['arfsubmitbuttonmarginsetting_1']   = ( isset( $styling_opts['arfsubmitbuttonmarginsetting_1'] ) && $styling_opts['arfsubmitbuttonmarginsetting_1'] != '' ) ? intval( $styling_opts['arfsubmitbuttonmarginsetting_1'] ) : 0;
7527                        $form_css['arfsubmitbuttonmarginsetting_2']   = ( isset( $styling_opts['arfsubmitbuttonmarginsetting_2'] ) && $styling_opts['arfsubmitbuttonmarginsetting_2'] != '' ) ? intval( $styling_opts['arfsubmitbuttonmarginsetting_2'] ) : 0;
7528                        $form_css['arfsubmitbuttonmarginsetting_3']   = ( isset( $styling_opts['arfsubmitbuttonmarginsetting_3'] ) && $styling_opts['arfsubmitbuttonmarginsetting_3'] != '' ) ? intval( $styling_opts['arfsubmitbuttonmarginsetting_3'] ) : 0;
7529                        $form_css['arfsubmitbuttonmarginsetting_4']   = ( isset( $styling_opts['arfsubmitbuttonmarginsetting_4'] ) && $styling_opts['arfsubmitbuttonmarginsetting_4'] != '' ) ? intval( $styling_opts['arfsubmitbuttonmarginsetting_4'] ) : 0;
7530
7531                        $form_css['arfcheckradiostyle']          = isset( $styling_opts['arfcksn'] ) ? sanitize_text_field( $styling_opts['arfcksn'] ) : '';
7532                        $form_css['arfcheckradiocolor']          = isset( $styling_opts['arfcksc'] ) ? sanitize_text_field( $styling_opts['arfcksc'] ) : '';
7533                        $form_css['arf_checked_checkbox_icon']   = isset( $styling_opts['arf_checkbox_icon'] ) ? sanitize_text_field( $styling_opts['arf_checkbox_icon'] ) : '';
7534                        $form_css['enable_arf_checkbox']         = isset( $styling_opts['enable_arf_checkbox'] ) ? intval( $styling_opts['enable_arf_checkbox'] ) : '';
7535                        $form_css['arf_checked_radio_icon']      = isset( $styling_opts['arf_radio_icon'] ) ? sanitize_text_field( $styling_opts['arf_radio_icon'] ) : '';
7536                        $form_css['enable_arf_radio']            = isset( $styling_opts['enable_arf_radio'] ) ? intval( $styling_opts['enable_arf_radio'] ) : '';
7537                        $form_css['checked_checkbox_icon_color'] = isset( $styling_opts['cbscol'] ) ? sanitize_text_field( $styling_opts['cbscol'] ) : '';
7538                        $form_css['checked_radio_icon_color']    = isset( $styling_opts['rbscol'] ) ? sanitize_text_field( $styling_opts['rbscol'] ) : '';
7539                        $form_css['arferrorstyle']               = isset( $styling_opts['arfest'] ) ? sanitize_text_field( $styling_opts['arfest'] ) : '';
7540                        $form_css['arferrorstylecolor']          = isset( $styling_opts['arfestc'] ) ? sanitize_text_field( $styling_opts['arfestc'] ) : '';
7541                        $form_css['arferrorstylecolor2']         = isset( $styling_opts['arfestc2'] ) ? sanitize_text_field( $styling_opts['arfestc2'] ) : '';
7542                        $form_css['arferrorstyleposition']       = isset( $styling_opts['arfestbc'] ) ? sanitize_text_field( $styling_opts['arfestbc'] ) : '';
7543                        $form_css['arfsuccessmsgposition']       = isset( $styling_opts['arfsuccessmsgposition'] ) ? sanitize_text_field( $styling_opts['arfsuccessmsgposition'] ) : '';
7544                        $form_css['arfstandarderrposition']      = isset( $styling_opts['arfstndrerr'] ) ? sanitize_text_field( $styling_opts['arfstndrerr'] ) : 'relative';
7545                        $form_css['arfformtitlealign']           = isset( $styling_opts['arffta'] ) ? sanitize_text_field( $styling_opts['arffta'] ) : '';
7546                        $form_css['arfsubmitautowidth']          = isset( $styling_opts['arfsbaw'] ) ? intval( $styling_opts['arfsbaw'] ) : '';
7547                        $form_css['arftitlefontfamily']          = isset( $styling_opts['arftff'] ) ? sanitize_text_field( $styling_opts['arftff'] ) : '';
7548
7549                        if ( isset( $styling_opts['arfmainform_opacity'] ) && $styling_opts['arfmainform_opacity'] > 1 ) {
7550                                $form_css['arfmainform_opacity'] = '1';
7551                        } else {
7552                                $form_css['arfmainform_opacity'] = isset( $styling_opts['arfmainform_opacity'] ) ? floatval( $styling_opts['arfmainform_opacity'] ) : '';
7553                        }
7554
7555                        if ( isset( $styling_opts['arfplaceholder_opacity'] ) && $styling_opts['arfplaceholder_opacity'] > 1 ) {
7556                                $form_css['arfplaceholder_opacity'] = '1';
7557                        } else {
7558                                $form_css['arfplaceholder_opacity'] = isset( $styling_opts['arfplaceholder_opacity'] ) ? floatval( $styling_opts['arfplaceholder_opacity'] ) : '0.50';
7559                        }
7560                        $form_css['arfmainfield_opacity']     = isset( $styling_opts['arfmfo'] ) ? intval( $styling_opts['arfmfo'] ) : '';
7561                        $form_css['arf_req_indicator']        = isset( $styling_opts['arfrinc'] ) ? intval( $styling_opts['arfrinc'] ) : '0';
7562                        $form_css['prefix_suffix_bg_color']   = isset( $styling_opts['pfsfsbg'] ) ? sanitize_text_field( $styling_opts['pfsfsbg'] ) : '';
7563                        $form_css['prefix_suffix_icon_color'] = isset( $styling_opts['pfsfscol'] ) ? sanitize_text_field( $styling_opts['pfsfscol'] ) : '';
7564                        $form_css['arf_tooltip_bg_color']     = isset( $styling_opts['arf_tooltip_bg_color'] ) ? sanitize_text_field( $styling_opts['arf_tooltip_bg_color'] ) : '';
7565                        $form_css['arf_tooltip_font_color']   = isset( $styling_opts['arf_tooltip_font_color'] ) ? sanitize_text_field( $styling_opts['arf_tooltip_font_color'] ) : '';
7566                        $form_css['arf_tooltip_width']        = isset( $styling_opts['arf_tooltip_width'] ) ? sanitize_text_field( $styling_opts['arf_tooltip_width'] ) : '';
7567
7568                        $form_css['arftooltipposition'] = isset( $styling_opts['arflitetippos'] ) ? sanitize_text_field( $styling_opts['arflitetippos'] ) : '';
7569
7570                        $form_css['arfsubmitbuttonstyle'] = isset( $styling_opts['arfsubmitbuttonstyle'] ) ? sanitize_text_field( $styling_opts['arfsubmitbuttonstyle'] ) : 'border';
7571
7572                        $form_css['arfmainbasecolor']           = isset( $styling_opts['arfmbsc'] ) ? sanitize_text_field( $styling_opts['arfmbsc'] ) : '';
7573                        $form_css['arferrorbordercolorsetting'] = sanitize_text_field( $form_css['arfmainbasecolor'] );
7574
7575                        $form_css['arfsliderselectioncolor'] = isset( $styling_opts['asldrsl'] ) ? sanitize_text_field( $styling_opts['asldrsl'] ) : '';
7576                        $form_css['arfslidertrackcolor']     = isset( $styling_opts['asltrcl'] ) ? sanitize_text_field( $styling_opts['asltrcl'] ) : '';
7577                        $new_values                          = array();
7578                        $arfssl                              = ( is_ssl() ) ? 1 : 0;
7579                        foreach ( $form_css as $k => $val ) {
7580                                $new_values[ $k ] = $val;
7581                        }
7582                        $css_rtl_filename    = ARFLITE_FORMPATH . '/core/arflite_css_create_rtl.php';
7583                        $css_common_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_common.php';
7584                        $css_filename        = ARFLITE_FORMPATH . '/core/arflite_css_create_main.php';
7585                        if ( $style == 'material' ) {
7586                                $css_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_materialize.php';
7587                        }
7588                        ob_start();
7589                        $use_saved    = true;
7590                        $is_form_save = true;
7591                        include $css_filename;
7592                        include $css_common_filename;
7593                        if ( is_rtl() ) {
7594                                include $css_rtl_filename;
7595                        }
7596                        $css           = ob_get_contents();
7597                        $css           = str_replace( '##', '#', $css );
7598                        $return['css'] = $css;
7599                        ob_end_clean();
7600                }
7601                $frm_css          = $new_values;
7602                $data['form_css'] = maybe_serialize( $frm_css );
7603                $newarr           = array();
7604                $arr              = $data['form_css'];
7605                if ( isset( $arr ) && ! empty( $arr ) && is_array( $arr ) ) {
7606                        foreach ( $arr as $k => $v ) {
7607                                $newarr[ $k ] = $v;
7608                        }
7609                }
7610                foreach ( $arf_fields as $field ) {
7611
7612                        $display_field_in_editor_from_outside = apply_filters( 'arflite_display_field_in_editor_outside', false, $field );
7613
7614                        if ( is_array( $field ) ) {
7615                                $field['name'] = $this->arflite_html_entity_decode( $field['name'], true );
7616
7617                                $field['form_id'] = $form_id;
7618                                $field_name       = 'item_meta[' . $field['id'] . ']';
7619                                $has_field_opt    = false;
7620                                if ( isset( $field['options'] ) && $field['options'] != '' && ! empty( $field['options'] ) ) {
7621                                        $has_field_opt    = true;
7622                                        $field_options_db = @json_decode( $field['options'], true );
7623                                        if ( json_last_error() != JSON_ERROR_NONE ) {
7624                                                $field_options_db = maybe_unserialize( $field['options'], true );
7625                                        }
7626                                }
7627
7628                                $field_opt = json_decode( $field['field_options'], true );
7629                                $class     = ( isset( $field_opt['inner_class'] ) && $field_opt['inner_class'] ) ? $field_opt['inner_class'] : 'arf_1col';
7630                                array_push( $class_array, $field_opt['inner_class'] );
7631
7632                                if ( json_last_error() != JSON_ERROR_NONE ) {
7633                                        $field_opt = maybe_unserialize( $field['field_options'] );
7634                                }
7635
7636                                if ( isset( $field_opt ) && ! empty( $field_opt ) ) {
7637                                        foreach ( $field_opt as $k => $field_opt_val ) {
7638                                                if ( $k != 'options' ) {
7639                                                        $field[ $k ] = $this->arflite_html_entity_decode( $field_opt_val );
7640                                                } else {
7641                                                        if ( $has_field_opt == true && $k == 'options' ) {
7642                                                                $field[ $k ] = $field_options_db;
7643                                                        }
7644                                                }
7645                                        }
7646                                }
7647                        }
7648                        if ( ! $display_field_in_editor_from_outside ) {
7649                                $filename = ARFLITE_VIEWS_PATH . '/arflite_field_editor.php';
7650                                ob_start();
7651                                include $filename;
7652                                $content .= ob_get_contents();
7653                                ob_end_clean();
7654                                unset( $field );
7655                                unset( $field_name );
7656                        }
7657                        $arf_field_counter++;
7658                }
7659                $return['content'] = $content;
7660                echo json_encode( $return );
7661                die();
7662        }
7663
7664        function arfliteSearchArray( $id, $column, $array ) {
7665                foreach ( $array as $key => $val ) {
7666                        if ( $val[ $column ] == $id ) {
7667                                return $key;
7668                        }
7669                }
7670                return null;
7671        }
7672
7673        function arflite_html_entity_decode( $data ) {
7674                if ( is_array( $data ) ) {
7675                        return array_map( array( $this, __FUNCTION__ ), $data );
7676                } elseif ( is_object( $data ) ) {
7677                        $data = $this->arfliteObjtoArray( $data );
7678                        return array_map( array( $this, __FUNCTION__ ), $data );
7679                } else {
7680                        return html_entity_decode( $data );
7681                }
7682        }
7683
7684        function arfliteHtmlEntities( $data, $addslashes = false ) {
7685                if ( is_array( $data ) ) {
7686                        return array_map( array( $this, __FUNCTION__ ), $data );
7687                } elseif ( is_object( $data ) ) {
7688                        $data = $this->arfliteObjtoArray( $data );
7689                        return array_map( array( $this, __FUNCTION__ ), $data );
7690                } else {
7691                        if ( $addslashes ) {
7692                                return addslashes( htmlentities( $data ) );
7693                        } else {
7694                                return htmlentities( $data );
7695                        }
7696                }
7697        }
7698
7699        function arflitegetfieldfromid( $field_id, $field_values, $type = 'object' ) {
7700                if ( $field_id == '' || $field_id < 1 ) {
7701                        return false;
7702                }
7703
7704                if ( preg_match( '/(\d+)\.(\d+)/', $field_id, $match ) ) {
7705                        $field_id = $match[1];
7706                }
7707
7708                if ( is_object( $field_values ) ) {
7709                        $field_values = $this->arfliteObjtoArray( $field_values );
7710                }
7711
7712                $newObject = array();
7713                $key       = $this->arfliteSearchArray( $field_id, 'id', $field_values );
7714                $object    = isset( $field_values[ $key ] ) ? $field_values[ $key ] : array();
7715                if ( $type == 'object' ) {
7716                        $object = $this->arfliteArraytoObj( $object );
7717                }
7718                return $object;
7719        }
7720
7721        function arflitecode_to_country( $code = '', $country_name = '', $all = fale ) {
7722                $countryList = array(
7723                        'AF' => 'Afghanistan',
7724                        'AX' => 'Aland Islands',
7725                        'AL' => 'Albania',
7726                        'DZ' => 'Algeria',
7727                        'AS' => 'American Samoa',
7728                        'AD' => 'Andorra',
7729                        'AO' => 'Angola',
7730                        'AI' => 'Anguilla',
7731                        'AQ' => 'Antarctica',
7732                        'AG' => 'Antigua and Barbuda',
7733                        'AR' => 'Argentina',
7734                        'AM' => 'Armenia',
7735                        'AW' => 'Aruba',
7736                        'AU' => 'Australia',
7737                        'AT' => 'Austria',
7738                        'AZ' => 'Azerbaijan',
7739                        'BS' => 'Bahamas',
7740                        'BH' => 'Bahrain',
7741                        'BD' => 'Bangladesh',
7742                        'BB' => 'Barbados',
7743                        'BY' => 'Belarus',
7744                        'BE' => 'Belgium',
7745                        'BZ' => 'Belize',
7746                        'BJ' => 'Benin',
7747                        'BM' => 'Bermuda',
7748                        'BT' => 'Bhutan',
7749                        'BO' => 'Bolivia',
7750                        'BQ' => 'Bonaire',
7751                        'BA' => 'Bosnia and Herzegovina',
7752                        'BW' => 'Botswana',
7753                        'BV' => 'Bouvet Island',
7754                        'BR' => 'Brazil',
7755                        'IO' => 'British Indian Ocean Territory',
7756                        'VG' => 'British Virgin Islands',
7757                        'BN' => 'Brunei Darussalam',
7758                        'BG' => 'Bulgaria',
7759                        'BF' => 'Burkina Faso',
7760                        'BI' => 'Burundi',
7761                        'KH' => 'Cambodia',
7762                        'CM' => 'Cameroon',
7763                        'CA' => 'Canada',
7764                        'CV' => 'Cape Verde',
7765                        'KY' => 'Cayman Islands',
7766                        'CF' => 'Central African Republic',
7767                        'TD' => 'Chad',
7768                        'CL' => 'Chile',
7769                        'CN' => 'China',
7770                        'CX' => 'Christmas Island',
7771                        'CC' => 'Cocos (Keeling) Islands',
7772                        'CO' => 'Colombia',
7773                        'KM' => 'Comoros',
7774                        'CD' => 'Democratic Republic of the Congo',
7775                        'CG' => 'Congo',
7776                        'CK' => 'Cook Islands',
7777                        'CR' => 'Costa Rica',
7778                        'CI' => 'Cote d\'Ivoire',
7779                        'HR' => 'Croatia',
7780                        'CU' => 'Cuba',
7781                        'CW' => 'Curacao',
7782                        'CY' => 'Cyprus',
7783                        'CZ' => 'Czech Republic',
7784                        'DK' => 'Denmark',
7785                        'DJ' => 'Djibouti',
7786                        'DM' => 'Dominica',
7787                        'DO' => 'Dominican Republic',
7788                        'EC' => 'Ecuador',
7789                        'EG' => 'Egypt',
7790                        'SV' => 'El Salvador',
7791                        'GQ' => 'Equatorial Guinea',
7792                        'ER' => 'Eritrea',
7793                        'EE' => 'Estonia',
7794                        'ET' => 'Ethiopia',
7795                        'FO' => 'Faroe Islands',
7796                        'FK' => 'Falkland Islands (Malvinas)',
7797                        'FJ' => 'Fiji',
7798                        'FI' => 'Finland',
7799                        'FR' => 'France',
7800                        'GF' => 'French Guiana',
7801                        'PF' => 'French Polynesia',
7802                        'TF' => 'French Southern Territories',
7803                        'GA' => 'Gabon',
7804                        'GM' => 'Gambia',
7805                        'GE' => 'Georgia',
7806                        'DE' => 'Germany',
7807                        'GH' => 'Ghana',
7808                        'GI' => 'Gibraltar',
7809                        'GR' => 'Greece',
7810                        'GL' => 'Greenland',
7811                        'GD' => 'Grenada',
7812                        'GP' => 'Guadeloupe',
7813                        'GU' => 'Guam',
7814                        'GT' => 'Guatemala',
7815                        'GG' => 'Guernsey',
7816                        'GN' => 'Guinea',
7817                        'GW' => 'Guinea-Bissau',
7818                        'GY' => 'Guyana',
7819                        'HT' => 'Haiti',
7820                        'HM' => 'Heard Island and McDonald Islands',
7821                        'VA' => 'Holy See (Vatican City State)',
7822                        'HN' => 'Honduras',
7823                        'HK' => 'Hong Kong',
7824                        'HU' => 'Hungary',
7825                        'IS' => 'Iceland',
7826                        'IN' => 'India',
7827                        'ID' => 'Indonesia',
7828                        'IR' => 'Iran',
7829                        'IQ' => 'Iraq',
7830                        'IE' => 'Ireland',
7831                        'IM' => 'Isle of Man',
7832                        'IL' => 'Israel',
7833                        'IT' => 'Italy',
7834                        'JM' => 'Jamaica',
7835                        'JP' => 'Japan',
7836                        'JE' => 'Jersey',
7837                        'JO' => 'Jordan',
7838                        'KZ' => 'Kazakhstan',
7839                        'KE' => 'Kenya',
7840                        'KI' => 'Kiribati',
7841                        'KP' => 'Korea, Democratic People\'s Republic of',
7842                        'KR' => 'Korea, Republic of',
7843                        'KW' => 'Kuwait',
7844                        'KG' => 'Kyrgyzstan',
7845                        'LA' => 'Lao People\'s Democratic Republic',
7846                        'LV' => 'Latvia',
7847                        'LB' => 'Lebanon',
7848                        'LS' => 'Lesotho',
7849                        'LR' => 'Liberia',
7850                        'LY' => 'Libyan',
7851                        'LI' => 'Liechtenstein',
7852                        'LT' => 'Lithuania',
7853                        'LU' => 'Luxembourg',
7854                        'MO' => 'Macao',
7855                        'MK' => 'Macedonia, the Former Yugoslav Republic of',
7856                        'MG' => 'Madagascar',
7857                        'MW' => 'Malawi',
7858                        'MY' => 'Malaysia',
7859                        'MV' => 'Maldives',
7860                        'ML' => 'Mali',
7861                        'MT' => 'Malta',
7862                        'MH' => 'Marshall Islands',
7863                        'MQ' => 'Martinique',
7864                        'MR' => 'Mauritania',
7865                        'MU' => 'Mauritius',
7866                        'YT' => 'Mayotte',
7867                        'MX' => 'Mexico',
7868                        'FM' => 'Micronesia, Federated States of',
7869                        'MD' => 'Moldova, Republic of',
7870                        'MC' => 'Monaco',
7871                        'MN' => 'Mongolia',
7872                        'ME' => 'Montenegro',
7873                        'MS' => 'Montserrat',
7874                        'MA' => 'Morocco',
7875                        'MZ' => 'Mozambique',
7876                        'MM' => 'Myanmar',
7877                        'NA' => 'Namibia',
7878                        'NR' => 'Nauru',
7879                        'NP' => 'Nepal',
7880                        'AN' => 'Netherlands Antilles',
7881                        'NL' => 'Netherlands',
7882                        'NC' => 'New Caledonia',
7883                        'NZ' => 'New Zealand',
7884                        'NI' => 'Nicaragua',
7885                        'NE' => 'Niger',
7886                        'NG' => 'Nigeria',
7887                        'NU' => 'Niue',
7888                        'NF' => 'Norfolk Island',
7889                        'MP' => 'Northern Mariana Islands',
7890                        'NO' => 'Norway',
7891                        'OM' => 'Oman',
7892                        'PK' => 'Pakistan',
7893                        'PW' => 'Palau',
7894                        'PS' => 'Palestine, State of',
7895                        'PA' => 'Panama',
7896                        'PG' => 'Papua New Guinea',
7897                        'PY' => 'Paraguay',
7898                        'PE' => 'Peru',
7899                        'PH' => 'Philippines',
7900                        'PN' => 'Pitcairn',
7901                        'PL' => 'Poland',
7902                        'PT' => 'Portugal',
7903                        'PR' => 'Puerto Rico',
7904                        'QA' => 'Qatar',
7905                        'RE' => 'Reunion',
7906                        'RO' => 'Romania',
7907                        'RU' => 'Russian Federation',
7908                        'RW' => 'Rwanda',
7909                        'BL' => 'Saint Barthelemy',
7910                        'SH' => 'Saint Helena',
7911                        'KN' => 'Saint Kitts and Nevis',
7912                        'LC' => 'Saint Lucia',
7913                        'MF' => 'Saint Martin (French part)',
7914                        'PM' => 'Saint Pierre and Miquelon',
7915                        'VC' => 'Saint Vincent and the Grenadines',
7916                        'WS' => 'Samoa',
7917                        'SM' => 'San Marino',
7918                        'ST' => 'Sao Tome and Principe',
7919                        'SA' => 'Saudi Arabia',
7920                        'SN' => 'Senegal',
7921                        'RS' => 'Serbia',
7922                        'SC' => 'Seychelles',
7923                        'SL' => 'Sierra Leone',
7924                        'SG' => 'Singapore',
7925                        'SX' => 'Sint Maarten (Dutch part)',
7926                        'SK' => 'Slovakia',
7927                        'SI' => 'Slovenia',
7928                        'SB' => 'Solomon Islands',
7929                        'SO' => 'Somalia',
7930                        'ZA' => 'South Africa',
7931                        'SS' => 'South Sudan',
7932                        'GS' => 'South Georgia and the South Sandwich Islands',
7933                        'ES' => 'Spain',
7934                        'LK' => 'Sri Lanka',
7935                        'SD' => 'Sudan',
7936                        'SR' => 'Suriname',
7937                        'SJ' => 'Svalbard and Jan Mayen',
7938                        'SZ' => 'Swaziland',
7939                        'SE' => 'Sweden',
7940                        'CH' => 'Switzerland',
7941                        'SY' => 'Syrian Arab Republic',
7942                        'TW' => 'Taiwan, Province of China',
7943                        'TJ' => 'Tajikistan',
7944                        'TZ' => 'United Republic of Tanzania',
7945                        'TH' => 'Thailand',
7946                        'TL' => 'Timor-Leste',
7947                        'TG' => 'Togo',
7948                        'TK' => 'Tokelau',
7949                        'TO' => 'Tonga',
7950                        'TT' => 'Trinidad and Tobago',
7951                        'TN' => 'Tunisia',
7952                        'TR' => 'Turkey',
7953                        'TM' => 'Turkmenistan',
7954                        'TC' => 'Turks and Caicos Islands',
7955                        'TV' => 'Tuvalu',
7956                        'UG' => 'Uganda',
7957                        'UA' => 'Ukraine',
7958                        'AE' => 'United Arab Emirates',
7959                        'GB' => 'United Kingdom',
7960                        'US' => 'United States of America',
7961                        'US' => 'United States',
7962                        'UM' => 'United States Minor Outlying Islands',
7963                        'VI' => 'United States Virgin Islands',
7964                        'UY' => 'Uruguay',
7965                        'UZ' => 'Uzbekistan',
7966                        'VU' => 'Vanuatu',
7967                        'VE' => 'Venezuela',
7968                        'VN' => 'Viet Nam',
7969                        'VG' => 'British Virgin Islands',
7970                        'VI' => 'US Virgin Islands',
7971                        'WF' => 'Wallis and Futuna',
7972                        'EH' => 'Western Sahara',
7973                        'YE' => 'Yemen',
7974                        'ZM' => 'Zambia',
7975                        'ZW' => 'Zimbabwe',
7976                );
7977                if ( $all ) {
7978                        return $countryList;
7979                }
7980                if ( isset( $code ) ) {
7981                        return array_search( $code, $countryList );
7982                }
7983        }
7984        function arflitereturndateformate() {
7985                $return_array                      = array();
7986                $return_array['arfwp_dateformate'] = $wp_format_date = get_option( 'date_format' );
7987                if ( $wp_format_date == 'F j, Y' ) {
7988                        $date_format_new = 'MMMM D, YYYY';
7989                } elseif ( $wp_format_date == 'Y-m-d' ) {
7990                        $date_format_new = 'YYYY-MM-DD';
7991                } elseif ( $wp_format_date == 'm/d/Y' ) {
7992                        $date_format_new = 'MM/DD/YYYY';
7993                } elseif ( $wp_format_date == 'd/m/Y' ) {
7994                        $date_format_new = 'DD/MM/YYYY';
7995                } elseif ( $wp_format_date == 'Y/m/d' ) {
7996                        $date_format_new = 'DD/MM/YYYY';
7997                } else {
7998                        $date_format_new = 'MM/DD/YYYY';
7999                }
8000                $return_array['arfjs_dateformate'] = $date_format_new;
8001                return $return_array;
8002        }
8003
8004
8005
8006        function arflite_after_submit_sucess_outside_function( $return_script, $form ) {
8007                $arf_form_option              = isset( $form->options ) ? $form->options : '';
8008                $arf_sub_track_code           = isset( $arf_form_option['arf_sub_track_code'] ) ? $arf_form_option['arf_sub_track_code'] : '';
8009                $arf_submission_tracking_code = trim( rawurldecode( stripslashes_deep( $arf_sub_track_code ) ) );
8010                if ( $arf_submission_tracking_code != '' ) {
8011                        $return_script .= "<script type='text/javascript'>";
8012                        $return_script .= $arf_submission_tracking_code;
8013                        $return_script .= '</script>';
8014                        return $return_script;
8015                }
8016        }
8017
8018        function arflite_load_form_css( $form_id, $inputStyle ) {
8019
8020                global $arformsmain, $arflite_jscss_version, $arfliteversion,$is_gutenberg;
8021                $arf_db_version  = get_option( 'arflite_db_version' );
8022                $upload_main_url = ARFLITE_UPLOAD_URL . '/maincss';
8023                $is_material     = false;
8024                $materialize_css = '';
8025                if ( $inputStyle == 'material' ) {
8026                        $materialize_css = 'materialize_';
8027                        $is_material     = true;
8028                }
8029                if ( is_ssl() ) {
8030                        $fid = str_replace( 'http://', 'https://', $upload_main_url . '/maincss_' . $materialize_css . $form_id . '.css?ver=' . $arflite_jscss_version );
8031                } else {
8032                        $fid = $upload_main_url . '/maincss_' . $materialize_css . $form_id . '.css?ver=' . $arflite_jscss_version;
8033                }
8034
8035                $fid = esc_url_raw( $fid );
8036
8037                $return_link        = '';
8038                $stylesheet_handler = 'arfliteformscss_' . $materialize_css . $form_id;
8039                if($is_gutenberg)
8040                {
8041                        $arflite_gutenberg_materialize_css= ARFLITEURL."/css/arflite_front.css?ver=$arflite_jscss_version";
8042                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$fid}' />";
8043                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$arflite_gutenberg_materialize_css}' />";
8044                }
8045                global $is_divibuilder;
8046                if($is_divibuilder)
8047                {
8048                        $arf_selectpiker = ARFLITEURL . "/css/arflite_selectpicker.css?ver=1.6.0";
8049                        $arflite_gutenberg_materialize_css= ARFLITEURL."/css/arflite_front.css?ver=$arflite_jscss_version";
8050                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$fid}' />";
8051                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$arflite_gutenberg_materialize_css}' />";
8052                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$arf_selectpiker}' />";
8053                }
8054
8055                global $is_fusionbuilder;
8056                if($is_fusionbuilder)
8057                {
8058                        $arf_selectpiker = ARFLITEURL . "/css/arflite_selectpicker.css?ver=1.6.0";
8059                        $arflite_gutenberg_materialize_css= ARFLITEURL."/css/arflite_front.css?ver=$arflite_jscss_version";
8060                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$fid}' />";
8061                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$arflite_gutenberg_materialize_css}' />";
8062                        $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$arf_selectpiker}' />";
8063                }
8064
8065                if ( ! wp_style_is( $stylesheet_handler, 'enqueued' ) ) {
8066                        $arfmainformloadjscss = $arformsmain->arforms_get_settings('arfmainformloadjscss','general_settings');
8067                        $arfmainformloadjscss = !empty( $arfmainformloadjscss ) ? $arfmainformloadjscss : 0;
8068                        if ( $arfmainformloadjscss != 1 ) {
8069                                wp_enqueue_style( $stylesheet_handler, $fid, array(), $arflite_jscss_version );
8070                        } else {
8071                                $new_key = '';
8072                                global $ARFLiteMdlDb,$arflitemainhelper, $tbl_arf_forms;
8073                                $unique_key = $arflitemainhelper->arflite_get_unique_key( $new_key, $tbl_arf_forms, 'form_key' );
8074                        }
8075                } 
8076                else {
8077                        if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
8078                                $return_link .= "<link rel='stylesheet' type='text/css' id='{$stylesheet_handler}-fallback-css' href='{$fid}' />";
8079                        }
8080                }
8081                return $return_link;
8082        }
8083
8084        function arflite_replace_default_value_shortcode_func( $default_value, $field, $form ) {
8085
8086                if ( '' == $default_value || is_array( $default_value ) ) {
8087                        return $default_value;
8088                }
8089
8090                $current_user = wp_get_current_user();
8091
8092                $pattern = '/(\[arf_current_user_detail(\s+)field\=(\'|\")(.*?)(\'|\")\])/';
8093
8094                preg_match_all( $pattern, $default_value, $matches );
8095
8096                foreach ( $matches as $parent_k => $match ) {
8097                        if ( isset( $match ) && is_array( $match ) && count( $match ) == 1 ) {
8098                                if ( $parent_k == 4 ) {
8099                                        $meta_key = isset( $match[0] ) ? $match[0] : '';
8100                                        if ( $meta_key == '' ) {
8101                                                $default_value = preg_replace( $pattern, '', $default_value );
8102                                        } elseif ( 0 == $current_user->ID || $current_user->ID < 1 ) {
8103                                                $default_value = preg_replace( $pattern, '', $default_value );
8104                                        } else {
8105                                                $user_obj = get_userdata( $current_user->ID );
8106
8107                                                if ( isset( $user_obj->data->$meta_key ) ) {
8108                                                        $default_value = preg_replace( $pattern, $user_obj->data->$meta_key, $default_value );
8109                                                } else {
8110                                                        $user_meta = get_user_meta( $current_user->ID, $meta_key, true );
8111
8112                                                        if ( is_array( $user_meta ) ) {
8113                                                                $user_meta = implode( ',', $user_meta );
8114                                                        }
8115                                                        $default_value = preg_replace( $pattern, $user_meta, $default_value );
8116                                                }
8117                                        }
8118                                }
8119                        } elseif ( isset( $match ) && is_array( $match ) && count( $match ) > 1 ) {
8120                                if ( $parent_k == 4 ) {
8121                                        $meta_keys = $match;
8122                                        foreach ( $meta_keys as $meta_key ) {
8123                                                $pattern_new = '/(\[arf_current_user_detail(\s+)field\=(\'|\")' . $meta_key . '(\'|\")\])/';
8124                                                if ( $meta_key == '' ) {
8125                                                        $default_value = preg_replace( $pattern_new, '', $default_value );
8126                                                } elseif ( 0 == $current_user->ID || $current_user->ID < 1 ) {
8127                                                        $default_value = preg_replace( $pattern_new, '', $default_value );
8128                                                } else {
8129                                                        $user_obj = get_userdata( $current_user->ID );
8130                                                        if ( isset( $user_obj->data->$meta_key ) ) {
8131                                                                $default_value = preg_replace( $pattern_new, $user_obj->data->$meta_key, $default_value );
8132                                                        } else {
8133                                                                $user_meta = get_user_meta( $current_user->ID, $meta_key, true );
8134
8135                                                                if ( is_array( $user_meta ) ) {
8136                                                                        $user_meta = implode( ',', $user_meta );
8137                                                                }
8138
8139                                                                $default_value = preg_replace( $pattern_new, $user_meta, $default_value );
8140                                                        }
8141                                                }
8142                                        }
8143                                }
8144                        } else {
8145                                $default_value = preg_replace( $pattern, '', $default_value );
8146                        }
8147                }
8148
8149                return $default_value;
8150        }
8151
8152        function arflite_remove_preview_data() {
8153
8154                if ( isset( $_POST['_wpnonce_arflite'] ) && '' != $_POST['_wpnonce_arflite'] && ! wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce_arflite'] ), 'arflite_wp_nonce' ) ) {
8155                        echo esc_attr( 'security_error' );
8156                        die;
8157                }
8158
8159                $opt_id = isset( $_POST['opt_id'] ) ? sanitize_text_field( $_POST['opt_id'] ) : '';
8160
8161                if ( $opt_id != '' ) {
8162                        delete_option( $opt_id );
8163                        echo esc_html( $opt_id ) . ' removed successfully';
8164                }
8165                die;
8166        }
8167
8168        function arflite_rewrite_form_css( $form_id, $frm_css ) {
8169                global $wpdb, $ARFLiteMdlDb, $arfliteform, $tbl_arf_fields;
8170
8171                if ( empty( $form_id ) || empty( $frm_css ) ) {
8172                        return;
8173                }
8174
8175                if ( ! function_exists( 'WP_Filesystem' ) ) {
8176                        require_once ABSPATH . 'wp-admin/includes/file.php';
8177                }
8178
8179                $form_css = maybe_unserialize( $frm_css );
8180
8181                WP_Filesystem();
8182                global $wp_filesystem;
8183
8184                $saving    = true;
8185                $use_saved = true;
8186
8187                $arfssl = ( is_ssl() ) ? 1 : 0;
8188
8189                $arflite_preview = false;
8190
8191                $arfinputstyle = $form_css['arfinputstyle'];
8192
8193                $wp_upload_dir = wp_upload_dir();
8194                $upload_dir    = $wp_upload_dir['basedir'] . '/arforms-form-builder/css/';
8195                $dest_dir      = $wp_upload_dir['basedir'] . '/arforms-form-builder/maincss/';
8196                $dest_css_url  = $wp_upload_dir['baseurl'] . '/arforms-form-builder/maincss/';
8197
8198                $new_values = $form_css;
8199
8200                $form = $arfliteform->arflitegetOne( (int) $form_id );
8201
8202                $form->form_css = maybe_unserialize( $form->form_css );
8203
8204                $form_options = maybe_unserialize( $form->options );
8205
8206                $is_prefix_suffix_enable = false;
8207                $is_checkbox_img_enable  = false;
8208                $is_radio_img_enable     = false;
8209
8210                $temp_fres = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $tbl_arf_fields . ' WHERE form_id = %d ORDER BY id', $form->id ) ); //phpcs:ignore
8211
8212                $loaded_field = array();
8213                if ( empty( $temp_fres ) ) {
8214                        return; }
8215                foreach ( $temp_fres as $temp_fdata ) {
8216                        $loaded_field[] = $temp_fdata->type;
8217
8218                        $field_options = json_decode( $temp_fdata->field_options, true );
8219
8220                        if ( ! empty( $field_options['enable_arf_prefix'] ) || ! empty( $field_options['enable_arf_suffix'] ) ) {
8221                                $is_prefix_suffix_enable = true;
8222                        }
8223
8224                        if ( 'checkbox' == $temp_fdata->type && ! empty( $field_options['use_image'] ) ) {
8225                                $is_checkbox_img_enable = true;
8226                        }
8227
8228                        if ( 'radio' == $temp_fdata->type && ! empty( $field_options['use_image'] ) ) {
8229                                $is_radio_img_enable = true;
8230                        }
8231                }
8232
8233                $css_common_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_common.php';
8234
8235                $css_rtl_filename = ARFLITE_FORMPATH . '/core/arflite_css_create_rtl.php';
8236                if ( 'standard' == $arfinputstyle || 'rounded' == $arfinputstyle ) {
8237                        $filename = ARFLITE_FORMPATH . '/core/arflite_css_create_main.php';
8238
8239                        $temp_css_file = $warn = '/* WARNING: Any changes made to this file will be lost when your ARForms settings are updated */';
8240
8241                        $temp_css_file .= "\n";
8242
8243                        ob_start();
8244
8245                        include $filename;
8246                        include $css_common_filename;
8247                        if ( is_rtl() ) {
8248                                include $css_rtl_filename;
8249                        }
8250
8251                        $temp_css_file .= str_replace( '##', '#', ob_get_contents() );
8252
8253                        ob_end_clean();
8254
8255                        $temp_css_file .= "\n " . $warn;
8256                } elseif ( 'material' == $arfinputstyle ) {
8257                        $filename = ARFLITE_FORMPATH . '/core/arflite_css_create_materialize.php';
8258
8259                        $temp_materialize_file = $warn = '/* WARNING: Any changes made to this file will be lost when your ARForms settings are updated */';
8260
8261                        $temp_materialize_file .= "\n";
8262
8263                        ob_start();
8264
8265                        include $filename;
8266                        include $css_common_filename;
8267                        if ( is_rtl() ) {
8268                                include $css_rtl_filename;
8269                        }
8270
8271                        $temp_materialize_file .= str_replace( '##', '#', ob_get_contents() );
8272
8273                        ob_end_clean();
8274
8275                        $temp_materialize_file .= "\n " . $warn;
8276                }
8277
8278                $css_file_new = $dest_dir . 'maincss_' . $form_id . '.css';
8279
8280                $material_css_file_new = $dest_dir . 'maincss_materialize_' . $form_id . '.css';
8281
8282                if ( 'standard' == $form_css['arfinputstyle'] || 'rounded' == $form_css['arfinputstyle'] ) {
8283                        $temp_css_file = str_replace( '##', '#', $temp_css_file );
8284                        $wp_filesystem->put_contents( $css_file_new, $temp_css_file, 0777 );
8285                }
8286
8287                if ( 'material' == $form_css['arfinputstyle'] ) {
8288                        $temp_materialize_file = str_replace( '##', '#', $temp_materialize_file );
8289                        $wp_filesystem->put_contents( $material_css_file_new, $temp_materialize_file, 0777 );
8290                }
8291        }
8292}
8293function arflite_sort_callback_event_start( $a, $b ) {
8294        return (int) $a->field_order - (int) $b->field_order;
8295}
Note: See TracBrowser for help on using the repository browser.