PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +30 -3 6.25.1 → trunk 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|void
25 + * @return string|null
26 26 */
27 27 public static function toggle( $id, $name, $args ) {
28 28 wp_enqueue_script( 'formidable_settings' );
29 29 return FrmAppHelper::clip(
@@ -35,8 +35,30 @@
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 + /**
39 61 * Echo a dropdown option.
40 62 * This is useful to avoid closing and opening PHP to echo <option> tags which leads to extra whitespace.
41 63 * Avoiding whitespace saves 5KB of HTML for an international address field with a country dropdown with 252 options.
42 64 *
@@ -44,8 +66,9 @@
44 66 *
45 67 * @param string $option The string used as the option label.
46 68 * @param bool $selected True if the option should be selected.
47 69 * @param array $params Other HTML params for the option.
70 + *
48 71 * @return void
49 72 */
50 73 public static function echo_dropdown_option( $option, $selected, $params = array() ) {
51 74 echo '<option ';
@@ -91,14 +114,15 @@
91 114 if ( '' !== $value && ! is_numeric( $value ) ) {
92 115 $pattern = '/^([0-9.]*)(' . implode( '|', array_map( 'preg_quote', $units ) ) . ')?$/';
93 116 preg_match( $pattern, $value, $matches );
94 117 $selected_unit = $matches[2] ?? '';
118 +
95 119 if ( ! empty( $matches[1] ) ) {
96 120 $value = $matches[1];
97 121 }
98 122 }
99 123
100 - $input_number_attrs = array_merge(
124 + $input_number_attrs = array_merge(
101 125 $args['input_number_attrs'],
102 126 array(
103 127 'type' => ! empty( $selected_unit ) ? 'number' : 'text',
104 128 'value' => $value,
@@ -106,17 +130,19 @@
106 130 )
107 131 );
108 132
109 133 $hidden_value = $args['value'];
134 +
110 135 if ( is_numeric( $hidden_value ) ) {
111 136 $hidden_value .= $args['default_unit'];
112 137 }
138 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
113 139 ?>
114 140 <span class="frm-unit-input">
115 141 <input type="hidden" value="<?php echo esc_attr( $hidden_value ); ?>" <?php FrmAppHelper::array_to_html_params( $args['field_attrs'], true ); ?> />
116 142 <input <?php FrmAppHelper::array_to_html_params( $input_number_attrs, true ); ?> />
117 143 <span class="frm-input-group-suffix">
118 - <select aria-label="<?php echo esc_attr__( 'Select unit', 'formidable' ); ?>" tabindex="0">
144 + <select aria-label="<?php esc_attr_e( 'Select unit', 'formidable' ); ?>" tabindex="0">
119 145 <?php
120 146 foreach ( $units as $unit ) {
121 147 self::echo_dropdown_option( $unit, $unit === ( $selected_unit ?? $args['default_unit'] ), array( 'value' => $unit ) );
122 148 }
@@ -124,6 +150,7 @@
124 150 </select>
125 151 </span>
126 152 </span>
127 153 <?php
154 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
128 155 }
129 156 }