@@ -7,71 +7,71 @@ discard block |
||
7 | 7 | |
8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
9 | 9 | |
10 | - if ( strpos($type, '|') ) { |
|
11 | - list($type, $setting) = explode('|', $type); |
|
12 | - } |
|
13 | - |
|
14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
16 | - |
|
17 | - $values = array(); |
|
18 | - |
|
19 | - foreach ( $defaults as $var => $default ) { |
|
20 | - if ( $var == 'field_options' ) { |
|
21 | - $values['field_options'] = array(); |
|
22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
24 | - unset($opt_var, $opt_default); |
|
25 | - } |
|
26 | - } else { |
|
27 | - $values[ $var ] = $default; |
|
28 | - } |
|
29 | - unset($var, $default); |
|
30 | - } |
|
31 | - |
|
32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
33 | - if ( 'data' == $type ) { |
|
34 | - $values['field_options']['data_type'] = $setting; |
|
35 | - } else { |
|
36 | - $values['field_options'][ $setting ] = 1; |
|
37 | - } |
|
38 | - } |
|
39 | - |
|
40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
41 | - $values['options'] = serialize( array( |
|
42 | - __( 'Option 1', 'formidable' ), |
|
43 | - __( 'Option 2', 'formidable' ), |
|
44 | - ) ); |
|
45 | - } else if ( $type == 'select' ) { |
|
46 | - $values['options'] = serialize( array( |
|
47 | - '', __( 'Option 1', 'formidable' ), |
|
48 | - ) ); |
|
49 | - } else if ( $type == 'textarea' ) { |
|
50 | - $values['field_options']['max'] = '5'; |
|
51 | - } else if ( $type == 'captcha' ) { |
|
52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
53 | - $values['invalid'] = $frm_settings->re_msg; |
|
54 | - } else if ( 'url' == $type ) { |
|
55 | - $values['name'] = __( 'Website', 'formidable' ); |
|
56 | - } |
|
10 | + if ( strpos($type, '|') ) { |
|
11 | + list($type, $setting) = explode('|', $type); |
|
12 | + } |
|
13 | + |
|
14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
16 | + |
|
17 | + $values = array(); |
|
18 | + |
|
19 | + foreach ( $defaults as $var => $default ) { |
|
20 | + if ( $var == 'field_options' ) { |
|
21 | + $values['field_options'] = array(); |
|
22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
24 | + unset($opt_var, $opt_default); |
|
25 | + } |
|
26 | + } else { |
|
27 | + $values[ $var ] = $default; |
|
28 | + } |
|
29 | + unset($var, $default); |
|
30 | + } |
|
31 | + |
|
32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
33 | + if ( 'data' == $type ) { |
|
34 | + $values['field_options']['data_type'] = $setting; |
|
35 | + } else { |
|
36 | + $values['field_options'][ $setting ] = 1; |
|
37 | + } |
|
38 | + } |
|
39 | + |
|
40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
41 | + $values['options'] = serialize( array( |
|
42 | + __( 'Option 1', 'formidable' ), |
|
43 | + __( 'Option 2', 'formidable' ), |
|
44 | + ) ); |
|
45 | + } else if ( $type == 'select' ) { |
|
46 | + $values['options'] = serialize( array( |
|
47 | + '', __( 'Option 1', 'formidable' ), |
|
48 | + ) ); |
|
49 | + } else if ( $type == 'textarea' ) { |
|
50 | + $values['field_options']['max'] = '5'; |
|
51 | + } else if ( $type == 'captcha' ) { |
|
52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
53 | + $values['invalid'] = $frm_settings->re_msg; |
|
54 | + } else if ( 'url' == $type ) { |
|
55 | + $values['name'] = __( 'Website', 'formidable' ); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | $fields = FrmField::field_selection(); |
59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
59 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
60 | 60 | |
61 | - if ( isset( $fields[ $type ] ) ) { |
|
62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
63 | - } |
|
61 | + if ( isset( $fields[ $type ] ) ) { |
|
62 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
63 | + } |
|
64 | 64 | |
65 | - unset($fields); |
|
65 | + unset($fields); |
|
66 | 66 | |
67 | - return $values; |
|
68 | - } |
|
67 | + return $values; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | public static function get_html_id( $field, $plus = '' ) { |
71 | 71 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
74 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
75 | 75 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
76 | 76 | $defaults = array( |
77 | 77 | 'name' => $record->name, |
@@ -84,86 +84,86 @@ discard block |
||
84 | 84 | ); |
85 | 85 | |
86 | 86 | if ( $doing_ajax ) { |
87 | - $values = $values + $defaults; |
|
88 | - $values['form_name'] = ''; |
|
87 | + $values = $values + $defaults; |
|
88 | + $values['form_name'] = ''; |
|
89 | 89 | } else { |
90 | 90 | foreach ( $defaults as $var => $default ) { |
91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | - unset($var, $default); |
|
93 | - } |
|
91 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | + unset($var, $default); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | unset( $defaults ); |
99 | 99 | |
100 | - $values['options'] = $record->options; |
|
101 | - $values['field_options'] = $record->field_options; |
|
100 | + $values['options'] = $record->options; |
|
101 | + $values['field_options'] = $record->field_options; |
|
102 | 102 | |
103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
103 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
104 | 104 | |
105 | 105 | if ( $values['type'] == 'captcha' ) { |
106 | - $frm_settings = FrmAppHelper::get_settings(); |
|
107 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
108 | - } |
|
106 | + $frm_settings = FrmAppHelper::get_settings(); |
|
107 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | foreach ( $defaults as $opt => $default ) { |
111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
112 | - unset($opt, $default); |
|
113 | - } |
|
111 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
112 | + unset($opt, $default); |
|
113 | + } |
|
114 | 114 | |
115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
115 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
116 | 116 | |
117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
121 | - $field_options = array( |
|
122 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
123 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
124 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
120 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
121 | + $field_options = array( |
|
122 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
123 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
124 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
125 | 125 | 'custom_html' => '', 'captcha_size' => 'default', |
126 | - ); |
|
126 | + ); |
|
127 | 127 | |
128 | 128 | if ( $limit ) { |
129 | - return $field_options; |
|
129 | + return $field_options; |
|
130 | 130 | } |
131 | 131 | |
132 | - global $wpdb; |
|
132 | + global $wpdb; |
|
133 | 133 | |
134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
134 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
135 | 135 | |
136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
137 | 137 | |
138 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
138 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
139 | 139 | |
140 | - $frm_settings = FrmAppHelper::get_settings(); |
|
141 | - return array( |
|
142 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
140 | + $frm_settings = FrmAppHelper::get_settings(); |
|
141 | + return array( |
|
142 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
143 | 143 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
144 | 144 | 'field_order' => $field_count + 1, 'required' => false, |
145 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
146 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
145 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
146 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
147 | 147 | 'field_options' => $field_options, |
148 | - ); |
|
149 | - } |
|
148 | + ); |
|
149 | + } |
|
150 | 150 | |
151 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
152 | - global $wpdb; |
|
151 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
152 | + global $wpdb; |
|
153 | 153 | |
154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
155 | - $values['form_id'] = $form_id; |
|
156 | - $values['options'] = maybe_serialize($field->options); |
|
157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
158 | - |
|
159 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
160 | - $values[ $col ] = $field->{$col}; |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @since 2.0 |
|
166 | - */ |
|
155 | + $values['form_id'] = $form_id; |
|
156 | + $values['options'] = maybe_serialize($field->options); |
|
157 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
158 | + |
|
159 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
160 | + $values[ $col ] = $field->{$col}; |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @since 2.0 |
|
166 | + */ |
|
167 | 167 | public static function get_error_msg( $field, $error ) { |
168 | 168 | $frm_settings = FrmAppHelper::get_settings(); |
169 | 169 | $default_settings = $frm_settings->default_options(); |
@@ -180,21 +180,21 @@ discard block |
||
180 | 180 | return $msg; |
181 | 181 | } |
182 | 182 | |
183 | - public static function get_form_fields( $form_id, $error = false ) { |
|
184 | - $fields = FrmField::get_all_for_form($form_id); |
|
185 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
186 | - return $fields; |
|
187 | - } |
|
183 | + public static function get_form_fields( $form_id, $error = false ) { |
|
184 | + $fields = FrmField::get_all_for_form($form_id); |
|
185 | + $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
186 | + return $fields; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | public static function get_default_html( $type = 'text' ) { |
190 | 190 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
191 | 191 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
192 | - $for = ''; |
|
192 | + $for = ''; |
|
193 | 193 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
194 | - $for = 'for="field_[key]"'; |
|
195 | - } |
|
194 | + $for = 'for="field_[key]"'; |
|
195 | + } |
|
196 | 196 | |
197 | - $default_html = <<<DEFAULT_HTML |
|
197 | + $default_html = <<<DEFAULT_HTML |
|
198 | 198 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
199 | 199 | <label $for class="frm_primary_label">[field_name] |
200 | 200 | <span class="frm_required">[required_label]</span> |
@@ -204,145 +204,145 @@ discard block |
||
204 | 204 | [if error]<div class="frm_error">[error]</div>[/if error] |
205 | 205 | </div> |
206 | 206 | DEFAULT_HTML; |
207 | - } else { |
|
207 | + } else { |
|
208 | 208 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
212 | - } |
|
211 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
212 | + } |
|
213 | 213 | |
214 | 214 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
215 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
215 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
216 | 216 | |
217 | - $defaults = array( |
|
217 | + $defaults = array( |
|
218 | 218 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
219 | 219 | 'field_id' => $field['id'], |
220 | - 'field_plus_id' => '', |
|
221 | - 'section_id' => '', |
|
222 | - ); |
|
223 | - $args = wp_parse_args($args, $defaults); |
|
224 | - $field_name = $args['field_name']; |
|
225 | - $field_id = $args['field_id']; |
|
226 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
220 | + 'field_plus_id' => '', |
|
221 | + 'section_id' => '', |
|
222 | + ); |
|
223 | + $args = wp_parse_args($args, $defaults); |
|
224 | + $field_name = $args['field_name']; |
|
225 | + $field_id = $args['field_id']; |
|
226 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
227 | 227 | |
228 | - if ( FrmField::is_multiple_select($field) ) { |
|
229 | - $field_name .= '[]'; |
|
230 | - } |
|
228 | + if ( FrmField::is_multiple_select($field) ) { |
|
229 | + $field_name .= '[]'; |
|
230 | + } |
|
231 | 231 | |
232 | - //replace [id] |
|
233 | - $html = str_replace('[id]', $field_id, $html); |
|
232 | + //replace [id] |
|
233 | + $html = str_replace('[id]', $field_id, $html); |
|
234 | 234 | |
235 | - // Remove the for attribute for captcha |
|
236 | - if ( $field['type'] == 'captcha' ) { |
|
237 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
238 | - } |
|
235 | + // Remove the for attribute for captcha |
|
236 | + if ( $field['type'] == 'captcha' ) { |
|
237 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
238 | + } |
|
239 | 239 | |
240 | - // set the label for |
|
241 | - $html = str_replace('field_[key]', $html_id, $html); |
|
240 | + // set the label for |
|
241 | + $html = str_replace('field_[key]', $html_id, $html); |
|
242 | 242 | |
243 | - //replace [key] |
|
244 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
243 | + //replace [key] |
|
244 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
245 | 245 | |
246 | - //replace [description] and [required_label] and [error] |
|
246 | + //replace [description] and [required_label] and [error] |
|
247 | 247 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
248 | - if ( ! is_array( $errors ) ) { |
|
249 | - $errors = array(); |
|
250 | - } |
|
248 | + if ( ! is_array( $errors ) ) { |
|
249 | + $errors = array(); |
|
250 | + } |
|
251 | 251 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
252 | 252 | |
253 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
254 | - if ( $field['type'] == 'divider' ) { |
|
255 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
256 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
257 | - } else { |
|
258 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
259 | - } |
|
260 | - } |
|
253 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
254 | + if ( $field['type'] == 'divider' ) { |
|
255 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
256 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
257 | + } else { |
|
258 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
263 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
264 | - } |
|
263 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
264 | + } |
|
265 | 265 | |
266 | - //replace [required_class] |
|
266 | + //replace [required_class] |
|
267 | 267 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
268 | - $html = str_replace('[required_class]', $required_class, $html); |
|
268 | + $html = str_replace('[required_class]', $required_class, $html); |
|
269 | 269 | |
270 | - //replace [label_position] |
|
271 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
272 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
270 | + //replace [label_position] |
|
271 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
272 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
273 | 273 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
274 | 274 | |
275 | - //replace [field_name] |
|
276 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
275 | + //replace [field_name] |
|
276 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
277 | 277 | |
278 | - //replace [error_class] |
|
278 | + //replace [error_class] |
|
279 | 279 | $error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
280 | 280 | self::get_more_field_classes( $error_class, $field, $field_id, $html ); |
281 | 281 | if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
282 | 282 | // there is no error_class shortcode to use for addign fields |
283 | 283 | $html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html ); |
284 | 284 | } |
285 | - $html = str_replace('[error_class]', $error_class, $html); |
|
285 | + $html = str_replace('[error_class]', $error_class, $html); |
|
286 | 286 | |
287 | - //replace [entry_key] |
|
288 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
289 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
287 | + //replace [entry_key] |
|
288 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
289 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
290 | 290 | |
291 | - //replace [input] |
|
292 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
293 | - global $frm_vars; |
|
294 | - $frm_settings = FrmAppHelper::get_settings(); |
|
291 | + //replace [input] |
|
292 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
293 | + global $frm_vars; |
|
294 | + $frm_settings = FrmAppHelper::get_settings(); |
|
295 | 295 | |
296 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
297 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
296 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
297 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
298 | 298 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
299 | 299 | |
300 | - $replace_with = ''; |
|
300 | + $replace_with = ''; |
|
301 | 301 | |
302 | - if ( $tag == 'input' ) { |
|
303 | - if ( isset($atts['opt']) ) { |
|
304 | - $atts['opt']--; |
|
305 | - } |
|
302 | + if ( $tag == 'input' ) { |
|
303 | + if ( isset($atts['opt']) ) { |
|
304 | + $atts['opt']--; |
|
305 | + } |
|
306 | 306 | |
307 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
308 | - if ( isset($atts['class']) ) { |
|
309 | - unset($atts['class']); |
|
310 | - } |
|
307 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
308 | + if ( isset($atts['class']) ) { |
|
309 | + unset($atts['class']); |
|
310 | + } |
|
311 | 311 | |
312 | - $field['shortcodes'] = $atts; |
|
313 | - ob_start(); |
|
312 | + $field['shortcodes'] = $atts; |
|
313 | + ob_start(); |
|
314 | 314 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
315 | - $replace_with = ob_get_contents(); |
|
316 | - ob_end_clean(); |
|
317 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
318 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
319 | - } |
|
315 | + $replace_with = ob_get_contents(); |
|
316 | + ob_end_clean(); |
|
317 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
318 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
319 | + } |
|
320 | 320 | |
321 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
322 | - } |
|
321 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
322 | + } |
|
323 | 323 | |
324 | 324 | if ( $form ) { |
325 | - $form = (array) $form; |
|
325 | + $form = (array) $form; |
|
326 | 326 | |
327 | - //replace [form_key] |
|
328 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
327 | + //replace [form_key] |
|
328 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
329 | 329 | |
330 | - //replace [form_name] |
|
331 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
332 | - } |
|
333 | - $html .= "\n"; |
|
330 | + //replace [form_name] |
|
331 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
332 | + } |
|
333 | + $html .= "\n"; |
|
334 | 334 | |
335 | - //Return html if conf_field to prevent loop |
|
336 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
337 | - return $html; |
|
338 | - } |
|
335 | + //Return html if conf_field to prevent loop |
|
336 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
337 | + return $html; |
|
338 | + } |
|
339 | 339 | |
340 | - //If field is in repeating section |
|
341 | - if ( $args['section_id'] ) { |
|
342 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
343 | - } else { |
|
344 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
345 | - } |
|
340 | + //If field is in repeating section |
|
341 | + if ( $args['section_id'] ) { |
|
342 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
343 | + } else { |
|
344 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
345 | + } |
|
346 | 346 | |
347 | 347 | self::remove_collapse_shortcode( $html ); |
348 | 348 | |
@@ -350,18 +350,18 @@ discard block |
||
350 | 350 | $html = do_shortcode( $html ); |
351 | 351 | } |
352 | 352 | |
353 | - return $html; |
|
354 | - } |
|
353 | + return $html; |
|
354 | + } |
|
355 | 355 | |
356 | 356 | /** |
357 | - * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
358 | - * |
|
359 | - * @since 2.0 |
|
360 | - * @param $error_class string, pass by reference |
|
361 | - * @param $field array |
|
362 | - * @param $field_id int |
|
363 | - * @param $html string |
|
364 | - */ |
|
357 | + * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
358 | + * |
|
359 | + * @since 2.0 |
|
360 | + * @param $error_class string, pass by reference |
|
361 | + * @param $field array |
|
362 | + * @param $field_id int |
|
363 | + * @param $html string |
|
364 | + */ |
|
365 | 365 | private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) { |
366 | 366 | $error_class .= ' frm_' . $field['label'] . '_container'; |
367 | 367 | if ( $field['id'] != $field_id ) { |
@@ -425,46 +425,46 @@ discard block |
||
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
429 | - if ( $no_vars ) { |
|
428 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
429 | + if ( $no_vars ) { |
|
430 | 430 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
431 | 431 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
432 | - } else { |
|
432 | + } else { |
|
433 | 433 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
434 | - } |
|
434 | + } |
|
435 | 435 | |
436 | 436 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
437 | - } |
|
437 | + } |
|
438 | 438 | |
439 | 439 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
440 | 440 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
441 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
442 | - $args['conditional_check'] = true; |
|
443 | - } |
|
444 | - |
|
445 | - $prefix = ''; |
|
446 | - if ( $args['conditional_check'] ) { |
|
447 | - if ( $args['conditional'] ) { |
|
448 | - $prefix = 'if '; |
|
449 | - } else if ( $args['foreach'] ) { |
|
450 | - $prefix = 'foreach '; |
|
451 | - } |
|
452 | - } |
|
453 | - |
|
454 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
455 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
456 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
457 | - $tag = str_replace(']', '', $tag); |
|
458 | - $tags = explode(' ', $tag); |
|
459 | - if ( is_array($tags) ) { |
|
460 | - $tag = $tags[0]; |
|
461 | - } |
|
462 | - } else { |
|
463 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
464 | - } |
|
465 | - |
|
466 | - return $tag; |
|
467 | - } |
|
441 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
442 | + $args['conditional_check'] = true; |
|
443 | + } |
|
444 | + |
|
445 | + $prefix = ''; |
|
446 | + if ( $args['conditional_check'] ) { |
|
447 | + if ( $args['conditional'] ) { |
|
448 | + $prefix = 'if '; |
|
449 | + } else if ( $args['foreach'] ) { |
|
450 | + $prefix = 'foreach '; |
|
451 | + } |
|
452 | + } |
|
453 | + |
|
454 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
455 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
456 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
457 | + $tag = str_replace(']', '', $tag); |
|
458 | + $tags = explode(' ', $tag); |
|
459 | + if ( is_array($tags) ) { |
|
460 | + $tag = $tags[0]; |
|
461 | + } |
|
462 | + } else { |
|
463 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
464 | + } |
|
465 | + |
|
466 | + return $tag; |
|
467 | + } |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * Remove [collapse_this] if it's still included after all processing |
@@ -477,128 +477,128 @@ discard block |
||
477 | 477 | } |
478 | 478 | |
479 | 479 | public static function display_recaptcha( $field ) { |
480 | - $frm_settings = FrmAppHelper::get_settings(); |
|
481 | - $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field); |
|
480 | + $frm_settings = FrmAppHelper::get_settings(); |
|
481 | + $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field); |
|
482 | 482 | |
483 | - $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit'; |
|
484 | - if ( $lang != 'en' ) { |
|
483 | + $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit'; |
|
484 | + if ( $lang != 'en' ) { |
|
485 | 485 | $api_js_url .= '&hl=' . $lang; |
486 | - } |
|
487 | - $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url); |
|
486 | + } |
|
487 | + $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url); |
|
488 | 488 | |
489 | - wp_register_script('recaptcha-api', $api_js_url, '', true); |
|
490 | - wp_enqueue_script('recaptcha-api'); |
|
489 | + wp_register_script('recaptcha-api', $api_js_url, '', true); |
|
490 | + wp_enqueue_script('recaptcha-api'); |
|
491 | 491 | |
492 | 492 | ?> |
493 | 493 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div> |
494 | 494 | <?php |
495 | - } |
|
495 | + } |
|
496 | 496 | |
497 | 497 | public static function show_single_option( $field ) { |
498 | - $field_name = $field['name']; |
|
499 | - $html_id = self::get_html_id($field); |
|
500 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
501 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
502 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
498 | + $field_name = $field['name']; |
|
499 | + $html_id = self::get_html_id($field); |
|
500 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
501 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
502 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
503 | 503 | |
504 | - // If this is an "Other" option, get the HTML for it |
|
504 | + // If this is an "Other" option, get the HTML for it |
|
505 | 505 | if ( self::is_other_opt( $opt_key ) ) { |
506 | - // Get string for Other text field, if needed |
|
506 | + // Get string for Other text field, if needed |
|
507 | 507 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
508 | 508 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
509 | - } else { |
|
509 | + } else { |
|
510 | 510 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
511 | - } |
|
512 | - } |
|
513 | - } |
|
511 | + } |
|
512 | + } |
|
513 | + } |
|
514 | 514 | |
515 | 515 | public static function dropdown_categories( $args ) { |
516 | 516 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
517 | - $args = wp_parse_args($args, $defaults); |
|
517 | + $args = wp_parse_args($args, $defaults); |
|
518 | 518 | |
519 | - if ( ! $args['field'] ) { |
|
520 | - return; |
|
521 | - } |
|
519 | + if ( ! $args['field'] ) { |
|
520 | + return; |
|
521 | + } |
|
522 | 522 | |
523 | - if ( ! $args['name'] ) { |
|
523 | + if ( ! $args['name'] ) { |
|
524 | 524 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
525 | - } |
|
525 | + } |
|
526 | 526 | |
527 | - $id = self::get_html_id($args['field']); |
|
528 | - $class = $args['field']['type']; |
|
527 | + $id = self::get_html_id($args['field']); |
|
528 | + $class = $args['field']['type']; |
|
529 | 529 | |
530 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
531 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
530 | + $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
531 | + $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
532 | 532 | |
533 | - if ( is_array($args['field']['value']) ) { |
|
534 | - if ( ! empty($exclude) ) { |
|
535 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
536 | - } |
|
537 | - $selected = reset($args['field']['value']); |
|
538 | - } else { |
|
539 | - $selected = $args['field']['value']; |
|
540 | - } |
|
533 | + if ( is_array($args['field']['value']) ) { |
|
534 | + if ( ! empty($exclude) ) { |
|
535 | + $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
536 | + } |
|
537 | + $selected = reset($args['field']['value']); |
|
538 | + } else { |
|
539 | + $selected = $args['field']['value']; |
|
540 | + } |
|
541 | 541 | |
542 | - $tax_atts = array( |
|
543 | - 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
544 | - 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
545 | - 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
546 | - ); |
|
542 | + $tax_atts = array( |
|
543 | + 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
544 | + 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
545 | + 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
546 | + ); |
|
547 | 547 | |
548 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
548 | + $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
549 | 549 | |
550 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
551 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
552 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
553 | - if ( ! $tax_atts['taxonomy'] ) { |
|
554 | - return; |
|
555 | - } |
|
550 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
551 | + $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
552 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
553 | + if ( ! $tax_atts['taxonomy'] ) { |
|
554 | + return; |
|
555 | + } |
|
556 | 556 | |
557 | - // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
558 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
559 | - $tax_atts['exclude_tree'] = $exclude; |
|
560 | - } |
|
561 | - } |
|
557 | + // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
558 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
559 | + $tax_atts['exclude_tree'] = $exclude; |
|
560 | + } |
|
561 | + } |
|
562 | 562 | |
563 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
563 | + $dropdown = wp_dropdown_categories($tax_atts); |
|
564 | 564 | |
565 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
565 | + $add_html = FrmFieldsController::input_html($args['field'], false); |
|
566 | 566 | |
567 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
568 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
569 | - } |
|
567 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
568 | + $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
569 | + } |
|
570 | 570 | |
571 | 571 | $dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown ); |
572 | 572 | |
573 | - if ( is_array($args['field']['value']) ) { |
|
574 | - $skip = true; |
|
575 | - foreach ( $args['field']['value'] as $v ) { |
|
573 | + if ( is_array($args['field']['value']) ) { |
|
574 | + $skip = true; |
|
575 | + foreach ( $args['field']['value'] as $v ) { |
|
576 | 576 | if ( $skip ) { |
577 | - $skip = false; |
|
578 | - continue; |
|
579 | - } |
|
577 | + $skip = false; |
|
578 | + continue; |
|
579 | + } |
|
580 | 580 | $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
581 | - unset($v); |
|
582 | - } |
|
583 | - } |
|
581 | + unset($v); |
|
582 | + } |
|
583 | + } |
|
584 | 584 | |
585 | - return $dropdown; |
|
586 | - } |
|
585 | + return $dropdown; |
|
586 | + } |
|
587 | 587 | |
588 | 588 | public static function get_term_link( $tax_id ) { |
589 | - $tax = get_taxonomy($tax_id); |
|
590 | - if ( ! $tax ) { |
|
591 | - return; |
|
592 | - } |
|
589 | + $tax = get_taxonomy($tax_id); |
|
590 | + if ( ! $tax ) { |
|
591 | + return; |
|
592 | + } |
|
593 | 593 | |
594 | - $link = sprintf( |
|
595 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
594 | + $link = sprintf( |
|
595 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
596 | 596 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
597 | - ); |
|
598 | - unset($tax); |
|
597 | + ); |
|
598 | + unset($tax); |
|
599 | 599 | |
600 | - return $link; |
|
601 | - } |
|
600 | + return $link; |
|
601 | + } |
|
602 | 602 | |
603 | 603 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
604 | 604 | // Remove white space from hide_opt |
@@ -606,195 +606,195 @@ discard block |
||
606 | 606 | $hide_opt = rtrim( $hide_opt ); |
607 | 607 | } |
608 | 608 | |
609 | - if ( is_array($observed_value) ) { |
|
610 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
611 | - } |
|
612 | - |
|
613 | - $m = false; |
|
614 | - if ( $cond == '==' ) { |
|
615 | - $m = $observed_value == $hide_opt; |
|
616 | - } else if ( $cond == '!=' ) { |
|
617 | - $m = $observed_value != $hide_opt; |
|
618 | - } else if ( $cond == '>' ) { |
|
619 | - $m = $observed_value > $hide_opt; |
|
620 | - } else if ( $cond == '<' ) { |
|
621 | - $m = $observed_value < $hide_opt; |
|
622 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
623 | - $m = stripos($observed_value, $hide_opt); |
|
624 | - if ( $cond == 'not LIKE' ) { |
|
625 | - $m = ( $m === false ) ? true : false; |
|
626 | - } else { |
|
627 | - $m = ( $m === false ) ? false : true; |
|
628 | - } |
|
629 | - } |
|
630 | - return $m; |
|
631 | - } |
|
609 | + if ( is_array($observed_value) ) { |
|
610 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
611 | + } |
|
612 | + |
|
613 | + $m = false; |
|
614 | + if ( $cond == '==' ) { |
|
615 | + $m = $observed_value == $hide_opt; |
|
616 | + } else if ( $cond == '!=' ) { |
|
617 | + $m = $observed_value != $hide_opt; |
|
618 | + } else if ( $cond == '>' ) { |
|
619 | + $m = $observed_value > $hide_opt; |
|
620 | + } else if ( $cond == '<' ) { |
|
621 | + $m = $observed_value < $hide_opt; |
|
622 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
623 | + $m = stripos($observed_value, $hide_opt); |
|
624 | + if ( $cond == 'not LIKE' ) { |
|
625 | + $m = ( $m === false ) ? true : false; |
|
626 | + } else { |
|
627 | + $m = ( $m === false ) ? false : true; |
|
628 | + } |
|
629 | + } |
|
630 | + return $m; |
|
631 | + } |
|
632 | 632 | |
633 | 633 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
634 | - $m = false; |
|
635 | - if ( $cond == '==' ) { |
|
636 | - if ( is_array($hide_opt) ) { |
|
637 | - $m = array_intersect($hide_opt, $observed_value); |
|
638 | - $m = empty($m) ? false : true; |
|
639 | - } else { |
|
640 | - $m = in_array($hide_opt, $observed_value); |
|
641 | - } |
|
642 | - } else if ( $cond == '!=' ) { |
|
643 | - $m = ! in_array($hide_opt, $observed_value); |
|
644 | - } else if ( $cond == '>' ) { |
|
645 | - $min = min($observed_value); |
|
646 | - $m = $min > $hide_opt; |
|
647 | - } else if ( $cond == '<' ) { |
|
648 | - $max = max($observed_value); |
|
649 | - $m = $max < $hide_opt; |
|
650 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
651 | - foreach ( $observed_value as $ob ) { |
|
652 | - $m = strpos($ob, $hide_opt); |
|
653 | - if ( $m !== false ) { |
|
654 | - $m = true; |
|
655 | - break; |
|
656 | - } |
|
657 | - } |
|
658 | - |
|
659 | - if ( $cond == 'not LIKE' ) { |
|
660 | - $m = ( $m === false ) ? true : false; |
|
661 | - } |
|
662 | - } |
|
663 | - |
|
664 | - return $m; |
|
665 | - } |
|
666 | - |
|
667 | - /** |
|
668 | - * Replace a few basic shortcodes and field ids |
|
669 | - * @since 2.0 |
|
670 | - * @return string |
|
671 | - */ |
|
634 | + $m = false; |
|
635 | + if ( $cond == '==' ) { |
|
636 | + if ( is_array($hide_opt) ) { |
|
637 | + $m = array_intersect($hide_opt, $observed_value); |
|
638 | + $m = empty($m) ? false : true; |
|
639 | + } else { |
|
640 | + $m = in_array($hide_opt, $observed_value); |
|
641 | + } |
|
642 | + } else if ( $cond == '!=' ) { |
|
643 | + $m = ! in_array($hide_opt, $observed_value); |
|
644 | + } else if ( $cond == '>' ) { |
|
645 | + $min = min($observed_value); |
|
646 | + $m = $min > $hide_opt; |
|
647 | + } else if ( $cond == '<' ) { |
|
648 | + $max = max($observed_value); |
|
649 | + $m = $max < $hide_opt; |
|
650 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
651 | + foreach ( $observed_value as $ob ) { |
|
652 | + $m = strpos($ob, $hide_opt); |
|
653 | + if ( $m !== false ) { |
|
654 | + $m = true; |
|
655 | + break; |
|
656 | + } |
|
657 | + } |
|
658 | + |
|
659 | + if ( $cond == 'not LIKE' ) { |
|
660 | + $m = ( $m === false ) ? true : false; |
|
661 | + } |
|
662 | + } |
|
663 | + |
|
664 | + return $m; |
|
665 | + } |
|
666 | + |
|
667 | + /** |
|
668 | + * Replace a few basic shortcodes and field ids |
|
669 | + * @since 2.0 |
|
670 | + * @return string |
|
671 | + */ |
|
672 | 672 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
673 | - if ( strpos($value, '[sitename]') !== false ) { |
|
674 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
675 | - $value = str_replace('[sitename]', $new_value, $value); |
|
676 | - } |
|
673 | + if ( strpos($value, '[sitename]') !== false ) { |
|
674 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
675 | + $value = str_replace('[sitename]', $new_value, $value); |
|
676 | + } |
|
677 | 677 | |
678 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
679 | - $value = do_shortcode($value); |
|
678 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
679 | + $value = do_shortcode($value); |
|
680 | 680 | |
681 | - return $value; |
|
682 | - } |
|
681 | + return $value; |
|
682 | + } |
|
683 | 683 | |
684 | 684 | public static function get_shortcodes( $content, $form_id ) { |
685 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
686 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
687 | - } |
|
685 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
686 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
687 | + } |
|
688 | 688 | |
689 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
689 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
690 | 690 | |
691 | - $tagregexp = self::allowed_shortcodes($fields); |
|
691 | + $tagregexp = self::allowed_shortcodes($fields); |
|
692 | 692 | |
693 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
693 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
694 | 694 | |
695 | - return $matches; |
|
696 | - } |
|
695 | + return $matches; |
|
696 | + } |
|
697 | 697 | |
698 | 698 | public static function allowed_shortcodes( $fields = array() ) { |
699 | - $tagregexp = array( |
|
700 | - 'editlink', 'id', 'key', 'ip', |
|
701 | - 'siteurl', 'sitename', 'admin_email', |
|
702 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
699 | + $tagregexp = array( |
|
700 | + 'editlink', 'id', 'key', 'ip', |
|
701 | + 'siteurl', 'sitename', 'admin_email', |
|
702 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
703 | 703 | 'parent[-|_]id', |
704 | - ); |
|
704 | + ); |
|
705 | 705 | |
706 | - foreach ( $fields as $field ) { |
|
707 | - $tagregexp[] = $field->id; |
|
708 | - $tagregexp[] = $field->field_key; |
|
709 | - } |
|
706 | + foreach ( $fields as $field ) { |
|
707 | + $tagregexp[] = $field->id; |
|
708 | + $tagregexp[] = $field->field_key; |
|
709 | + } |
|
710 | 710 | |
711 | - $tagregexp = implode('|', $tagregexp); |
|
712 | - return $tagregexp; |
|
713 | - } |
|
711 | + $tagregexp = implode('|', $tagregexp); |
|
712 | + return $tagregexp; |
|
713 | + } |
|
714 | 714 | |
715 | 715 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
716 | - $shortcode_values = array( |
|
717 | - 'id' => $entry->id, |
|
718 | - 'key' => $entry->item_key, |
|
719 | - 'ip' => $entry->ip, |
|
720 | - ); |
|
716 | + $shortcode_values = array( |
|
717 | + 'id' => $entry->id, |
|
718 | + 'key' => $entry->item_key, |
|
719 | + 'ip' => $entry->ip, |
|
720 | + ); |
|
721 | 721 | |
722 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
723 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
722 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
723 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
724 | 724 | |
725 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
725 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
726 | 726 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
727 | - $tags = explode(' ', $tag); |
|
728 | - if ( is_array($tags) ) { |
|
729 | - $tag = $tags[0]; |
|
730 | - } |
|
731 | - } else { |
|
732 | - $tag = $shortcodes[2][ $short_key ]; |
|
733 | - } |
|
734 | - |
|
735 | - switch ( $tag ) { |
|
736 | - case 'id': |
|
737 | - case 'key': |
|
738 | - case 'ip': |
|
739 | - $replace_with = $shortcode_values[ $tag ]; |
|
740 | - break; |
|
741 | - |
|
742 | - case 'user_agent': |
|
743 | - case 'user-agent': |
|
744 | - $entry->description = maybe_unserialize($entry->description); |
|
727 | + $tags = explode(' ', $tag); |
|
728 | + if ( is_array($tags) ) { |
|
729 | + $tag = $tags[0]; |
|
730 | + } |
|
731 | + } else { |
|
732 | + $tag = $shortcodes[2][ $short_key ]; |
|
733 | + } |
|
734 | + |
|
735 | + switch ( $tag ) { |
|
736 | + case 'id': |
|
737 | + case 'key': |
|
738 | + case 'ip': |
|
739 | + $replace_with = $shortcode_values[ $tag ]; |
|
740 | + break; |
|
741 | + |
|
742 | + case 'user_agent': |
|
743 | + case 'user-agent': |
|
744 | + $entry->description = maybe_unserialize($entry->description); |
|
745 | 745 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
746 | - break; |
|
747 | - |
|
748 | - case 'created_at': |
|
749 | - case 'created-at': |
|
750 | - case 'updated_at': |
|
751 | - case 'updated-at': |
|
752 | - if ( isset($atts['format']) ) { |
|
753 | - $time_format = ' '; |
|
754 | - } else { |
|
755 | - $atts['format'] = get_option('date_format'); |
|
756 | - $time_format = ''; |
|
757 | - } |
|
758 | - |
|
759 | - $this_tag = str_replace('-', '_', $tag); |
|
760 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
761 | - unset($this_tag); |
|
762 | - break; |
|
763 | - |
|
764 | - case 'created_by': |
|
765 | - case 'created-by': |
|
766 | - case 'updated_by': |
|
767 | - case 'updated-by': |
|
768 | - $this_tag = str_replace('-', '_', $tag); |
|
746 | + break; |
|
747 | + |
|
748 | + case 'created_at': |
|
749 | + case 'created-at': |
|
750 | + case 'updated_at': |
|
751 | + case 'updated-at': |
|
752 | + if ( isset($atts['format']) ) { |
|
753 | + $time_format = ' '; |
|
754 | + } else { |
|
755 | + $atts['format'] = get_option('date_format'); |
|
756 | + $time_format = ''; |
|
757 | + } |
|
758 | + |
|
759 | + $this_tag = str_replace('-', '_', $tag); |
|
760 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
761 | + unset($this_tag); |
|
762 | + break; |
|
763 | + |
|
764 | + case 'created_by': |
|
765 | + case 'created-by': |
|
766 | + case 'updated_by': |
|
767 | + case 'updated-by': |
|
768 | + $this_tag = str_replace('-', '_', $tag); |
|
769 | 769 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
770 | - unset($this_tag); |
|
771 | - break; |
|
772 | - |
|
773 | - case 'admin_email': |
|
774 | - case 'siteurl': |
|
775 | - case 'frmurl': |
|
776 | - case 'sitename': |
|
777 | - case 'get': |
|
778 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
779 | - break; |
|
780 | - |
|
781 | - default: |
|
782 | - $field = FrmField::getOne( $tag ); |
|
783 | - if ( ! $field ) { |
|
784 | - break; |
|
785 | - } |
|
786 | - |
|
787 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
788 | - |
|
789 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
790 | - |
|
791 | - $atts['entry_id'] = $entry->id; |
|
792 | - $atts['entry_key'] = $entry->item_key; |
|
793 | - |
|
794 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
795 | - $replace_with = $field->name; |
|
796 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
797 | - $replace_with = $field->description; |
|
770 | + unset($this_tag); |
|
771 | + break; |
|
772 | + |
|
773 | + case 'admin_email': |
|
774 | + case 'siteurl': |
|
775 | + case 'frmurl': |
|
776 | + case 'sitename': |
|
777 | + case 'get': |
|
778 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
779 | + break; |
|
780 | + |
|
781 | + default: |
|
782 | + $field = FrmField::getOne( $tag ); |
|
783 | + if ( ! $field ) { |
|
784 | + break; |
|
785 | + } |
|
786 | + |
|
787 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
788 | + |
|
789 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
790 | + |
|
791 | + $atts['entry_id'] = $entry->id; |
|
792 | + $atts['entry_key'] = $entry->item_key; |
|
793 | + |
|
794 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
795 | + $replace_with = $field->name; |
|
796 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
797 | + $replace_with = $field->description; |
|
798 | 798 | } else { |
799 | 799 | $string_value = $replace_with; |
800 | 800 | if ( is_array( $replace_with ) ) { |
@@ -808,82 +808,82 @@ discard block |
||
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | - unset($field); |
|
812 | - break; |
|
813 | - } |
|
811 | + unset($field); |
|
812 | + break; |
|
813 | + } |
|
814 | 814 | |
815 | - if ( isset($replace_with) ) { |
|
816 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
817 | - } |
|
815 | + if ( isset($replace_with) ) { |
|
816 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
817 | + } |
|
818 | 818 | |
819 | - unset($atts, $conditional, $replace_with); |
|
819 | + unset($atts, $conditional, $replace_with); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | return $content; |
823 | - } |
|
824 | - |
|
825 | - /** |
|
826 | - * Get the value to replace a few standard shortcodes |
|
827 | - * |
|
828 | - * @since 2.0 |
|
829 | - * @return string |
|
830 | - */ |
|
831 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
832 | - $new_value = ''; |
|
833 | - switch ( $tag ) { |
|
834 | - case 'admin_email': |
|
835 | - $new_value = get_option('admin_email'); |
|
836 | - break; |
|
837 | - case 'siteurl': |
|
838 | - $new_value = FrmAppHelper::site_url(); |
|
839 | - break; |
|
840 | - case 'frmurl': |
|
841 | - $new_value = FrmAppHelper::plugin_url(); |
|
842 | - break; |
|
843 | - case 'sitename': |
|
844 | - $new_value = FrmAppHelper::site_name(); |
|
845 | - break; |
|
846 | - case 'get': |
|
847 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
848 | - break; |
|
849 | - } |
|
850 | - |
|
851 | - return $new_value; |
|
852 | - } |
|
853 | - |
|
854 | - /** |
|
855 | - * Process the [get] shortcode |
|
856 | - * |
|
857 | - * @since 2.0 |
|
858 | - * @return string|array |
|
859 | - */ |
|
860 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
861 | - if ( ! isset($atts['param']) ) { |
|
862 | - return ''; |
|
863 | - } |
|
864 | - |
|
865 | - if ( strpos($atts['param'], '[') ) { |
|
866 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
867 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
868 | - } |
|
869 | - |
|
870 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
871 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
872 | - |
|
873 | - if ( $new_value == '' ) { |
|
874 | - if ( ! isset($atts['prev_val']) ) { |
|
875 | - $atts['prev_val'] = ''; |
|
876 | - } |
|
877 | - |
|
878 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
879 | - } |
|
880 | - |
|
881 | - if ( is_array($new_value) && ! $return_array ) { |
|
882 | - $new_value = implode(', ', $new_value); |
|
883 | - } |
|
884 | - |
|
885 | - return $new_value; |
|
886 | - } |
|
823 | + } |
|
824 | + |
|
825 | + /** |
|
826 | + * Get the value to replace a few standard shortcodes |
|
827 | + * |
|
828 | + * @since 2.0 |
|
829 | + * @return string |
|
830 | + */ |
|
831 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
832 | + $new_value = ''; |
|
833 | + switch ( $tag ) { |
|
834 | + case 'admin_email': |
|
835 | + $new_value = get_option('admin_email'); |
|
836 | + break; |
|
837 | + case 'siteurl': |
|
838 | + $new_value = FrmAppHelper::site_url(); |
|
839 | + break; |
|
840 | + case 'frmurl': |
|
841 | + $new_value = FrmAppHelper::plugin_url(); |
|
842 | + break; |
|
843 | + case 'sitename': |
|
844 | + $new_value = FrmAppHelper::site_name(); |
|
845 | + break; |
|
846 | + case 'get': |
|
847 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
848 | + break; |
|
849 | + } |
|
850 | + |
|
851 | + return $new_value; |
|
852 | + } |
|
853 | + |
|
854 | + /** |
|
855 | + * Process the [get] shortcode |
|
856 | + * |
|
857 | + * @since 2.0 |
|
858 | + * @return string|array |
|
859 | + */ |
|
860 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
861 | + if ( ! isset($atts['param']) ) { |
|
862 | + return ''; |
|
863 | + } |
|
864 | + |
|
865 | + if ( strpos($atts['param'], '[') ) { |
|
866 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
867 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
868 | + } |
|
869 | + |
|
870 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
871 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
872 | + |
|
873 | + if ( $new_value == '' ) { |
|
874 | + if ( ! isset($atts['prev_val']) ) { |
|
875 | + $atts['prev_val'] = ''; |
|
876 | + } |
|
877 | + |
|
878 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
879 | + } |
|
880 | + |
|
881 | + if ( is_array($new_value) && ! $return_array ) { |
|
882 | + $new_value = implode(', ', $new_value); |
|
883 | + } |
|
884 | + |
|
885 | + return $new_value; |
|
886 | + } |
|
887 | 887 | |
888 | 888 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
889 | 889 | $atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
892 | 892 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
893 | 893 | |
894 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
895 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
896 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
897 | - if ( is_array($replace_with) ) { |
|
898 | - $replace_with = implode("\n", $replace_with); |
|
899 | - } |
|
900 | - $replace_with = wpautop($replace_with); |
|
901 | - } |
|
894 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
895 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
896 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
897 | + if ( is_array($replace_with) ) { |
|
898 | + $replace_with = implode("\n", $replace_with); |
|
899 | + } |
|
900 | + $replace_with = wpautop($replace_with); |
|
901 | + } |
|
902 | 902 | unset( $autop ); |
903 | 903 | } else if ( is_array( $replace_with ) ) { |
904 | 904 | $replace_with = implode( $atts['sep'], $replace_with ); |
@@ -908,57 +908,57 @@ discard block |
||
908 | 908 | } |
909 | 909 | |
910 | 910 | public static function get_field_types( $type ) { |
911 | - $single_input = array( |
|
912 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
913 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
914 | - 'user_id', 'tag', 'password', |
|
915 | - ); |
|
911 | + $single_input = array( |
|
912 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
913 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
914 | + 'user_id', 'tag', 'password', |
|
915 | + ); |
|
916 | 916 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale' ); |
917 | 917 | $other_type = array( 'divider', 'html', 'break' ); |
918 | 918 | |
919 | 919 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
920 | 920 | |
921 | - $field_types = array(); |
|
922 | - if ( in_array($type, $single_input) ) { |
|
923 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
924 | - } else if ( in_array($type, $multiple_input) ) { |
|
925 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
926 | - } else if ( in_array($type, $other_type) ) { |
|
927 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
921 | + $field_types = array(); |
|
922 | + if ( in_array($type, $single_input) ) { |
|
923 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
924 | + } else if ( in_array($type, $multiple_input) ) { |
|
925 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
926 | + } else if ( in_array($type, $other_type) ) { |
|
927 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
928 | 928 | } else if ( isset( $field_selection[ $type ] ) ) { |
929 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
930 | - } |
|
931 | - |
|
932 | - return $field_types; |
|
933 | - } |
|
934 | - |
|
935 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
936 | - foreach ( $inputs as $input ) { |
|
937 | - $field_types[ $input ] = $fields[ $input ]; |
|
938 | - unset($input); |
|
939 | - } |
|
940 | - } |
|
941 | - |
|
942 | - /** |
|
943 | - * Check if current field option is an "other" option |
|
944 | - * |
|
945 | - * @since 2.0.6 |
|
946 | - * |
|
947 | - * @param string $opt_key |
|
948 | - * @return boolean Returns true if current field option is an "Other" option |
|
949 | - */ |
|
950 | - public static function is_other_opt( $opt_key ) { |
|
951 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
952 | - } |
|
953 | - |
|
954 | - /** |
|
955 | - * Get value that belongs in "Other" text box |
|
956 | - * |
|
957 | - * @since 2.0.6 |
|
958 | - * |
|
959 | - * @param array $args |
|
960 | - */ |
|
961 | - public static function get_other_val( $args ) { |
|
929 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
930 | + } |
|
931 | + |
|
932 | + return $field_types; |
|
933 | + } |
|
934 | + |
|
935 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
936 | + foreach ( $inputs as $input ) { |
|
937 | + $field_types[ $input ] = $fields[ $input ]; |
|
938 | + unset($input); |
|
939 | + } |
|
940 | + } |
|
941 | + |
|
942 | + /** |
|
943 | + * Check if current field option is an "other" option |
|
944 | + * |
|
945 | + * @since 2.0.6 |
|
946 | + * |
|
947 | + * @param string $opt_key |
|
948 | + * @return boolean Returns true if current field option is an "Other" option |
|
949 | + */ |
|
950 | + public static function is_other_opt( $opt_key ) { |
|
951 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
952 | + } |
|
953 | + |
|
954 | + /** |
|
955 | + * Get value that belongs in "Other" text box |
|
956 | + * |
|
957 | + * @since 2.0.6 |
|
958 | + * |
|
959 | + * @param array $args |
|
960 | + */ |
|
961 | + public static function get_other_val( $args ) { |
|
962 | 962 | $defaults = array( |
963 | 963 | 'opt_key' => 0, 'field' => array(), |
964 | 964 | 'parent' => false, 'pointer' => false, |
@@ -1034,20 +1034,20 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | return $other_val; |
1037 | - } |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
1041 | - * Intended for front-end use |
|
1042 | - * |
|
1043 | - * @since 2.0.6 |
|
1044 | - * |
|
1045 | - * @param array $args should include field, opt_key and field name |
|
1046 | - * @param boolean $other_opt |
|
1047 | - * @param string $checked |
|
1048 | - * @return string $other_val |
|
1049 | - */ |
|
1050 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
1037 | + } |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
1041 | + * Intended for front-end use |
|
1042 | + * |
|
1043 | + * @since 2.0.6 |
|
1044 | + * |
|
1045 | + * @param array $args should include field, opt_key and field name |
|
1046 | + * @param boolean $other_opt |
|
1047 | + * @param string $checked |
|
1048 | + * @return string $other_val |
|
1049 | + */ |
|
1050 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
1051 | 1051 | //Check if this is an "Other" option |
1052 | 1052 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
1053 | 1053 | return; |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | $checked = 'checked="checked" '; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - return $other_args; |
|
1067 | - } |
|
1066 | + return $other_args; |
|
1067 | + } |
|
1068 | 1068 | |
1069 | 1069 | /** |
1070 | 1070 | * @param array $args |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | * @since 2.0.6 |
1114 | 1114 | */ |
1115 | 1115 | public static function include_other_input( $args ) { |
1116 | - if ( ! $args['other_opt'] ) { |
|
1117 | - return; |
|
1116 | + if ( ! $args['other_opt'] ) { |
|
1117 | + return; |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | $classes = array( 'frm_other_input' ); |
@@ -1135,15 +1135,15 @@ discard block |
||
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | /** |
1138 | - * Get the HTML id for an "Other" text field |
|
1139 | - * Note: This does not affect fields in repeating sections |
|
1140 | - * |
|
1141 | - * @since 2.0.08 |
|
1142 | - * @param string $type - field type |
|
1143 | - * @param string $html_id |
|
1144 | - * @param string|boolean $opt_key |
|
1145 | - * @return string $other_id |
|
1146 | - */ |
|
1138 | + * Get the HTML id for an "Other" text field |
|
1139 | + * Note: This does not affect fields in repeating sections |
|
1140 | + * |
|
1141 | + * @since 2.0.08 |
|
1142 | + * @param string $type - field type |
|
1143 | + * @param string $html_id |
|
1144 | + * @param string|boolean $opt_key |
|
1145 | + * @return string $other_id |
|
1146 | + */ |
|
1147 | 1147 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
1148 | 1148 | $other_id = $html_id; |
1149 | 1149 | |
@@ -1201,10 +1201,10 @@ discard block |
||
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | public static function switch_field_ids( $val ) { |
1204 | - global $frm_duplicate_ids; |
|
1205 | - $replace = array(); |
|
1206 | - $replace_with = array(); |
|
1207 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
1204 | + global $frm_duplicate_ids; |
|
1205 | + $replace = array(); |
|
1206 | + $replace_with = array(); |
|
1207 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
1208 | 1208 | $replace[] = '[if ' . $old . ']'; |
1209 | 1209 | $replace_with[] = '[if ' . $new . ']'; |
1210 | 1210 | $replace[] = '[if ' . $old . ' '; |
@@ -1219,153 +1219,153 @@ discard block |
||
1219 | 1219 | $replace_with[] = '[' . $new . ']'; |
1220 | 1220 | $replace[] = '[' . $old . ' '; |
1221 | 1221 | $replace_with[] = '[' . $new . ' '; |
1222 | - unset($old, $new); |
|
1223 | - } |
|
1222 | + unset($old, $new); |
|
1223 | + } |
|
1224 | 1224 | if ( is_array( $val ) ) { |
1225 | 1225 | foreach ( $val as $k => $v ) { |
1226 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
1227 | - unset($k, $v); |
|
1228 | - } |
|
1229 | - } else { |
|
1230 | - $val = str_replace($replace, $replace_with, $val); |
|
1231 | - } |
|
1232 | - |
|
1233 | - return $val; |
|
1234 | - } |
|
1235 | - |
|
1236 | - public static function get_us_states() { |
|
1237 | - return apply_filters( 'frm_us_states', array( |
|
1238 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
1239 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
1240 | - 'DC' => 'District of Columbia', |
|
1241 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
1242 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
1243 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
1244 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
1245 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
1246 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
1247 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
1248 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
1249 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
1250 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
1251 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
1252 | - ) ); |
|
1253 | - } |
|
1254 | - |
|
1255 | - public static function get_countries() { |
|
1256 | - return apply_filters( 'frm_countries', array( |
|
1257 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
1258 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
1259 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
1260 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
1261 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
1262 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
1263 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
1264 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
1265 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
1266 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
1267 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
1268 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
1269 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
1270 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
1271 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
1272 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
1273 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
1274 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
1275 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
1276 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
1277 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
1278 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
1279 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
1280 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
1281 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
1282 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
1283 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
1284 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
1285 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
1286 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
1287 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
1288 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
1289 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
1290 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
1291 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
1292 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
1293 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
1294 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
1295 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
1296 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
1297 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
1298 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
1299 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
1300 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
1301 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
1302 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
1303 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
1304 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
1305 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
1306 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
1307 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
1308 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
1309 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
1310 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
1311 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
1312 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
1313 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
1314 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
1315 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
1316 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
1317 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
1318 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
1319 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
1320 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
1321 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
1322 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
1323 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
1324 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
1325 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
1326 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
1327 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
1328 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
1329 | - __( 'Zimbabwe', 'formidable' ), |
|
1330 | - ) ); |
|
1331 | - } |
|
1226 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
1227 | + unset($k, $v); |
|
1228 | + } |
|
1229 | + } else { |
|
1230 | + $val = str_replace($replace, $replace_with, $val); |
|
1231 | + } |
|
1232 | + |
|
1233 | + return $val; |
|
1234 | + } |
|
1235 | + |
|
1236 | + public static function get_us_states() { |
|
1237 | + return apply_filters( 'frm_us_states', array( |
|
1238 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
1239 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
1240 | + 'DC' => 'District of Columbia', |
|
1241 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
1242 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
1243 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
1244 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
1245 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
1246 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
1247 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
1248 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
1249 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
1250 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
1251 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
1252 | + ) ); |
|
1253 | + } |
|
1254 | + |
|
1255 | + public static function get_countries() { |
|
1256 | + return apply_filters( 'frm_countries', array( |
|
1257 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
1258 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
1259 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
1260 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
1261 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
1262 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
1263 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
1264 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
1265 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
1266 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
1267 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
1268 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
1269 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
1270 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
1271 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
1272 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
1273 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
1274 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
1275 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
1276 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
1277 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
1278 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
1279 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
1280 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
1281 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
1282 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
1283 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
1284 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
1285 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
1286 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
1287 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
1288 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
1289 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
1290 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
1291 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
1292 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
1293 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
1294 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
1295 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
1296 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
1297 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
1298 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
1299 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
1300 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
1301 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
1302 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
1303 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
1304 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
1305 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
1306 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
1307 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
1308 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
1309 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
1310 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
1311 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
1312 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
1313 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
1314 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
1315 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
1316 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
1317 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
1318 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
1319 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
1320 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
1321 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
1322 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
1323 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
1324 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
1325 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
1326 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
1327 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
1328 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
1329 | + __( 'Zimbabwe', 'formidable' ), |
|
1330 | + ) ); |
|
1331 | + } |
|
1332 | 1332 | |
1333 | 1333 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
1334 | 1334 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
1335 | 1335 | |
1336 | - $states = FrmFieldsHelper::get_us_states(); |
|
1337 | - $state_abv = array_keys($states); |
|
1338 | - sort($state_abv); |
|
1336 | + $states = FrmFieldsHelper::get_us_states(); |
|
1337 | + $state_abv = array_keys($states); |
|
1338 | + sort($state_abv); |
|
1339 | 1339 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
1340 | 1340 | |
1341 | - $states = array_values($states); |
|
1342 | - sort($states); |
|
1341 | + $states = array_values($states); |
|
1342 | + sort($states); |
|
1343 | 1343 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
1344 | - unset($state_abv, $states); |
|
1344 | + unset($state_abv, $states); |
|
1345 | 1345 | |
1346 | 1346 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
1347 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
1348 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
1349 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
1350 | - ); |
|
1347 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
1348 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
1349 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
1350 | + ); |
|
1351 | 1351 | |
1352 | 1352 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
1353 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1354 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1355 | - ); |
|
1353 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1354 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1355 | + ); |
|
1356 | 1356 | |
1357 | 1357 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
1358 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1359 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1360 | - ); |
|
1358 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1359 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1360 | + ); |
|
1361 | 1361 | |
1362 | 1362 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
1363 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1364 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1365 | - ); |
|
1363 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1364 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1365 | + ); |
|
1366 | 1366 | |
1367 | 1367 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
1368 | - } |
|
1368 | + } |
|
1369 | 1369 | |
1370 | 1370 | public static function field_selection() { |
1371 | 1371 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1402,8 +1402,8 @@ discard block |
||
1402 | 1402 | return FrmField::is_required( $field ); |
1403 | 1403 | } |
1404 | 1404 | |
1405 | - public static function maybe_get_field( &$field ) { |
|
1405 | + public static function maybe_get_field( &$field ) { |
|
1406 | 1406 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
1407 | 1407 | FrmField::maybe_get_field( $field ); |
1408 | - } |
|
1408 | + } |
|
1409 | 1409 | } |
@@ -2,129 +2,129 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | - public static function load_field() { |
|
5 | + public static function load_field() { |
|
6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
8 | 8 | |
9 | - $fields = $_POST['field']; |
|
10 | - if ( empty( $fields ) ) { |
|
11 | - wp_die(); |
|
12 | - } |
|
9 | + $fields = $_POST['field']; |
|
10 | + if ( empty( $fields ) ) { |
|
11 | + wp_die(); |
|
12 | + } |
|
13 | 13 | |
14 | - $_GET['page'] = 'formidable'; |
|
15 | - $fields = stripslashes_deep( $fields ); |
|
14 | + $_GET['page'] = 'formidable'; |
|
15 | + $fields = stripslashes_deep( $fields ); |
|
16 | 16 | |
17 | - $ajax = true; |
|
17 | + $ajax = true; |
|
18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
19 | - $path = FrmAppHelper::plugin_path(); |
|
20 | - $field_html = array(); |
|
21 | - |
|
22 | - foreach ( $fields as $field ) { |
|
23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | - $field = json_decode( $field, true ); |
|
25 | - if ( ! isset( $field['id'] ) ) { |
|
26 | - // this field may have already been loaded |
|
27 | - continue; |
|
28 | - } |
|
19 | + $path = FrmAppHelper::plugin_path(); |
|
20 | + $field_html = array(); |
|
21 | + |
|
22 | + foreach ( $fields as $field ) { |
|
23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | + $field = json_decode( $field, true ); |
|
25 | + if ( ! isset( $field['id'] ) ) { |
|
26 | + // this field may have already been loaded |
|
27 | + continue; |
|
28 | + } |
|
29 | 29 | |
30 | - $field_id = absint( $field['id'] ); |
|
30 | + $field_id = absint( $field['id'] ); |
|
31 | 31 | |
32 | - if ( ! isset( $field['value'] ) ) { |
|
33 | - $field['value'] = ''; |
|
34 | - } |
|
32 | + if ( ! isset( $field['value'] ) ) { |
|
33 | + $field['value'] = ''; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
38 | 38 | |
39 | - ob_start(); |
|
39 | + ob_start(); |
|
40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
42 | - ob_end_clean(); |
|
43 | - } |
|
41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
42 | + ob_end_clean(); |
|
43 | + } |
|
44 | 44 | |
45 | - unset($path); |
|
45 | + unset($path); |
|
46 | 46 | |
47 | - echo json_encode($field_html); |
|
47 | + echo json_encode($field_html); |
|
48 | 48 | |
49 | - wp_die(); |
|
50 | - } |
|
49 | + wp_die(); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Create a new field with ajax |
54 | 54 | */ |
55 | - public static function create() { |
|
55 | + public static function create() { |
|
56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
58 | 58 | |
59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
61 | 61 | |
62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
63 | 63 | |
64 | - // this hook will allow for multiple fields to be added at once |
|
65 | - do_action('frm_after_field_created', $field, $form_id); |
|
64 | + // this hook will allow for multiple fields to be added at once |
|
65 | + do_action('frm_after_field_created', $field, $form_id); |
|
66 | 66 | |
67 | - wp_die(); |
|
68 | - } |
|
67 | + wp_die(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Set up and create a new field |
|
72 | - * |
|
73 | - * @param string $field_type |
|
74 | - * @param integer $form_id |
|
75 | - * @return array|bool |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Set up and create a new field |
|
72 | + * |
|
73 | + * @param string $field_type |
|
74 | + * @param integer $form_id |
|
75 | + * @return array|bool |
|
76 | + */ |
|
77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
78 | - $values = array(); |
|
79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
81 | - } |
|
78 | + $values = array(); |
|
79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
85 | 85 | |
86 | - $field_id = FrmField::create( $field_values ); |
|
86 | + $field_id = FrmField::create( $field_values ); |
|
87 | 87 | |
88 | - if ( ! $field_id ) { |
|
89 | - return false; |
|
90 | - } |
|
88 | + if ( ! $field_id ) { |
|
89 | + return false; |
|
90 | + } |
|
91 | 91 | |
92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
93 | 93 | |
94 | - return $field; |
|
95 | - } |
|
94 | + return $field; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
100 | 100 | |
101 | - if ( empty($field) ) { |
|
102 | - $field = 'name'; |
|
103 | - } |
|
101 | + if ( empty($field) ) { |
|
102 | + $field = 'name'; |
|
103 | + } |
|
104 | 104 | |
105 | - if ( empty($id) ) { |
|
105 | + if ( empty($id) ) { |
|
106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
108 | - } |
|
108 | + } |
|
109 | 109 | |
110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
111 | 111 | $value = trim( $value ); |
112 | - if ( trim(strip_tags($value)) == '' ) { |
|
113 | - // set blank value if there is no content |
|
114 | - $value = ''; |
|
115 | - } |
|
112 | + if ( trim(strip_tags($value)) == '' ) { |
|
113 | + // set blank value if there is no content |
|
114 | + $value = ''; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
118 | 118 | |
119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
120 | 120 | |
121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
122 | - wp_die(); |
|
123 | - } |
|
122 | + wp_die(); |
|
123 | + } |
|
124 | 124 | |
125 | - public static function update_ajax_option() { |
|
125 | + public static function update_ajax_option() { |
|
126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
128 | 128 | |
129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
130 | 130 | if ( ! $field_id ) { |
@@ -139,141 +139,141 @@ discard block |
||
139 | 139 | unset($new_val); |
140 | 140 | } |
141 | 141 | |
142 | - FrmField::update( $field_id, array( |
|
143 | - 'field_options' => $field->field_options, |
|
142 | + FrmField::update( $field_id, array( |
|
143 | + 'field_options' => $field->field_options, |
|
144 | 144 | 'form_id' => $field->form_id, |
145 | - ) ); |
|
146 | - wp_die(); |
|
147 | - } |
|
145 | + ) ); |
|
146 | + wp_die(); |
|
147 | + } |
|
148 | 148 | |
149 | - public static function duplicate() { |
|
149 | + public static function duplicate() { |
|
150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
152 | 152 | |
153 | - global $wpdb; |
|
153 | + global $wpdb; |
|
154 | 154 | |
155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
157 | 157 | |
158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
159 | - if ( ! $copy_field ) { |
|
160 | - wp_die(); |
|
161 | - } |
|
159 | + if ( ! $copy_field ) { |
|
160 | + wp_die(); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
165 | 165 | |
166 | - $values = array( 'id' => $form_id ); |
|
167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
166 | + $values = array( 'id' => $form_id ); |
|
167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
168 | 168 | |
169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
170 | 170 | |
171 | - $values['field_order'] = $field_count + 1; |
|
171 | + $values['field_order'] = $field_count + 1; |
|
172 | 172 | |
173 | - if ( ! $field_id = FrmField::create($values) ) { |
|
174 | - wp_die(); |
|
175 | - } |
|
173 | + if ( ! $field_id = FrmField::create($values) ) { |
|
174 | + wp_die(); |
|
175 | + } |
|
176 | 176 | |
177 | - self::include_single_field($field_id, $values); |
|
177 | + self::include_single_field($field_id, $values); |
|
178 | 178 | |
179 | - wp_die(); |
|
180 | - } |
|
179 | + wp_die(); |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * Load a single field in the form builder along with all needed variables |
|
184 | - */ |
|
185 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
186 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
182 | + /** |
|
183 | + * Load a single field in the form builder along with all needed variables |
|
184 | + */ |
|
185 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
186 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
187 | 187 | $field_name = 'item_meta[' . $field_id . ']'; |
188 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
189 | - $id = $form_id ? $form_id : $field['form_id']; |
|
190 | - if ( $field['type'] == 'html' ) { |
|
191 | - $field['stop_filter'] = true; |
|
192 | - } |
|
188 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
189 | + $id = $form_id ? $form_id : $field['form_id']; |
|
190 | + if ( $field['type'] == 'html' ) { |
|
191 | + $field['stop_filter'] = true; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
195 | 195 | |
196 | - return $field; |
|
197 | - } |
|
196 | + return $field; |
|
197 | + } |
|
198 | 198 | |
199 | - public static function destroy() { |
|
199 | + public static function destroy() { |
|
200 | 200 | FrmAppHelper::permission_check('frm_edit_forms'); |
201 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
201 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
202 | 202 | |
203 | 203 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
204 | 204 | FrmField::destroy( $field_id ); |
205 | - wp_die(); |
|
206 | - } |
|
205 | + wp_die(); |
|
206 | + } |
|
207 | 207 | |
208 | - /* Field Options */ |
|
208 | + /* Field Options */ |
|
209 | 209 | |
210 | - //Add Single Option or Other Option |
|
211 | - public static function add_option() { |
|
210 | + //Add Single Option or Other Option |
|
211 | + public static function add_option() { |
|
212 | 212 | FrmAppHelper::permission_check('frm_edit_forms'); |
213 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
213 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
214 | 214 | |
215 | 215 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
216 | 216 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
217 | 217 | |
218 | - //Get the field |
|
219 | - $field = FrmField::getOne($id); |
|
218 | + //Get the field |
|
219 | + $field = FrmField::getOne($id); |
|
220 | 220 | |
221 | 221 | if ( ! empty( $field->options ) ) { |
222 | 222 | $keys = array_keys( $field->options ); |
223 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
224 | - } else { |
|
225 | - $last = 0; |
|
226 | - } |
|
227 | - $opt_key = $last + 1; |
|
223 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
224 | + } else { |
|
225 | + $last = 0; |
|
226 | + } |
|
227 | + $opt_key = $last + 1; |
|
228 | 228 | |
229 | - if ( 'other' == $opt_type ) { |
|
229 | + if ( 'other' == $opt_type ) { |
|
230 | 230 | $opt = esc_html__( 'Other', 'formidable' ); |
231 | - $other_val = ''; |
|
232 | - $opt_key = 'other_' . $opt_key; |
|
233 | - |
|
234 | - //Update value of "other" in DB |
|
235 | - $field_options = maybe_unserialize( $field->field_options ); |
|
236 | - $field_options['other'] = 1; |
|
237 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
238 | - } else { |
|
231 | + $other_val = ''; |
|
232 | + $opt_key = 'other_' . $opt_key; |
|
233 | + |
|
234 | + //Update value of "other" in DB |
|
235 | + $field_options = maybe_unserialize( $field->field_options ); |
|
236 | + $field_options['other'] = 1; |
|
237 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
238 | + } else { |
|
239 | 239 | $first_opt = reset( $field->options ); |
240 | 240 | $next_opt = count( $field->options ); |
241 | - if ( $first_opt != '' ) { |
|
242 | - $next_opt++; |
|
243 | - } |
|
241 | + if ( $first_opt != '' ) { |
|
242 | + $next_opt++; |
|
243 | + } |
|
244 | 244 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
245 | - unset($next_opt); |
|
246 | - } |
|
247 | - $field_val = $opt; |
|
245 | + unset($next_opt); |
|
246 | + } |
|
247 | + $field_val = $opt; |
|
248 | 248 | $field->options[ $opt_key ] = $opt; |
249 | 249 | |
250 | - //Update options in DB |
|
250 | + //Update options in DB |
|
251 | 251 | FrmField::update( $id, array( 'options' => $field->options ) ); |
252 | 252 | |
253 | - $field_data = $field; |
|
254 | - $field = array( |
|
255 | - 'type' => $field_data->type, |
|
256 | - 'id' => $id, |
|
257 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
258 | - 'form_id' => $field_data->form_id, |
|
259 | - 'field_key' => $field_data->field_key, |
|
260 | - ); |
|
253 | + $field_data = $field; |
|
254 | + $field = array( |
|
255 | + 'type' => $field_data->type, |
|
256 | + 'id' => $id, |
|
257 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
258 | + 'form_id' => $field_data->form_id, |
|
259 | + 'field_key' => $field_data->field_key, |
|
260 | + ); |
|
261 | 261 | |
262 | 262 | $field_name = 'item_meta[' . $id . ']'; |
263 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
264 | - $checked = ''; |
|
263 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
264 | + $checked = ''; |
|
265 | 265 | |
266 | - if ( 'other' == $opt_type ) { |
|
266 | + if ( 'other' == $opt_type ) { |
|
267 | 267 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
268 | - } else { |
|
268 | + } else { |
|
269 | 269 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
270 | - } |
|
271 | - wp_die(); |
|
272 | - } |
|
270 | + } |
|
271 | + wp_die(); |
|
272 | + } |
|
273 | 273 | |
274 | - public static function edit_option() { |
|
274 | + public static function edit_option() { |
|
275 | 275 | FrmAppHelper::permission_check('frm_edit_forms'); |
276 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
276 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
277 | 277 | |
278 | 278 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
279 | 279 | $ids = explode( '-', $element_id ); |
@@ -281,43 +281,43 @@ discard block |
||
281 | 281 | |
282 | 282 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
283 | 283 | if ( strpos( $element_id, 'key_' ) ) { |
284 | - $new_value = $update_value; |
|
285 | - } else { |
|
286 | - $new_label = $update_value; |
|
287 | - } |
|
284 | + $new_value = $update_value; |
|
285 | + } else { |
|
286 | + $new_label = $update_value; |
|
287 | + } |
|
288 | 288 | |
289 | - $field = FrmField::getOne($id); |
|
290 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
289 | + $field = FrmField::getOne($id); |
|
290 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
291 | 291 | |
292 | - $this_opt_id = end($ids); |
|
292 | + $this_opt_id = end($ids); |
|
293 | 293 | $this_opt = (array) $field->options[ $this_opt_id ]; |
294 | 294 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
295 | 295 | |
296 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
297 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
296 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
297 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
298 | 298 | |
299 | - if ( ! isset( $new_label ) ) { |
|
300 | - $new_label = $label; |
|
301 | - } |
|
299 | + if ( ! isset( $new_label ) ) { |
|
300 | + $new_label = $label; |
|
301 | + } |
|
302 | 302 | |
303 | - if ( isset($new_value) || isset($value) ) { |
|
304 | - $update_value = isset($new_value) ? $new_value : $value; |
|
305 | - } |
|
303 | + if ( isset($new_value) || isset($value) ) { |
|
304 | + $update_value = isset($new_value) ? $new_value : $value; |
|
305 | + } |
|
306 | 306 | |
307 | 307 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
308 | 308 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
309 | - } else { |
|
309 | + } else { |
|
310 | 310 | $field->options[ $this_opt_id ] = $orig_update_value; |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | 313 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
314 | 314 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
315 | - wp_die(); |
|
316 | - } |
|
315 | + wp_die(); |
|
316 | + } |
|
317 | 317 | |
318 | - public static function delete_option() { |
|
318 | + public static function delete_option() { |
|
319 | 319 | FrmAppHelper::permission_check('frm_edit_forms'); |
320 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
320 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
321 | 321 | |
322 | 322 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
323 | 323 | $field = FrmField::getOne( $field_id ); |
@@ -325,310 +325,310 @@ discard block |
||
325 | 325 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
326 | 326 | |
327 | 327 | $options = $field->options; |
328 | - unset( $options[ $opt_key ] ); |
|
329 | - $response = array( 'other' => true ); |
|
328 | + unset( $options[ $opt_key ] ); |
|
329 | + $response = array( 'other' => true ); |
|
330 | 330 | |
331 | - //If the deleted option is an "other" option |
|
331 | + //If the deleted option is an "other" option |
|
332 | 332 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
333 | - //Assume all other options are gone, unless proven otherwise |
|
334 | - $other = false; |
|
333 | + //Assume all other options are gone, unless proven otherwise |
|
334 | + $other = false; |
|
335 | 335 | |
336 | - //Check if all other options are really gone |
|
337 | - foreach ( $options as $o_key => $o_val ) { |
|
338 | - //If there is still an other option in the field, set other to true |
|
336 | + //Check if all other options are really gone |
|
337 | + foreach ( $options as $o_key => $o_val ) { |
|
338 | + //If there is still an other option in the field, set other to true |
|
339 | 339 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
340 | - $other = true; |
|
341 | - break; |
|
342 | - } |
|
343 | - unset( $o_key, $o_val ); |
|
344 | - } |
|
345 | - |
|
346 | - //If all other options are gone |
|
347 | - if ( false === $other ) { |
|
348 | - $field_options = maybe_unserialize( $field->field_options ); |
|
349 | - $field_options['other'] = 0; |
|
340 | + $other = true; |
|
341 | + break; |
|
342 | + } |
|
343 | + unset( $o_key, $o_val ); |
|
344 | + } |
|
345 | + |
|
346 | + //If all other options are gone |
|
347 | + if ( false === $other ) { |
|
348 | + $field_options = maybe_unserialize( $field->field_options ); |
|
349 | + $field_options['other'] = 0; |
|
350 | 350 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
351 | - $response = array( 'other' => false ); |
|
352 | - } |
|
353 | - } |
|
354 | - echo json_encode( $response ); |
|
351 | + $response = array( 'other' => false ); |
|
352 | + } |
|
353 | + } |
|
354 | + echo json_encode( $response ); |
|
355 | 355 | |
356 | 356 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
357 | 357 | |
358 | - wp_die(); |
|
359 | - } |
|
358 | + wp_die(); |
|
359 | + } |
|
360 | 360 | |
361 | - public static function import_choices() { |
|
362 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
361 | + public static function import_choices() { |
|
362 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
363 | 363 | |
364 | 364 | $field_id = absint( $_REQUEST['field_id'] ); |
365 | 365 | |
366 | - global $current_screen, $hook_suffix; |
|
366 | + global $current_screen, $hook_suffix; |
|
367 | 367 | |
368 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
369 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
370 | - $hook_suffix = ''; |
|
371 | - set_current_screen(); |
|
372 | - } |
|
368 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
369 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
370 | + $hook_suffix = ''; |
|
371 | + set_current_screen(); |
|
372 | + } |
|
373 | 373 | |
374 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
375 | - register_admin_color_schemes(); |
|
376 | - } |
|
374 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
375 | + register_admin_color_schemes(); |
|
376 | + } |
|
377 | 377 | |
378 | - $hook_suffix = $admin_body_class = ''; |
|
378 | + $hook_suffix = $admin_body_class = ''; |
|
379 | 379 | |
380 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
381 | - $admin_body_class .= ' folded'; |
|
382 | - } |
|
380 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
381 | + $admin_body_class .= ' folded'; |
|
382 | + } |
|
383 | 383 | |
384 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
385 | - $admin_body_class .= ' admin-bar'; |
|
386 | - } |
|
384 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
385 | + $admin_body_class .= ' admin-bar'; |
|
386 | + } |
|
387 | 387 | |
388 | - if ( is_rtl() ) { |
|
389 | - $admin_body_class .= ' rtl'; |
|
390 | - } |
|
388 | + if ( is_rtl() ) { |
|
389 | + $admin_body_class .= ' rtl'; |
|
390 | + } |
|
391 | 391 | |
392 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
393 | - $prepop = array(); |
|
394 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
392 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
393 | + $prepop = array(); |
|
394 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
395 | 395 | |
396 | - $field = FrmField::getOne($field_id); |
|
396 | + $field = FrmField::getOne($field_id); |
|
397 | 397 | |
398 | - wp_enqueue_script( 'utils' ); |
|
398 | + wp_enqueue_script( 'utils' ); |
|
399 | 399 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
400 | - FrmAppHelper::load_admin_wide_js(); |
|
400 | + FrmAppHelper::load_admin_wide_js(); |
|
401 | 401 | |
402 | 402 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
403 | - wp_die(); |
|
404 | - } |
|
403 | + wp_die(); |
|
404 | + } |
|
405 | 405 | |
406 | - public static function import_options() { |
|
406 | + public static function import_options() { |
|
407 | 407 | FrmAppHelper::permission_check('frm_edit_forms'); |
408 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
408 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
409 | 409 | |
410 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
411 | - return; |
|
412 | - } |
|
410 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
411 | + return; |
|
412 | + } |
|
413 | 413 | |
414 | 414 | $field_id = absint( $_POST['field_id'] ); |
415 | - $field = FrmField::getOne($field_id); |
|
415 | + $field = FrmField::getOne($field_id); |
|
416 | 416 | |
417 | 417 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
418 | - return; |
|
419 | - } |
|
420 | - |
|
421 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
422 | - $opts = stripslashes_deep($_POST['opts']); |
|
423 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
424 | - if ( $field['separate_value'] ) { |
|
425 | - foreach ( $opts as $opt_key => $opt ) { |
|
426 | - if ( strpos($opt, '|') !== false ) { |
|
427 | - $vals = explode('|', $opt); |
|
428 | - if ( $vals[0] != $vals[1] ) { |
|
429 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
430 | - } |
|
431 | - unset($vals); |
|
432 | - } |
|
433 | - unset($opt_key, $opt); |
|
434 | - } |
|
435 | - } |
|
436 | - |
|
437 | - //Keep other options after bulk update |
|
438 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
439 | - $other_array = array(); |
|
440 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
441 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
442 | - $other_array[ $opt_key ] = $opt; |
|
443 | - } |
|
444 | - unset($opt_key, $opt); |
|
445 | - } |
|
446 | - if ( ! empty($other_array) ) { |
|
447 | - $opts = array_merge( $opts, $other_array); |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
452 | - |
|
453 | - $field['options'] = $opts; |
|
454 | - $field_name = $field['name']; |
|
455 | - |
|
456 | - // Get html_id which will be used in single-option.php |
|
457 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
458 | - |
|
459 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
418 | + return; |
|
419 | + } |
|
420 | + |
|
421 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
422 | + $opts = stripslashes_deep($_POST['opts']); |
|
423 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
424 | + if ( $field['separate_value'] ) { |
|
425 | + foreach ( $opts as $opt_key => $opt ) { |
|
426 | + if ( strpos($opt, '|') !== false ) { |
|
427 | + $vals = explode('|', $opt); |
|
428 | + if ( $vals[0] != $vals[1] ) { |
|
429 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
430 | + } |
|
431 | + unset($vals); |
|
432 | + } |
|
433 | + unset($opt_key, $opt); |
|
434 | + } |
|
435 | + } |
|
436 | + |
|
437 | + //Keep other options after bulk update |
|
438 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
439 | + $other_array = array(); |
|
440 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
441 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
442 | + $other_array[ $opt_key ] = $opt; |
|
443 | + } |
|
444 | + unset($opt_key, $opt); |
|
445 | + } |
|
446 | + if ( ! empty($other_array) ) { |
|
447 | + $opts = array_merge( $opts, $other_array); |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
452 | + |
|
453 | + $field['options'] = $opts; |
|
454 | + $field_name = $field['name']; |
|
455 | + |
|
456 | + // Get html_id which will be used in single-option.php |
|
457 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
458 | + |
|
459 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
460 | 460 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
461 | - } else { |
|
462 | - FrmFieldsHelper::show_single_option($field); |
|
463 | - } |
|
461 | + } else { |
|
462 | + FrmFieldsHelper::show_single_option($field); |
|
463 | + } |
|
464 | 464 | |
465 | - wp_die(); |
|
466 | - } |
|
465 | + wp_die(); |
|
466 | + } |
|
467 | 467 | |
468 | - public static function update_order() { |
|
468 | + public static function update_order() { |
|
469 | 469 | FrmAppHelper::permission_check('frm_edit_forms'); |
470 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
470 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
471 | 471 | |
472 | 472 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
473 | 473 | foreach ( (array) $fields as $position => $item ) { |
474 | 474 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
475 | 475 | } |
476 | - wp_die(); |
|
477 | - } |
|
476 | + wp_die(); |
|
477 | + } |
|
478 | 478 | |
479 | 479 | public static function change_type( $type ) { |
480 | - $type_switch = array( |
|
481 | - 'scale' => 'radio', |
|
482 | - '10radio' => 'radio', |
|
483 | - 'rte' => 'textarea', |
|
484 | - 'website' => 'url', |
|
485 | - ); |
|
486 | - if ( isset( $type_switch[ $type ] ) ) { |
|
487 | - $type = $type_switch[ $type ]; |
|
488 | - } |
|
480 | + $type_switch = array( |
|
481 | + 'scale' => 'radio', |
|
482 | + '10radio' => 'radio', |
|
483 | + 'rte' => 'textarea', |
|
484 | + 'website' => 'url', |
|
485 | + ); |
|
486 | + if ( isset( $type_switch[ $type ] ) ) { |
|
487 | + $type = $type_switch[ $type ]; |
|
488 | + } |
|
489 | 489 | |
490 | 490 | $frm_field_selection = FrmField::field_selection(); |
491 | - $types = array_keys($frm_field_selection); |
|
492 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
493 | - $type = 'text'; |
|
494 | - } |
|
491 | + $types = array_keys($frm_field_selection); |
|
492 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
493 | + $type = 'text'; |
|
494 | + } |
|
495 | 495 | |
496 | - return $type; |
|
497 | - } |
|
496 | + return $type; |
|
497 | + } |
|
498 | 498 | |
499 | 499 | public static function display_field_options( $display ) { |
500 | 500 | switch ( $display['type'] ) { |
501 | - case 'captcha': |
|
502 | - $display['required'] = false; |
|
503 | - $display['invalid'] = true; |
|
504 | - $display['default_blank'] = false; |
|
501 | + case 'captcha': |
|
502 | + $display['required'] = false; |
|
503 | + $display['invalid'] = true; |
|
504 | + $display['default_blank'] = false; |
|
505 | 505 | $display['captcha_size'] = true; |
506 | - break; |
|
507 | - case 'radio': |
|
508 | - $display['default_blank'] = false; |
|
509 | - break; |
|
510 | - case 'text': |
|
511 | - case 'textarea': |
|
512 | - $display['size'] = true; |
|
513 | - $display['clear_on_focus'] = true; |
|
514 | - break; |
|
515 | - case 'select': |
|
516 | - $display['size'] = true; |
|
517 | - break; |
|
518 | - case 'url': |
|
519 | - case 'website': |
|
520 | - case 'email': |
|
521 | - $display['size'] = true; |
|
522 | - $display['clear_on_focus'] = true; |
|
523 | - $display['invalid'] = true; |
|
524 | - } |
|
525 | - |
|
526 | - return $display; |
|
527 | - } |
|
528 | - |
|
529 | - public static function input_html( $field, $echo = true ) { |
|
530 | - $class = array(); //$field['type']; |
|
531 | - self::add_input_classes($field, $class); |
|
532 | - |
|
533 | - $add_html = array(); |
|
534 | - self::add_html_size($field, $add_html); |
|
535 | - self::add_html_length($field, $add_html); |
|
536 | - self::add_html_placeholder($field, $add_html, $class); |
|
506 | + break; |
|
507 | + case 'radio': |
|
508 | + $display['default_blank'] = false; |
|
509 | + break; |
|
510 | + case 'text': |
|
511 | + case 'textarea': |
|
512 | + $display['size'] = true; |
|
513 | + $display['clear_on_focus'] = true; |
|
514 | + break; |
|
515 | + case 'select': |
|
516 | + $display['size'] = true; |
|
517 | + break; |
|
518 | + case 'url': |
|
519 | + case 'website': |
|
520 | + case 'email': |
|
521 | + $display['size'] = true; |
|
522 | + $display['clear_on_focus'] = true; |
|
523 | + $display['invalid'] = true; |
|
524 | + } |
|
525 | + |
|
526 | + return $display; |
|
527 | + } |
|
528 | + |
|
529 | + public static function input_html( $field, $echo = true ) { |
|
530 | + $class = array(); //$field['type']; |
|
531 | + self::add_input_classes($field, $class); |
|
532 | + |
|
533 | + $add_html = array(); |
|
534 | + self::add_html_size($field, $add_html); |
|
535 | + self::add_html_length($field, $add_html); |
|
536 | + self::add_html_placeholder($field, $add_html, $class); |
|
537 | 537 | self::add_validation_messages( $field, $add_html ); |
538 | 538 | |
539 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
539 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
540 | 540 | |
541 | 541 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
542 | 542 | |
543 | - self::add_shortcodes_to_html($field, $add_html); |
|
543 | + self::add_shortcodes_to_html($field, $add_html); |
|
544 | 544 | |
545 | 545 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
546 | 546 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
547 | 547 | |
548 | - if ( $echo ) { |
|
549 | - echo $add_html; |
|
550 | - } |
|
548 | + if ( $echo ) { |
|
549 | + echo $add_html; |
|
550 | + } |
|
551 | 551 | |
552 | - return $add_html; |
|
553 | - } |
|
552 | + return $add_html; |
|
553 | + } |
|
554 | 554 | |
555 | 555 | private static function add_input_classes( $field, array &$class ) { |
556 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
557 | - $class[] = $field['input_class']; |
|
558 | - } |
|
556 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
557 | + $class[] = $field['input_class']; |
|
558 | + } |
|
559 | 559 | |
560 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
561 | - return; |
|
562 | - } |
|
560 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
561 | + return; |
|
562 | + } |
|
563 | 563 | |
564 | - global $frm_vars; |
|
564 | + global $frm_vars; |
|
565 | 565 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
566 | - $class[] = 'dyn_default_value'; |
|
567 | - } |
|
566 | + $class[] = 'dyn_default_value'; |
|
567 | + } |
|
568 | 568 | |
569 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
570 | - $class[] = 'auto_width'; |
|
571 | - } |
|
572 | - } |
|
569 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
570 | + $class[] = 'auto_width'; |
|
571 | + } |
|
572 | + } |
|
573 | 573 | |
574 | 574 | private static function add_html_size( $field, array &$add_html ) { |
575 | 575 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
576 | - return; |
|
577 | - } |
|
576 | + return; |
|
577 | + } |
|
578 | 578 | |
579 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
580 | - return; |
|
581 | - } |
|
579 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
580 | + return; |
|
581 | + } |
|
582 | 582 | |
583 | - if ( is_numeric($field['size']) ) { |
|
584 | - $field['size'] .= 'px'; |
|
585 | - } |
|
583 | + if ( is_numeric($field['size']) ) { |
|
584 | + $field['size'] .= 'px'; |
|
585 | + } |
|
586 | 586 | |
587 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
588 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
587 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
588 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
589 | 589 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
590 | 590 | |
591 | - self::add_html_cols($field, $add_html); |
|
592 | - } |
|
591 | + self::add_html_cols($field, $add_html); |
|
592 | + } |
|
593 | 593 | |
594 | 594 | private static function add_html_cols( $field, array &$add_html ) { |
595 | 595 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
596 | - return; |
|
597 | - } |
|
596 | + return; |
|
597 | + } |
|
598 | 598 | |
599 | - // convert to cols for textareas |
|
600 | - $calc = array( |
|
601 | - '' => 9, |
|
602 | - 'px' => 9, |
|
603 | - 'rem' => 0.444, |
|
604 | - 'em' => 0.544, |
|
605 | - ); |
|
599 | + // convert to cols for textareas |
|
600 | + $calc = array( |
|
601 | + '' => 9, |
|
602 | + 'px' => 9, |
|
603 | + 'rem' => 0.444, |
|
604 | + 'em' => 0.544, |
|
605 | + ); |
|
606 | 606 | |
607 | - // include "col" for valid html |
|
608 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
607 | + // include "col" for valid html |
|
608 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
609 | 609 | |
610 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
611 | - return; |
|
612 | - } |
|
610 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
611 | + return; |
|
612 | + } |
|
613 | 613 | |
614 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
614 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
615 | 615 | |
616 | 616 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
617 | - } |
|
617 | + } |
|
618 | 618 | |
619 | 619 | private static function add_html_length( $field, array &$add_html ) { |
620 | - // check for max setting and if this field accepts maxlength |
|
620 | + // check for max setting and if this field accepts maxlength |
|
621 | 621 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
622 | - return; |
|
623 | - } |
|
622 | + return; |
|
623 | + } |
|
624 | 624 | |
625 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
626 | - // don't load on form builder page |
|
627 | - return; |
|
628 | - } |
|
625 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
626 | + // don't load on form builder page |
|
627 | + return; |
|
628 | + } |
|
629 | 629 | |
630 | 630 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
631 | - } |
|
631 | + } |
|
632 | 632 | |
633 | 633 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
634 | 634 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -636,35 +636,35 @@ discard block |
||
636 | 636 | } |
637 | 637 | |
638 | 638 | $default_value_array = is_array( $field['default_value'] ); |
639 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
639 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
640 | 640 | if ( $default_value_array ) { |
641 | 641 | $field['default_value'] = json_encode( $field['default_value'] ); |
642 | 642 | } |
643 | 643 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
644 | - return; |
|
645 | - } |
|
644 | + return; |
|
645 | + } |
|
646 | 646 | |
647 | 647 | if ( $default_value_array ) { |
648 | 648 | // don't include a json placeholder |
649 | 649 | return; |
650 | 650 | } |
651 | 651 | |
652 | - $frm_settings = FrmAppHelper::get_settings(); |
|
652 | + $frm_settings = FrmAppHelper::get_settings(); |
|
653 | 653 | |
654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
655 | - // use HMTL5 placeholder with js fallback |
|
655 | + // use HMTL5 placeholder with js fallback |
|
656 | 656 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
657 | - wp_enqueue_script('jquery-placeholder'); |
|
658 | - } else if ( ! $frm_settings->use_html ) { |
|
657 | + wp_enqueue_script('jquery-placeholder'); |
|
658 | + } else if ( ! $frm_settings->use_html ) { |
|
659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
660 | 660 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
661 | - $class[] = 'frm_toggle_default'; |
|
661 | + $class[] = 'frm_toggle_default'; |
|
662 | 662 | |
663 | - if ( $field['value'] == $field['default_value'] ) { |
|
664 | - $class[] = 'frm_default'; |
|
665 | - } |
|
666 | - } |
|
667 | - } |
|
663 | + if ( $field['value'] == $field['default_value'] ) { |
|
664 | + $class[] = 'frm_default'; |
|
665 | + } |
|
666 | + } |
|
667 | + } |
|
668 | 668 | |
669 | 669 | private static function add_validation_messages( $field, array &$add_html ) { |
670 | 670 | if ( FrmField::is_required( $field ) ) { |
@@ -685,44 +685,44 @@ discard block |
||
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
689 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
690 | - return; |
|
691 | - } |
|
688 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
689 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
690 | + return; |
|
691 | + } |
|
692 | 692 | |
693 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
694 | - if ( 'opt' === $k ) { |
|
695 | - continue; |
|
696 | - } |
|
693 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
694 | + if ( 'opt' === $k ) { |
|
695 | + continue; |
|
696 | + } |
|
697 | 697 | |
698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
699 | - $add_html[] = $v; |
|
700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
698 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
699 | + $add_html[] = $v; |
|
700 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
701 | 701 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
702 | - } else { |
|
702 | + } else { |
|
703 | 703 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
704 | - } |
|
705 | - |
|
706 | - unset($k, $v); |
|
707 | - } |
|
708 | - } |
|
709 | - |
|
710 | - public static function check_value( $opt, $opt_key, $field ) { |
|
711 | - if ( is_array( $opt ) ) { |
|
712 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
713 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
714 | - } else { |
|
715 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
716 | - } |
|
717 | - } |
|
718 | - return $opt; |
|
719 | - } |
|
704 | + } |
|
705 | + |
|
706 | + unset($k, $v); |
|
707 | + } |
|
708 | + } |
|
709 | + |
|
710 | + public static function check_value( $opt, $opt_key, $field ) { |
|
711 | + if ( is_array( $opt ) ) { |
|
712 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
713 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
714 | + } else { |
|
715 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
716 | + } |
|
717 | + } |
|
718 | + return $opt; |
|
719 | + } |
|
720 | 720 | |
721 | 721 | public static function check_label( $opt ) { |
722 | - if ( is_array($opt) ) { |
|
723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
724 | - } |
|
722 | + if ( is_array($opt) ) { |
|
723 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
724 | + } |
|
725 | 725 | |
726 | - return $opt; |
|
727 | - } |
|
726 | + return $opt; |
|
727 | + } |
|
728 | 728 | } |