From 1bd9a7e93925fbd26c31eb3f17312b914409ccf1 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Mon, 15 Feb 2021 13:49:28 -0800 Subject: [PATCH] Only add '(optional)' to the billing_address_2 placeholder | #25510 --- includes/class-wc-countries.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php index 3710c39e6ea..beb7dab4604 100644 --- a/includes/class-wc-countries.php +++ b/includes/class-wc-countries.php @@ -658,10 +658,14 @@ class WC_Countries { * @return array */ public function get_default_address_fields() { + $address_2_label = __( 'Apartment, suite, unit, etc.', 'woocommerce' ); + + // If necessary, append '(optional)' to the placeholder: we don't need to worry about the + // label, though, as woocommerce_form_field() takes care of that. if ( 'optional' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ) ) { $address_2_placeholder = __( 'Apartment, suite, unit, etc. (optional)', 'woocommerce' ); } else { - $address_2_placeholder = __( 'Apartment, suite, unit, etc.', 'woocommerce' ); + $address_2_placeholder = $address_2_label; } $fields = array( @@ -704,6 +708,8 @@ class WC_Countries { 'priority' => 50, ), 'address_2' => array( + 'label' => esc_attr( $address_2_label ), + 'label_class' => array( 'screen-reader-text' ), 'placeholder' => esc_attr( $address_2_placeholder ), 'class' => array( 'form-row-wide', 'address-field' ), 'autocomplete' => 'address-line2',