PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFieldsController.php +289 -517 6.284.01.02 View file →
@@ -1,27 +1,14 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmFieldsController {
7 4
8 - /**
9 - * This is stored statically so we can re-use this data for every field.
10 - *
11 - * @var FrmFieldSelectionData|null
12 - */
13 - private static $field_selection_data;
14 -
15 5 public static function load_field() {
16 6 FrmAppHelper::permission_check( 'frm_edit_forms' );
17 7 check_ajax_referer( 'frm_ajax', 'nonce' );
18 8
19 - // Javascript may be included in some field settings.
20 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
21 9 $fields = isset( $_POST['field'] ) ? wp_unslash( $_POST['field'] ) : array();
22 -
23 - if ( ! $fields ) {
10 + if ( empty( $fields ) ) {
24 11 wp_die();
25 12 }
26 13
27 14 $_GET['page'] = 'formidable';
@@ -34,11 +21,10 @@
34 21
35 22 foreach ( $fields as $field ) {
36 23 $field = htmlspecialchars_decode( nl2br( $field ) );
37 24 $field = json_decode( $field );
38 -
39 25 if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
40 - // This field may have already been loaded
26 + // this field may have already been loaded
41 27 continue;
42 28 }
43 29
44 30 if ( ! isset( $field->value ) ) {
@@ -49,10 +35,11 @@
49 35 $field->default_value = json_decode( json_encode( $field->default_value ), true );
50 36
51 37 ob_start();
52 38 self::load_single_field( $field, $values );
53 - $field_html[ absint( $field->id ) ] = ob_get_clean();
54 - }//end foreach
39 + $field_html[ absint( $field->id ) ] = ob_get_contents();
40 + ob_end_clean();
41 + }
55 42
56 43 echo json_encode( $field_html );
57 44
58 45 wp_die();
@@ -64,17 +51,14 @@
64 51 public static function create() {
65 52 FrmAppHelper::permission_check( 'frm_edit_forms' );
66 53 check_ajax_referer( 'frm_ajax', 'nonce' );
67 54
68 - $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
69 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
70 - $field_options = FrmAppHelper::get_post_param( 'field_options', array(), 'wp_kses_post' );
55 + $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
56 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
71 57
72 - do_action( 'frm_before_create_field', $field_type, $form_id );
58 + $field = self::include_new_field( $field_type, $form_id );
73 59
74 - $field = self::include_new_field( $field_type, $form_id, $field_options );
75 -
76 - // This hook will allow for multiple fields to be added at once
60 + // this hook will allow for multiple fields to be added at once
77 61 do_action( 'frm_after_field_created', $field, $form_id );
78 62
79 63 wp_die();
80 64 }
@@ -82,40 +66,29 @@
82 66 /**
83 67 * Set up and create a new field
84 68 *
85 69 * @param string $field_type
86 - * @param int $form_id
87 - * @param array $field_options
70 + * @param integer $form_id
88 71 *
89 - * @return array|false
72 + * @return array|bool
90 73 */
91 - public static function include_new_field( $field_type, $form_id, $field_options = array() ) {
74 + public static function include_new_field( $field_type, $form_id ) {
92 75 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
76 + $field_values = apply_filters( 'frm_before_field_created', $field_values );
93 77
94 - if ( $field_options ) {
95 - $field_values['field_options'] = array_merge( $field_values['field_options'], $field_options );
96 - }
78 + $field_id = FrmField::create( $field_values );
97 79
98 - // When a new field is added to the form, flag it as draft and hide it from the front-end.
99 - $field_values['field_options']['draft'] = 1;
100 -
101 - /**
102 - * @param array $field_values
103 - */
104 - $field_values = apply_filters( 'frm_before_field_created', $field_values );
105 - $field_id = FrmField::create( $field_values );
106 -
107 80 if ( ! $field_id ) {
108 81 return false;
109 82 }
110 83
111 - $field = self::get_field_array_from_id( $field_id );
84 + $field = self::get_field_array_from_id( $field_id );
85 +
112 86 $values = array();
113 -
114 87 if ( FrmAppHelper::pro_is_installed() ) {
115 88 $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
116 - $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
117 89
90 + $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
118 91 if ( $parent_form_id ) {
119 92 $field['parent_form_id'] = $parent_form_id;
120 93 }
121 94 }
@@ -128,16 +101,30 @@
128 101 public static function duplicate() {
129 102 FrmAppHelper::permission_check( 'frm_edit_forms' );
130 103 check_ajax_referer( 'frm_ajax', 'nonce' );
131 104
132 - $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
133 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
134 - $new_field = FrmField::duplicate_single_field( $field_id, $form_id );
105 + $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
106 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
135 107
136 - if ( is_array( $new_field ) && ! empty( $new_field['field_id'] ) ) {
137 - self::load_single_field( $new_field['field_id'], $new_field['values'] );
108 + $copy_field = FrmField::getOne( $field_id );
109 + if ( ! $copy_field ) {
110 + wp_die();
138 111 }
139 112
113 + do_action( 'frm_duplicate_field', $copy_field, $form_id );
114 + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
115 +
116 + $values = array(
117 + 'id' => $copy_field->id,
118 + );
119 + FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id );
120 + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
121 +
122 + $field_id = FrmField::create( $values );
123 + if ( $field_id ) {
124 + self::load_single_field( $field_id, $values );
125 + }
126 +
140 127 wp_die();
141 128 }
142 129
143 130 /**
@@ -148,8 +135,9 @@
148 135 * @return array
149 136 */
150 137 public static function get_field_array_from_id( $field_id ) {
151 138 $field = FrmField::getOne( $field_id );
139 +
152 140 return FrmFieldsHelper::setup_edit_vars( $field );
153 141 }
154 142
155 143 /**
@@ -154,13 +142,11 @@
154 142
155 143 /**
156 144 * @since 3.0
157 145 *
158 - * @param array|int|object|string $field_object
159 - * @param array $values
160 - * @param int $form_id
161 - *
162 - * @return void
146 + * @param int|array|object $field_object
147 + * @param array $values
148 + * @param int $form_id
163 149 */
164 150 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
165 151 global $frm_vars;
166 152 $frm_vars['is_admin'] = true;
@@ -171,62 +157,47 @@
171 157 $field = $field_object;
172 158 $field_object = FrmField::getOne( $field['id'] );
173 159 }
174 160
175 - $field_obj = FrmFieldFactory::get_field_factory( $field_object );
176 - $display = self::display_field_options( array(), $field_obj );
177 - $ajax_loading = ! empty( $values['ajax_load'] );
178 - $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ), true );
161 + $field_obj = FrmFieldFactory::get_field_factory( $field_object );
162 + $display = self::display_field_options( array(), $field_obj );
179 163
164 + $ajax_loading = isset( $values['ajax_load'] ) && $values['ajax_load'];
165 + $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ) );
166 +
180 167 if ( $ajax_loading && $ajax_this_field ) {
181 168 $li_classes = self::get_classes_for_builder_field( array(), $display, $field_obj );
182 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php';
183 - return;
184 - }
169 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/ajax-field-placeholder.php' );
170 + } else {
171 + if ( ! isset( $field ) && is_object( $field_object ) ) {
172 + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
185 173
186 - if ( ! isset( $field ) && is_object( $field_object ) ) {
187 - $field_object->parent_form_id = $values['id'] ?? $field_object->form_id;
188 - $field = FrmFieldsHelper::setup_edit_vars( $field_object );
189 - }
174 + $field = FrmFieldsHelper::setup_edit_vars( $field_object );
175 + }
190 176
191 - /**
192 - * Filter for adding extra attributes to the field container.
193 - *
194 - * @since 6.23
195 - *
196 - * @param array $extra_field_attributes
197 - * @param array $field
198 - * @param array $display
199 - */
200 - $extra_field_attributes = apply_filters( 'frm_field_container_extra_attributes', array(), $field, $display );
177 + $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
178 + $li_classes .= ' ui-state-default widgets-holder-wrap';
201 179
202 - $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
203 - $li_classes .= ' ui-state-default widgets-holder-wrap';
204 -
205 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php';
180 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
181 + }
206 182 }
207 183
208 184 /**
209 185 * @since 3.0
210 - *
211 - * @param array $field
212 - * @param array $display
213 - * @param FrmFieldType $field_info
214 - *
215 - * @return string
216 186 */
217 187 private static function get_classes_for_builder_field( $field, $display, $field_info ) {
218 - $li_classes = $field_info->form_builder_classes( $display['type'] );
219 - $li_classes .= ' frm_form_field frmstart ';
188 + $li_classes = $field_info->form_builder_classes( $display['type'] );
189 + $classes = isset( $field['classes'] ) ? $field['classes'] : '';
220 190
221 - if ( isset( $field['classes'] ) ) {
222 - $li_classes .= trim( $field['classes'] ) . ' ';
191 + // Exclude alignright for now since we aren't using widths.
192 + $classes = str_replace( ' frm_alignright ', ' ', $classes );
193 + if ( trim( $classes ) === 'frm_alignright' ) {
194 + $classes = '';
223 195 }
224 196
225 - $li_classes .= 'frmend';
226 -
227 - if ( $field ) {
228 - return apply_filters( 'frm_build_field_class', $li_classes, $field );
197 + $li_classes .= ' frm_form_field frmstart ' . $classes . ' frmend';
198 + if ( ! empty( $field ) ) {
199 + $li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
229 200 }
230 201
231 202 return $li_classes;
232 203 }
@@ -239,11 +210,10 @@
239 210 FrmField::destroy( $field_id );
240 211 wp_die();
241 212 }
242 213
243 - /**
244 - * Field Options.
245 - */
214 + /* Field Options */
215 +
246 216 public static function import_options() {
247 217 FrmAppHelper::permission_check( 'frm_edit_forms' );
248 218 check_ajax_referer( 'frm_ajax', 'nonce' );
249 219
@@ -250,40 +220,27 @@
250 220 if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
251 221 return;
252 222 }
253 223
254 - $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
255 - $field = FrmField::getOne( $field_id );
256 - $bulk_edit_types = array( 'radio', 'checkbox', 'select' );
224 + $field_id = FrmAppHelper::get_param( 'field_id', '', 'post', 'absint' );
225 + $field = FrmField::getOne( $field_id );
257 226
258 - /**
259 - * Filter to add new fields that will support import_options/Bulk Edit Options.
260 - *
261 - * @since 6.8.4
262 - *
263 - * @param array $bulk_edit_types
264 - *
265 - * @return array
266 - */
267 - $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types );
268 -
269 - if ( ! in_array( $field->type, $bulk_edit_types, true ) ) {
227 + if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
270 228 return;
271 229 }
272 230
273 231 $field = FrmFieldsHelper::setup_edit_vars( $field );
232 + $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
233 + $opts = explode( "\n", rtrim( $opts, "\n" ) );
234 + $opts = array_map( 'trim', $opts );
274 235
275 - $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
276 - $opts = explode( "\n", rtrim( $opts, "\n" ) );
277 - $opts = array_map( 'trim', $opts );
236 + $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
237 + $field['separate_value'] = ( $separate === 'true' );
278 238
279 - $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
280 - $field['separate_value'] = $separate === 'true';
281 -
282 239 if ( $field['separate_value'] ) {
283 240 foreach ( $opts as $opt_key => $opt ) {
284 - if ( str_contains( $opt, '|' ) ) {
285 - $vals = explode( '|', $opt );
241 + if ( strpos( $opt, '|' ) !== false ) {
242 + $vals = explode( '|', $opt );
286 243 $opts[ $opt_key ] = array(
287 244 'label' => trim( $vals[0] ),
288 245 'value' => trim( $vals[1] ),
289 246 );
@@ -293,12 +250,10 @@
293 250 }
294 251 }
295 252
296 253 // Keep other options after bulk update.
297 - // phpcs:ignore Universal.Operators.StrictComparisons
298 - if ( ! empty( $field['field_options']['other'] ) ) {
254 + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
299 255 $other_array = array();
300 -
301 256 foreach ( $field['options'] as $opt_key => $opt ) {
302 257 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
303 258 $other_array[ $opt_key ] = $opt;
304 259 }
@@ -303,10 +258,9 @@
303 258 $other_array[ $opt_key ] = $opt;
304 259 }
305 260 unset( $opt_key, $opt );
306 261 }
307 -
308 - if ( $other_array ) {
262 + if ( ! empty( $other_array ) ) {
309 263 $opts = array_merge( $opts, $other_array );
310 264 }
311 265 }
312 266
@@ -320,10 +274,8 @@
320 274 /**
321 275 * @since 4.0
322 276 *
323 277 * @param array $atts - Includes field array, field_obj, display array, values array.
324 - *
325 - * @return void
326 278 */
327 279 public static function load_single_field_settings( $atts ) {
328 280 $field = $atts['field'];
329 281 $field_obj = $atts['field_obj'];
@@ -338,19 +290,19 @@
338 290 if ( ! isset( $field['read_only'] ) ) {
339 291 $field['read_only'] = false;
340 292 }
341 293
342 - $field_selection_data = self::maybe_define_field_selection_data();
343 - $all_field_types = $field_selection_data->all_field_types;
344 - $disabled_fields = $field_selection_data->disabled_fields;
345 - $frm_settings = FrmAppHelper::get_settings();
346 - $field_types = FrmFieldTypeOptionData::get_field_types( $field['type'] );
294 + $field_types = FrmFieldsHelper::get_field_types( $field['type'] );
295 + $pro_field_selection = FrmField::pro_field_selection();
296 + $all_field_types = array_merge( $pro_field_selection, FrmField::field_selection() );
297 + $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
298 + $frm_settings = FrmAppHelper::get_settings();
347 299
348 300 if ( ! isset( $all_field_types[ $field['type'] ] ) ) {
349 301 // Add fallback for an add-on field type that has been deactivated.
350 302 $all_field_types[ $field['type'] ] = array(
351 303 'name' => ucfirst( $field['type'] ),
352 - 'icon' => 'frmfont frm_pencil_icon',
304 + 'icon' => 'frm_icon_font frm_pencil_icon',
353 305 );
354 306 } elseif ( ! is_array( $all_field_types[ $field['type'] ] ) ) {
355 307 // Fallback for fields added in a more basic way.
356 308 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
@@ -356,34 +308,39 @@
356 308 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
357 309 }
358 310
359 311 $type_name = $all_field_types[ $field['type'] ]['name'];
360 -
361 312 if ( $field['type'] === 'divider' && FrmField::is_option_true( $field, 'repeat' ) ) {
362 313 $type_name = $all_field_types['divider|repeat']['name'];
363 314 }
364 315
316 + $display_type = self::displayed_field_type( $field );
317 +
365 318 if ( $display['default'] ) {
366 319 $default_value_types = self::default_value_types( $field, compact( 'display' ) );
367 320 }
368 321
369 322 if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) {
370 - $field['placeholder'] = implode( ', ', $field['placeholder'] );
323 + $field['placeholder'] = implode( $field['placeholder'], ', ' );
371 324 }
372 -
373 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php';
325 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' );
374 326 }
375 327
376 328 /**
377 - * @since 6.9.1
329 + * Get the type of field being displayed for lookups and dynamic fields.
378 330 *
379 - * @return FrmFieldSelectionData
331 + * @since 4.0
332 + * @return array
380 333 */
381 - private static function maybe_define_field_selection_data() {
382 - if ( ! isset( self::$field_selection_data ) ) {
383 - self::$field_selection_data = new FrmFieldSelectionData();
384 - }
385 - return self::$field_selection_data;
334 + private static function displayed_field_type( $field ) {
335 + $display_type = array(
336 + 'radio' => FrmField::is_field_type( $field, 'radio' ),
337 + 'checkbox' => FrmField::is_field_type( $field, 'checkbox' ),
338 + 'select' => FrmField::is_field_type( $field, 'select' ),
339 + 'lookup' => FrmField::is_field_type( $field, 'lookup' ),
340 + 'data' => FrmField::is_field_type( $field, 'data' ),
341 + );
342 + return array_filter( $display_type );
386 343 }
387 344
388 345 /**
389 346 * Get the list of default value types that can be toggled in the builder.
@@ -388,57 +345,54 @@
388 345 /**
389 346 * Get the list of default value types that can be toggled in the builder.
390 347 *
391 348 * @since 4.0
392 - *
393 - * @param array $field
394 - * @param array $atts
395 - *
396 349 * @return array
397 350 */
398 351 private static function default_value_types( $field, $atts ) {
399 352 $types = array(
400 - 'default_value' => array(
353 + 'default_value' => array(
401 354 'class' => '',
402 - 'icon' => 'frmfont frm_text2_icon',
403 - 'title' => __( 'Default Value', 'formidable' ),
355 + 'icon' => 'frm_icon_font frm_text2_icon',
356 + 'title' => __( 'Default Value (Text)', 'formidable' ),
404 357 'data' => array(
405 358 'frmshow' => '#default-value-for-',
406 359 ),
407 360 ),
408 - 'calc' => array(
409 - 'class' => 'frm_show_upgrade frm_noallow',
410 - 'title' => __( 'Calculate Value', 'formidable' ),
411 - 'icon' => 'frmfont frm_calculator_icon',
412 - 'data' => array(
361 + 'calc' => array(
362 + 'class' => 'frm_show_upgrade frm_noallow',
363 + 'title' => __( 'Default Value (Calculation)', 'formidable' ),
364 + 'icon' => 'frm_icon_font frm_calculator_icon',
365 + 'data' => array(
413 366 'medium' => 'calculations',
414 367 'upgrade' => __( 'Calculator forms', 'formidable' ),
415 368 ),
416 - 'tooltip' => __( 'Automatically calculate the value of this field based on values from other fields.', 'formidable' ),
417 369 ),
418 370 'get_values_field' => array(
419 - 'class' => 'frm_show_upgrade frm_noallow',
420 - 'title' => __( 'Lookup', 'formidable' ),
421 - 'icon' => 'frmfont frm_search_icon',
422 - 'data' => array(
371 + 'class' => 'frm_show_upgrade frm_noallow',
372 + 'title' => __( 'Default Value (Lookup)', 'formidable' ),
373 + 'icon' => 'frm_icon_font frm_search_icon',
374 + 'data' => array(
423 375 'medium' => 'lookup',
424 376 'upgrade' => __( 'Lookup fields', 'formidable' ),
425 377 ),
426 - 'tooltip' => __( 'Dynamically retrieve the value of this field from a lookup field.', 'formidable' ),
427 378 ),
428 379 );
429 380
430 381 $types = apply_filters( 'frm_default_value_types', $types, $atts );
431 382
383 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
384 + // Prevent settings from showing in 2 spots.
385 + unset( $types['calc'], $types['get_values_field'] );
386 + }
387 +
432 388 // Set active class.
433 389 $settings = array_keys( $types );
434 390 $active = 'default_value';
435 391
436 - if ( FrmAppHelper::pro_is_connected() ) {
437 - foreach ( $settings as $type ) {
438 - if ( ! empty( $field[ $type ] ) ) {
439 - $active = $type;
440 - }
392 + foreach ( $settings as $type ) {
393 + if ( ! empty( $field[ $type ] ) ) {
394 + $active = $type;
441 395 }
442 396 }
443 397
444 398 $types[ $active ]['class'] .= ' current';
@@ -446,13 +400,8 @@
446 400
447 401 return $types;
448 402 }
449 403
450 - /**
451 - * @param string $type
452 - *
453 - * @return string
454 - */
455 404 public static function change_type( $type ) {
456 405 $type_switch = array(
457 406 'scale' => 'radio',
458 407 'star' => 'radio',
@@ -460,32 +409,30 @@
460 409 'rte' => 'textarea',
461 410 'website' => 'url',
462 411 'image' => 'url',
463 412 );
464 -
465 413 if ( isset( $type_switch[ $type ] ) ) {
466 414 $type = $type_switch[ $type ];
467 415 }
468 416
469 417 $pro_fields = FrmField::pro_field_selection();
470 - // We want to keep credit_card types as credit card types for Stripe Lite.
471 - // The credit_card key is set for backward compatibility.
472 - unset( $pro_fields['credit_card'] );
418 + $types = array_keys( $pro_fields );
419 + if ( in_array( $type, $types ) ) {
420 + $type = 'text';
421 + }
473 422
474 - return array_key_exists( $type, $pro_fields ) ? 'text' : $type;
423 + return $type;
475 424 }
476 425
477 426 /**
478 - * @param array $settings
479 - * @param FrmFieldType|null $field_info
427 + * @param array $settings
428 + * @param object $field_info
480 429 *
481 430 * @return array
482 431 */
483 432 public static function display_field_options( $settings, $field_info = null ) {
484 433 if ( $field_info ) {
485 - $settings = $field_info->display_field_settings();
486 -
487 - // Field appears to be protected but there is a __get function in FrmFieldType that makes this public.
434 + $settings = $field_info->display_field_settings();
488 435 $settings['field_data'] = $field_info->field;
489 436 }
490 437
491 438 return apply_filters( 'frm_display_field_options', $settings );
@@ -495,32 +442,14 @@
495 442 * Display the format option
496 443 *
497 444 * @since 3.0
498 445 *
499 - * @param array $field Field data.
500 - * @param bool $is_hidden Whether the format option should be hidden.
501 - *
502 - * @return void
446 + * @param array $field
503 447 */
504 - public static function show_format_option( $field, $is_hidden = false ) {
505 - $attributes = array(
506 - 'class' => 'frm-has-modal',
507 - 'id' => 'frm-field-format-custom-' . $field['id'],
508 - );
509 -
510 - if ( $is_hidden ) {
511 - $attributes['class'] .= ' frm_hidden';
512 - }
513 -
514 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
448 + public static function show_format_option( $field ) {
449 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' );
515 450 }
516 451
517 - /**
518 - * @param array $field
519 - * @param bool $echo
520 - *
521 - * @return string
522 - */
523 452 public static function input_html( $field, $echo = true ) {
524 453 $class = array();
525 454 self::add_input_classes( $field, $class );
526 455
@@ -540,26 +469,20 @@
540 469 $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
541 470 $add_html = ' ' . implode( ' ', $add_html ) . ' ';
542 471
543 472 if ( $echo ) {
544 - echo $add_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
473 + echo $add_html; // WPCS: XSS ok.
545 474 }
546 475
547 476 return $add_html;
548 477 }
549 478
550 - /**
551 - * @param array $field
552 - * @param array $class
553 - *
554 - * @return void
555 - */
556 479 private static function add_input_classes( $field, array &$class ) {
557 - if ( ! empty( $field['input_class'] ) ) {
480 + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
558 481 $class[] = $field['input_class'];
559 482 }
560 483
561 - if ( $field['type'] === 'hidden' || $field['type'] === 'user_id' ) {
484 + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
562 485 return;
563 486 }
564 487
565 488 if ( isset( $field['size'] ) && $field['size'] > 0 ) {
@@ -566,14 +489,8 @@
566 489 $class[] = 'auto_width';
567 490 }
568 491 }
569 492
570 - /**
571 - * @param array $field
572 - * @param array $add_html
573 - *
574 - * @return void
575 - */
576 493 private static function add_html_size( $field, array &$add_html ) {
577 494 $size_fields = array(
578 495 'select',
579 496 'data',
@@ -582,9 +499,9 @@
582 499 'file',
583 500 'lookup',
584 501 );
585 502
586 - if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields, true ) ) {
503 + if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], $size_fields ) ) {
587 504 return;
588 505 }
589 506
590 507 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -601,16 +518,10 @@
601 518
602 519 self::add_html_cols( $field, $add_html );
603 520 }
604 521
605 - /**
606 - * @param array $field
607 - * @param array $add_html
608 - *
609 - * @return void
610 - */
611 522 private static function add_html_cols( $field, array &$add_html ) {
612 - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
523 + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
613 524 return;
614 525 }
615 526
616 527 // Convert to cols for textareas.
@@ -620,9 +531,9 @@
620 531 'rem' => 0.444,
621 532 'em' => 0.544,
622 533 );
623 534
624 - // Include "col" for valid html
535 + // include "col" for valid html
625 536 $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
626 537
627 538 if ( ! isset( $calc[ $unit ] ) ) {
628 539 return;
@@ -627,18 +538,13 @@
627 538 if ( ! isset( $calc[ $unit ] ) ) {
628 539 return;
629 540 }
630 541
631 - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
542 + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
543 +
632 544 $add_html['cols'] = 'cols="' . absint( $size ) . '"';
633 545 }
634 546
635 - /**
636 - * @param array $field
637 - * @param array $add_html
638 - *
639 - * @return void
640 - */
641 547 private static function add_html_length( $field, array &$add_html ) {
642 548 // Check for max setting and if this field accepts maxlength.
643 549 $fields = array(
644 550 'textarea',
@@ -646,9 +552,9 @@
646 552 'hidden',
647 553 'file',
648 554 );
649 555
650 - if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields, true ) ) {
556 + if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], $fields ) ) {
651 557 return;
652 558 }
653 559
654 560 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -658,17 +564,9 @@
658 564
659 565 $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
660 566 }
661 567
662 - /**
663 - * @param array $field
664 - * @param array $add_html
665 - * @param array $class
666 - *
667 - * @return void
668 - */
669 568 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
670 - // phpcs:ignore Universal.Operators.StrictComparisons
671 569 if ( $field['default_value'] != '' ) {
672 570 if ( is_array( $field['default_value'] ) ) {
673 571 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( json_encode( $field['default_value'] ) ) . '"';
674 572 } else {
@@ -676,29 +574,38 @@
676 574 }
677 575 }
678 576
679 577 $field['placeholder'] = self::prepare_placeholder( $field );
680 -
681 - // phpcs:ignore Universal.Operators.StrictComparisons
682 578 if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) {
683 - // Don't include a json placeholder
579 + // don't include a json placeholder
684 580 return;
685 581 }
686 582
687 - self::add_placeholder_to_input( $field, $add_html );
583 + $frm_settings = FrmAppHelper::get_settings();
584 +
585 + if ( $frm_settings->use_html ) {
586 + self::add_placeholder_to_input( $field, $add_html );
587 + } else {
588 + self::add_frmval_to_input( $field, $add_html );
589 +
590 + $class[] = 'frm_toggle_default';
591 +
592 + if ( $field['value'] == $field['placeholder'] ) {
593 + $class[] = 'frm_default';
594 + }
595 + }
688 596 }
689 597
690 - /**
691 - * Prepares field placeholder.
692 - *
693 - * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
694 - *
695 - * @param array $field Field array.
696 - *
697 - * @return string
698 - */
699 598 private static function prepare_placeholder( $field ) {
700 - return $field['placeholder'] ?? '';
599 + $is_placeholder_field = FrmFieldsHelper::is_placeholder_field_type( $field['type'] );
600 + $is_combo_field = in_array( $field['type'], array( 'address', 'credit_card' ) );
601 +
602 + $placeholder = $field['placeholder'];
603 + if ( empty( $placeholder ) && $is_placeholder_field && ! $is_combo_field ) {
604 + $placeholder = self::get_default_value_from_name( $field );
605 + }
606 +
607 + return $placeholder;
701 608 }
702 609
703 610 /**
704 611 * If the label position is "inside",
@@ -704,9 +611,8 @@
704 611 * If the label position is "inside",
705 612 * get the label to use as the placeholder
706 613 *
707 614 * @since 2.05
708 - * @since 5.4 Remove the logic code for "inside" label position.
709 615 *
710 616 * @param array $field
711 617 *
712 618 * @return string
@@ -711,60 +617,23 @@
711 617 *
712 618 * @return string
713 619 */
714 620 public static function get_default_value_from_name( $field ) {
715 - return '';
716 - }
717 -
718 - /**
719 - * Maybe add a blank placeholder option before any options
720 - * in a dropdown.
721 - *
722 - * @since 4.04
723 - *
724 - * @param array|object $field
725 - *
726 - * @return bool True if placeholder was added.
727 - */
728 - public static function add_placeholder_to_select( $field ) {
729 - $placeholder = FrmField::get_option( $field, 'placeholder' );
730 -
731 - if ( ! $placeholder ) {
732 - $placeholder = self::get_default_value_from_name( $field );
621 + $position = FrmField::get_option( $field, 'label' );
622 + if ( $position == 'inside' ) {
623 + $default_value = $field['name'];
624 + } else {
625 + $default_value = '';
733 626 }
734 627
735 - $use_placeholder = $placeholder;
736 - $autocomplete = FrmField::get_option( $field, 'autocom' );
737 -
738 - if ( $autocomplete ) {
739 - $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
740 -
741 - if ( $use_chosen ) {
742 - $use_placeholder = '';
743 - }
744 - }
745 -
746 - if ( $placeholder !== '' ) {
747 - $placeholder_attributes = array(
748 - 'class' => 'frm-select-placeholder',
749 - 'value' => '',
750 - 'data-placeholder' => 'true',
751 - );
752 -
753 - FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
754 - return true;
755 - }
756 -
757 - return false;
628 + return $default_value;
758 629 }
759 630
760 631 /**
761 - * Use HTML5 placeholder with js fallback.
632 + * Use HMTL5 placeholder with js fallback
762 633 *
763 634 * @param array $field
764 635 * @param array $add_html
765 - *
766 - * @return void
767 636 */
768 637 private static function add_placeholder_to_input( $field, &$add_html ) {
769 638 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
770 639 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
@@ -770,16 +639,9 @@
770 639 $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['placeholder'] ) . '"';
771 640 }
772 641 }
773 642
774 - /**
775 - * @param array $field
776 - * @param array $add_html
777 - *
778 - * @return void
779 - */
780 643 private static function add_frmval_to_input( $field, &$add_html ) {
781 - // phpcs:ignore Universal.Operators.StrictComparisons
782 644 if ( $field['placeholder'] != '' ) {
783 645 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['placeholder'] ) . '"';
784 646
785 647 if ( 'select' === $field['type'] ) {
@@ -786,295 +648,205 @@
786 648 $add_html['data-frmplaceholder'] = 'data-frmplaceholder="' . esc_attr( $field['placeholder'] ) . '"';
787 649 }
788 650 }
789 651
790 - // phpcs:ignore Universal.Operators.StrictComparisons
791 652 if ( $field['default_value'] != '' ) {
792 653 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
793 654 }
794 655 }
795 656
796 - /**
797 - * @param array $field
798 - * @param array $add_html
799 - *
800 - * @return void
801 - */
802 657 private static function add_validation_messages( $field, array &$add_html ) {
803 - $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
804 -
805 - if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
658 + if ( FrmField::is_required( $field ) ) {
806 659 $required_message = FrmFieldsHelper::get_error_msg( $field, 'blank' );
807 660 $add_html['data-reqmsg'] = 'data-reqmsg="' . esc_attr( $required_message ) . '"';
808 661 self::maybe_add_html_required( $field, $add_html );
809 662 }
810 663
811 - if ( ! FrmField::is_option_empty( $field, 'invalid' ) && ! empty( $field_validation_messages_status['data-invmsg'] ) ) {
664 + if ( ! FrmField::is_option_empty( $field, 'invalid' ) ) {
812 665 $invalid_message = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
813 666 $add_html['data-invmsg'] = 'data-invmsg="' . esc_attr( $invalid_message ) . '"';
814 667 }
815 -
816 - if ( ! empty( $add_html['data-reqmsg'] ) || ! empty( $add_html['data-invmsg'] ) ) {
817 - self::maybe_add_error_html_for_js_validation( $field, $add_html );
818 - }
819 668 }
820 669
821 670 /**
822 - * Returns an array that contains field validation messages status.
671 + * If 'required' is added to a conditionall hidden field, the form won't
672 + * submit in many browsers. Check to make sure the javascript to conditionally
673 + * remove it is present if needed.
823 674 *
824 - * @since 6.9
825 - *
826 - * @param array|object $field
827 - *
828 - * @return array
675 + * @since 3.06.01
676 + * @param array $field
677 + * @param array $add_html
829 678 */
830 - private static function get_validation_data_attribute_visibility_info( $field ) {
831 - if ( FrmField::get_field_type( $field ) === 'hidden' ) {
832 - $field_validation_data_attributes = array(
833 - 'data-invmsg' => false,
834 - 'data-reqmsg' => false,
835 - );
836 - } else {
837 - $field_validation_data_attributes = array(
838 - 'data-invmsg' => true,
839 - 'data-reqmsg' => true,
840 - );
679 + private static function maybe_add_html_required( $field, array &$add_html ) {
680 + if ( in_array( $field['type'], array( 'radio', 'checkbox', 'file', 'data', 'lookup' ) ) ) {
681 + return;
841 682 }
842 683
843 - /**
844 - * Allows controlling which field validation messages would be included in the field html.
845 - *
846 - * @since 6.9
847 - *
848 - * @param array $field_validation_messages_status
849 - * @param array|object $field
850 - */
851 - return apply_filters( 'frm_field_validation_include_data_attributes', $field_validation_data_attributes, $field );
684 + $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
685 + if ( $include_html ) {
686 + $add_html['aria-required'] = 'aria-required="true"';
687 + }
852 688 }
853 689
854 - /**
855 - * @since 5.0.03
856 - *
857 - * @param array $field
858 - * @param array $add_html
859 - *
860 - * @return void
861 - */
862 - private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
863 - $form = self::get_form_for_js_validation( $field );
864 -
865 - if ( false === $form ) {
690 + private static function add_shortcodes_to_html( $field, array &$add_html ) {
691 + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
866 692 return;
867 693 }
868 694
869 - $error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
695 + foreach ( $field['shortcodes'] as $k => $v ) {
696 + if ( 'opt' === $k ) {
697 + continue;
698 + }
870 699
871 - if ( false === $error_body ) {
872 - return;
700 + if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
701 + $add_html[] = $v;
702 + } elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
703 + $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
704 + } else {
705 + $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
706 + }
707 +
708 + unset( $k, $v );
873 709 }
874 -
875 - $error_body = urlencode( $error_body );
876 - $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
877 710 }
878 711
879 712 /**
880 - * @since 5.0.03
713 + * Add pattern attribute
881 714 *
715 + * @since 3.0
716 + *
882 717 * @param array $field
883 - *
884 - * @return false|stdClass false if there is no form object found with JS validation active.
718 + * @param array $add_html
885 719 */
886 - private static function get_form_for_js_validation( $field ) {
887 - global $frm_vars;
720 + private static function add_pattern_attribute( $field, array &$add_html ) {
721 + $has_format = FrmField::is_option_true_in_array( $field, 'format' );
722 + $format_field = FrmField::is_field_type( $field, 'text' );
888 723
889 - if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
890 - if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
891 - return $frm_vars['js_validate_forms'][ $field['form_id'] ];
724 + if ( $field['type'] == 'phone' || ( $has_format && $format_field ) ) {
725 + $frm_settings = FrmAppHelper::get_settings();
726 +
727 + if ( $frm_settings->use_html ) {
728 + $format = FrmEntryValidate::phone_format( $field );
729 + $format = substr( $format, 2, - 1 );
730 +
731 + $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
892 732 }
733 + }
734 + }
893 735
894 - if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
895 - return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
736 + public static function check_value( $opt, $opt_key, $field ) {
737 + if ( is_array( $opt ) ) {
738 + if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
739 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
740 + } else {
741 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
896 742 }
897 743 }
898 744
899 - return false;
745 + return $opt;
900 746 }
901 747
748 + public static function check_label( $opt ) {
749 + if ( is_array( $opt ) ) {
750 + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
751 + }
752 +
753 + return $opt;
754 + }
755 +
902 756 /**
903 - * @param stdClass $form
904 - * @param array $field
905 - * @param array $errors
906 - *
907 - * @return false|string
757 + * @deprecated 4.0
908 758 */
909 - public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
910 - if ( empty( $field['custom_html'] ) ) {
911 - return false;
759 + public static function update_ajax_option() {
760 + _deprecated_function( __METHOD__, '4.0' );
761 + FrmAppHelper::permission_check( 'frm_edit_forms' );
762 + check_ajax_referer( 'frm_ajax', 'nonce' );
763 +
764 + $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
765 + if ( ! $field_id ) {
766 + wp_die();
912 767 }
913 768
914 - $custom_html = $field['custom_html'];
915 - $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form );
916 - $start = strpos( $custom_html, '[if error]' );
769 + $field = FrmField::getOne( $field_id );
917 770
918 - if ( false === $start ) {
919 - return false;
920 - }
771 + if ( isset( $_POST['separate_value'] ) ) {
772 + $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
921 773
922 - $end = strpos( $custom_html, '[/if error]' );
923 -
924 - if ( false === $end || $end < $start ) {
925 - return false;
774 + $field->field_options['separate_value'] = $new_val;
775 + unset( $new_val );
926 776 }
927 777
928 - $error_body = substr( $custom_html, $start + 10, $end - $start - 10 );
929 - $default_html = array(
930 - '<div class="frm_error" id="frm_error_field_[key]">[error]</div>',
931 - '<div class="frm_error" role="alert" id="frm_error_field_[key]">[error]</div>',
932 - '<div class="frm_error">[error]</div>',
933 - '<div class="frm_error" role="alert">[error]</div>',
778 + FrmField::update(
779 + $field_id,
780 + array(
781 + 'field_options' => $field->field_options,
782 + 'form_id' => $field->form_id,
783 + )
934 784 );
785 + wp_die();
786 + }
935 787
936 - return in_array( $error_body, $default_html, true ) ? false : $error_body;
788 + /**
789 + * @deprecated 4.0
790 + */
791 + public static function import_choices() {
792 + _deprecated_function( __METHOD__, '4.0' );
793 + wp_die();
937 794 }
938 795
939 796 /**
940 - * If 'required' is added to a conditionally hidden field, the form won't
941 - * submit in many browsers. Check to make sure the javascript to conditionally
942 - * remove it is present if needed.
797 + * Add Single Option or Other Option.
943 798 *
944 - * @since 3.06.01
945 - *
946 - * @param array $field
947 - * @param array $add_html
948 - *
949 - * @return void
799 + * @deprecated 4.0 Moved to Pro for Other option only.
950 800 */
951 - private static function maybe_add_html_required( $field, array &$add_html ) {
952 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
953 - $excluded_field_types =
954 - FrmField::is_radio( $field ) ||
955 - FrmField::is_checkbox( $field ) ||
956 - FrmField::is_field_type( $field, 'file' ) ||
957 - FrmField::is_field_type( $field, 'nps' ) ||
958 - FrmField::is_field_type( $field, 'scale' );
959 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
960 -
961 - if ( $excluded_field_types ) {
962 - return;
801 + public static function add_option() {
802 + _deprecated_function( __METHOD__, '4.0', 'FrmProFormsController::add_other_option' );
803 + if ( is_callable( 'FrmProFormsController::add_other_option' ) ) {
804 + FrmProFormsController::add_other_option();
963 805 }
964 -
965 - $add_html['aria-required'] = 'aria-required="true"';
966 806 }
967 807
968 808 /**
969 - * @param array $field
970 - * @param array $add_html
971 - *
972 - * @return void
809 + * @deprecated 4.0
973 810 */
974 - private static function add_shortcodes_to_html( $field, array &$add_html ) {
975 - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
976 - return;
977 - }
978 -
979 - if ( ! empty( $field['autocomplete'] ) ) {
980 - unset( $field['shortcodes']['autocomplete'] );
981 - }
982 -
983 - foreach ( $field['shortcodes'] as $k => $v ) {
984 - if ( isset( $field['subfield_name'] ) && str_starts_with( $k, 'aria-invalid' ) ) {
985 - $subfield_name = $field['subfield_name'];
986 -
987 - if ( ! isset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] ) ) {
988 - continue;
989 - }
990 - // Change the key to the correct aria-invalid value so that $add_html is set correctly for the current subfield of a combo field.
991 - $k = 'aria-invalid';
992 - $v = $field['shortcodes'][ 'aria-invalid-' . $subfield_name ];
993 - unset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] );
994 - }
995 -
996 - if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
997 - continue;
998 - }
999 -
1000 - if ( is_numeric( $k ) && str_contains( $v, '=' ) ) {
1001 - $add_html[] = $v;
1002 - } elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
1003 - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
1004 - } else {
1005 - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
1006 - }
1007 -
1008 - unset( $k, $v );
1009 - }//end foreach
811 + public static function update_order() {
812 + FrmDeprecated::update_order();
1010 813 }
1011 814
1012 815 /**
1013 - * Disallow possibly unsafe attributees (that trigger JavaScript) when unasfe HTML is not allowed.
1014 - *
1015 - * @since 6.11.2
1016 - *
1017 - * @param string $key The option key.
1018 - *
1019 - * @return bool
816 + * @deprecated 3.0
817 + * @codeCoverageIgnore
1020 818 */
1021 - private static function should_allow_input_attribute( $key ) {
1022 - if ( ! FrmAppHelper::should_never_allow_unfiltered_html() ) {
1023 - return true;
1024 - }
1025 - return FrmAppHelper::input_key_is_safe( $key );
819 + public static function edit_name( $field = 'name', $id = '' ) {
820 + FrmDeprecated::edit_name( $field, $id );
1026 821 }
1027 822
1028 823 /**
1029 - * Add pattern attribute.
824 + * @deprecated 3.0
825 + * @codeCoverageIgnore
1030 826 *
1031 - * @since 3.0
827 + * @param int $field_id
828 + * @param array $values
829 + * @param int $form_id
1032 830 *
1033 - * @param array $field
1034 - * @param array $add_html
1035 - *
1036 - * @return void
831 + * @return array
1037 832 */
1038 - private static function add_pattern_attribute( $field, array &$add_html ) {
1039 - $format_value = FrmField::get_option( $field, 'format' );
1040 - $has_format = $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value );
1041 - $format_field = FrmField::is_field_type( $field, 'text' );
1042 -
1043 - if ( $field['type'] !== 'phone' && ( ! $has_format || ! $format_field ) ) {
1044 - return;
1045 - }
1046 -
1047 - $format = FrmEntryValidate::phone_format( $field );
1048 - $format = substr( $format, 2, - 1 );
1049 -
1050 - $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
833 + public static function include_single_field( $field_id, $values, $form_id = 0 ) {
834 + return FrmDeprecated::include_single_field( $field_id, $values, $form_id );
1051 835 }
1052 836
1053 837 /**
1054 - * @param mixed $opt
1055 - * @param mixed $opt_key
1056 - * @param array|object $field
1057 - *
1058 - * @return mixed
838 + * @deprecated 2.3
839 + * @codeCoverageIgnore
1059 840 */
1060 - public static function check_value( $opt, $opt_key, $field ) {
1061 - if ( is_array( $opt ) ) {
1062 - if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
1063 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
1064 - } else {
1065 - $opt = $opt['label'] ?? reset( $opt );
1066 - }
1067 - }
1068 -
1069 - return $opt;
841 + public static function edit_option() {
842 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
1070 843 }
1071 844
1072 845 /**
1073 - * @param mixed $opt
1074 - *
1075 - * @return mixed
846 + * @deprecated 2.3
847 + * @codeCoverageIgnore
1076 848 */
1077 - public static function check_label( $opt ) {
1078 - return is_array( $opt ) ? ( $opt['label'] ?? reset( $opt ) ) : $opt;
849 + public static function delete_option() {
850 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
1079 851 }
1080 852 }