PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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/helpers/FrmHtmlHelper.php +2 -76 6.276.19 View file →
@@ -21,9 +21,9 @@
21 21 *
22 22 * @type bool|null $echo True if you want the toggle to echo. False if you want it to return an HTML string.
23 23 * }
24 24 *
25 - * @return string|null
25 + * @return string|void
26 26 */
27 27 public static function toggle( $id, $name, $args ) {
28 28 wp_enqueue_script( 'formidable_settings' );
29 29 return FrmAppHelper::clip(
@@ -30,9 +30,9 @@
30 30 // @phpstan-ignore-next-line
31 31 function () use ( $id, $name, $args ) {
32 32 require FrmAppHelper::plugin_path() . '/classes/views/shared/toggle.php';
33 33 },
34 - $args['echo'] ?? false
34 + isset( $args['echo'] ) ? $args['echo'] : false
35 35 );
36 36 }
37 37
38 38 /**
@@ -44,9 +44,8 @@
44 44 *
45 45 * @param string $option The string used as the option label.
46 46 * @param bool $selected True if the option should be selected.
47 47 * @param array $params Other HTML params for the option.
48 - *
49 48 * @return void
50 49 */
51 50 public static function echo_dropdown_option( $option, $selected, $params = array() ) {
52 51 echo '<option ';
@@ -54,79 +53,6 @@
54 53 selected( $selected );
55 54 echo '>';
56 55 echo esc_html( $option === '' ? ' ' : $option );
57 56 echo '</option>';
58 - }
59 -
60 - /**
61 - * Renders a number input with unit selector.
62 - *
63 - * @since 6.24
64 - *
65 - * @param array $args {
66 - * Optional. Arguments to customize the unit input.
67 - *
68 - * @type array $field_attrs Attributes for the hidden input storing the field value.
69 - * @type array $input_number_attrs Attributes for the visible number input.
70 - * @type array $units Available units for selection. Default is ['px', '%', 'em'].
71 - * @type string $value Initial value with optional unit (e.g. '10px', '50%').
72 - * }
73 - *
74 - * @return void
75 - */
76 - public static function echo_unit_input( $args = array() ) {
77 - $args = wp_parse_args(
78 - $args,
79 - array(
80 - 'field_attrs' => array(),
81 - 'input_number_attrs' => array(),
82 - 'units' => array( '', 'px', '%', 'em' ),
83 - 'default_unit' => 'px',
84 - 'value' => '',
85 - )
86 - );
87 -
88 - $units = $args['units'];
89 - $value = $args['value'];
90 -
91 - // Extract unit and number value if value is a string
92 - if ( '' !== $value && ! is_numeric( $value ) ) {
93 - $pattern = '/^([0-9.]*)(' . implode( '|', array_map( 'preg_quote', $units ) ) . ')?$/';
94 - preg_match( $pattern, $value, $matches );
95 - $selected_unit = $matches[2] ?? '';
96 -
97 - if ( ! empty( $matches[1] ) ) {
98 - $value = $matches[1];
99 - }
100 - }
101 -
102 - $input_number_attrs = array_merge(
103 - $args['input_number_attrs'],
104 - array(
105 - 'type' => ! empty( $selected_unit ) ? 'number' : 'text',
106 - 'value' => $value,
107 - 'class' => trim( 'frm-unit-input-control ' . ( $args['input_number_attrs']['class'] ?? '' ) ),
108 - )
109 - );
110 -
111 - $hidden_value = $args['value'];
112 -
113 - if ( is_numeric( $hidden_value ) ) {
114 - $hidden_value .= $args['default_unit'];
115 - }
116 - ?>
117 - <span class="frm-unit-input">
118 - <input type="hidden" value="<?php echo esc_attr( $hidden_value ); ?>" <?php FrmAppHelper::array_to_html_params( $args['field_attrs'], true ); ?> />
119 - <input <?php FrmAppHelper::array_to_html_params( $input_number_attrs, true ); ?> />
120 - <span class="frm-input-group-suffix">
121 - <select aria-label="<?php echo esc_attr__( 'Select unit', 'formidable' ); ?>" tabindex="0">
122 - <?php
123 - foreach ( $units as $unit ) {
124 - self::echo_dropdown_option( $unit, $unit === ( $selected_unit ?? $args['default_unit'] ), array( 'value' => $unit ) );
125 - }
126 - ?>
127 - </select>
128 - </span>
129 - </span>
130 - <?php
131 57 }
132 58 }