PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 -100 6.336.16 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,35 +30,13 @@
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 /**
39 - * Show readonly setting icon
40 - *
41 - * @since 6.33
42 - *
43 - * @param bool $is_enabled Whether the setting is enabled.
44 - *
45 - * @return void
46 - */
47 - public static function show_readonly_setting_icon( $is_enabled ) {
48 - if ( $is_enabled ) {
49 - echo '<span class="frm-success-icon">';
50 - FrmAppHelper::icon_by_class( 'frmfont frm_checkmark_icon', array( 'aria-hidden' => 'true' ) );
51 - echo '</span>';
52 - return;
53 - }
54 -
55 - echo '<span class="frm-x-icon">';
56 - FrmAppHelper::icon_by_class( 'frmfont frm_x_icon', array( 'aria-hidden' => 'true' ) );
57 - echo '</span>';
58 - }
59 -
60 - /**
61 39 * Echo a dropdown option.
62 40 * This is useful to avoid closing and opening PHP to echo <option> tags which leads to extra whitespace.
63 41 * Avoiding whitespace saves 5KB of HTML for an international address field with a country dropdown with 252 options.
64 42 *
@@ -66,9 +44,8 @@
66 44 *
67 45 * @param string $option The string used as the option label.
68 46 * @param bool $selected True if the option should be selected.
69 47 * @param array $params Other HTML params for the option.
70 - *
71 48 * @return void
72 49 */
73 50 public static function echo_dropdown_option( $option, $selected, $params = array() ) {
74 51 echo '<option ';
@@ -76,81 +53,6 @@
76 53 selected( $selected );
77 54 echo '>';
78 55 echo esc_html( $option === '' ? ' ' : $option );
79 56 echo '</option>';
80 - }
81 -
82 - /**
83 - * Renders a number input with unit selector.
84 - *
85 - * @since 6.24
86 - *
87 - * @param array $args {
88 - * Optional. Arguments to customize the unit input.
89 - *
90 - * @type array $field_attrs Attributes for the hidden input storing the field value.
91 - * @type array $input_number_attrs Attributes for the visible number input.
92 - * @type array $units Available units for selection. Default is ['px', '%', 'em'].
93 - * @type string $value Initial value with optional unit (e.g. '10px', '50%').
94 - * }
95 - *
96 - * @return void
97 - */
98 - public static function echo_unit_input( $args = array() ) {
99 - $args = wp_parse_args(
100 - $args,
101 - array(
102 - 'field_attrs' => array(),
103 - 'input_number_attrs' => array(),
104 - 'units' => array( '', 'px', '%', 'em' ),
105 - 'default_unit' => 'px',
106 - 'value' => '',
107 - )
108 - );
109 -
110 - $units = $args['units'];
111 - $value = $args['value'];
112 -
113 - // Extract unit and number value if value is a string
114 - if ( '' !== $value && ! is_numeric( $value ) ) {
115 - $pattern = '/^([0-9.]*)(' . implode( '|', array_map( 'preg_quote', $units ) ) . ')?$/';
116 - preg_match( $pattern, $value, $matches );
117 - $selected_unit = $matches[2] ?? '';
118 -
119 - if ( ! empty( $matches[1] ) ) {
120 - $value = $matches[1];
121 - }
122 - }
123 -
124 - $input_number_attrs = array_merge(
125 - $args['input_number_attrs'],
126 - array(
127 - 'type' => ! empty( $selected_unit ) ? 'number' : 'text',
128 - 'value' => $value,
129 - 'class' => trim( 'frm-unit-input-control ' . ( $args['input_number_attrs']['class'] ?? '' ) ),
130 - )
131 - );
132 -
133 - $hidden_value = $args['value'];
134 -
135 - if ( is_numeric( $hidden_value ) ) {
136 - $hidden_value .= $args['default_unit'];
137 - }
138 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
139 - ?>
140 - <span class="frm-unit-input">
141 - <input type="hidden" value="<?php echo esc_attr( $hidden_value ); ?>" <?php FrmAppHelper::array_to_html_params( $args['field_attrs'], true ); ?> />
142 - <input <?php FrmAppHelper::array_to_html_params( $input_number_attrs, true ); ?> />
143 - <span class="frm-input-group-suffix">
144 - <select aria-label="<?php esc_attr_e( 'Select unit', 'formidable' ); ?>" tabindex="0">
145 - <?php
146 - foreach ( $units as $unit ) {
147 - self::echo_dropdown_option( $unit, $unit === ( $selected_unit ?? $args['default_unit'] ), array( 'value' => $unit ) );
148 - }
149 - ?>
150 - </select>
151 - </span>
152 - </span>
153 - <?php
154 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
155 57 }
156 58 }