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/models/fields/FrmFieldName.php +19 -24 6.26 → trunk View file →
@@ -60,14 +60,12 @@
60 60 *
61 61 * @return array
62 62 */
63 63 protected function get_processed_sub_fields() {
64 - $name_layout = $this->get_name_layout();
65 - $names = explode( '_', $name_layout );
66 - $col_class = 'frm' . intval( 12 / count( $names ) );
64 + $names = explode( '_', $this->get_name_layout() );
65 + $col_class = 'frm' . intval( 12 / count( $names ) );
66 + $result = array();
67 67
68 - $result = array();
69 -
70 68 foreach ( $names as $name ) {
71 69 if ( empty( $this->sub_fields[ $name ] ) ) {
72 70 continue;
73 71 }
@@ -92,13 +90,9 @@
92 90 * @return string
93 91 */
94 92 protected function get_name_layout() {
95 93 $name_layout = FrmField::get_option( $this->field, 'name_layout' );
96 -
97 - if ( ! $name_layout ) {
98 - $name_layout = 'first_last';
99 - }
100 - return $name_layout;
94 + return $name_layout ? $name_layout : 'first_last';
101 95 }
102 96
103 97 /**
104 98 * Gets extra field options.
@@ -147,10 +141,8 @@
147 141 if ( ! is_array( $value ) ) {
148 142 return $value;
149 143 }
150 144
151 - $name_layout = $this->get_name_layout();
152 -
153 145 if ( ! empty( $atts['show'] ) ) {
154 146 return $value[ $atts['show'] ] ?? '';
155 147 }
156 148
@@ -162,9 +154,9 @@
162 154 'last' => '',
163 155 )
164 156 );
165 157
166 - switch ( $name_layout ) {
158 + switch ( $this->get_name_layout() ) {
167 159 case 'last_first':
168 160 $value = $value['last'] . ' ' . $value['first'];
169 161 break;
170 162
@@ -225,15 +217,17 @@
225 217 protected function process_args_for_field_output( &$args ) {
226 218 parent::process_args_for_field_output( $args );
227 219
228 220 // Show all subfields in form builder then use JS to show or hide them.
229 - if ( $this->should_print_hidden_sub_fields() && count( $args['sub_fields'] ) !== count( $this->sub_fields ) ) {
230 - $hidden_fields = array_diff_key( $this->sub_fields, $args['sub_fields'] );
231 - $args['sub_fields'] = $this->sub_fields;
221 + if ( ! $this->should_print_hidden_sub_fields() || count( $args['sub_fields'] ) === count( $this->sub_fields ) ) {
222 + return;
223 + }
232 224
233 - foreach ( $hidden_fields as $name => $hidden_field ) {
234 - $args['sub_fields'][ $name ]['wrapper_classes'] .= ' frm_hidden';
235 - }
225 + $hidden_fields = array_diff_key( $this->sub_fields, $args['sub_fields'] );
226 + $args['sub_fields'] = $this->sub_fields;
227 +
228 + foreach ( $hidden_fields as $name => $hidden_field ) {
229 + $args['sub_fields'][ $name ]['wrapper_classes'] .= ' frm_hidden';
236 230 }
237 231 }
238 232
239 233 /**
@@ -250,9 +244,9 @@
250 244 * Gets inputs container attributes.
251 245 *
252 246 * @return array
253 247 */
254 - protected function get_inputs_container_attrs() {
248 + public function get_inputs_container_attrs() {
255 249 $attrs = parent::get_inputs_container_attrs();
256 250
257 251 $attrs['data-name-layout'] = $this->get_name_layout();
258 252 return $attrs;
@@ -280,9 +274,9 @@
280 274 $field = $args['field'];
281 275
282 276 $show_warning = false;
283 277
284 - foreach ( $this->sub_fields as $name => $sub_field ) {
278 + foreach ( $this->sub_fields as $sub_field ) {
285 279 $description = FrmField::get_option( $field, $sub_field['name'] . '_desc' );
286 280
287 281 if ( in_array( $description, array( 'First', 'Last' ), true ) ) {
288 282 $show_warning = true;
@@ -292,17 +286,19 @@
292 286
293 287 if ( ! $show_warning ) {
294 288 return;
295 289 }
290 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
296 291 ?>
297 292 <div class="frm_warning_style">
298 293 <?php
299 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon', array( 'style' => 'width:24px' ) );
294 + FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) );
300 295 echo ' ';
301 296 esc_html_e( 'Subfield descriptions are read by screen readers. Enhance accessibility by using complete labels, like "First Name" instead of "First".', 'formidable' );
302 297 ?>
303 298 </div>
304 299 <?php
300 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
305 301 }
306 302
307 303 /**
308 304 * Tracks the first name field ID in a form.
@@ -332,10 +328,9 @@
332 328 *
333 329 * @return array
334 330 */
335 331 protected function get_sub_field_input_attrs( $sub_field, $args ) {
336 - $attrs = parent::get_sub_field_input_attrs( $sub_field, $args );
337 -
332 + $attrs = parent::get_sub_field_input_attrs( $sub_field, $args );
338 333 $form_id = (int) ( is_array( $args['field'] ) ? $args['field']['form_id'] : $args['field']->form_id );
339 334
340 335 if ( ! self::$first_name_field_ids || empty( self::$first_name_field_ids[ $form_id ] ) ) {
341 336 return $attrs;