Moved accessibility labels for checkout after woocommerce_checkout_fields filter

This commit is contained in:
Ralf 2019-04-14 14:57:19 +12:00 committed by Gerhard
parent 14ed29b6f3
commit 66540f1b5d
2 changed files with 8 additions and 2 deletions

View File

@ -267,6 +267,14 @@ class WC_Checkout {
foreach ( $this->fields as $field_type => $fields ) {
// Sort each of the checkout field sections based on priority.
uasort( $this->fields[ $field_type ], 'wc_checkout_fields_uasort_comparison' );
//add accessibility labels to fields that have placeholders
foreach ( $fields as $single_field_type => $field) {
if ( empty( $field[ 'label' ] ) && !empty( $field[ 'placeholder' ] )) {
$this->fields[ $field_type ][ $single_field_type ][ 'label' ] = $field[ 'placeholder' ];
$this->fields[ $field_type ][ $single_field_type ][ 'label_class' ] = 'screen-reader-text';
}
}
}
return $fieldset ? $this->fields[ $fieldset ] : $this->fields;

View File

@ -664,8 +664,6 @@ class WC_Countries {
'priority' => 50,
),
'address_2' => array(
'label' => __( 'Apartment, suite, unit etc.', 'woocommerce' ),
'label_class' => array( 'screen-reader-text' ),
'placeholder' => esc_attr( $address_2_placeholder ),
'class' => array( 'form-row-wide', 'address-field' ),
'autocomplete' => 'address-line2',