From d52fa9312c25b8726ade5396d6cc5115e6243d32 Mon Sep 17 00:00:00 2001
From: David Baumwald <davidbaumwald@git.wordpress.org>
Date: Wed, 19 May 2021 18:38:53 +0000
Subject: [PATCH] Twenty Twenty: Correct `label` attribute references to
 `aria_label` in `get_search_form`.

In the bundled Twenty Twenty theme, a `label` argument was passed to `get_search_form` but used as the `aria_label` on the form.  This change updates the argument name to `aria_label` and maintains backwards compatibility for usage of the original `label` argument.

Props poena, sabernhardt, ipulc2, kishanjasani, mukesh27.
Fixes #51877.

git-svn-id: https://develop.svn.wordpress.org/trunk@50933 602fd350-edb4-49c9-b593-d223f7449a82
---
 src/wp-content/themes/twentytwenty/404.php                  | 2 +-
 src/wp-content/themes/twentytwenty/index.php                | 2 +-
 src/wp-content/themes/twentytwenty/searchform.php           | 6 +++++-
 .../themes/twentytwenty/template-parts/modal-search.php     | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/wp-content/themes/twentytwenty/404.php b/src/wp-content/themes/twentytwenty/404.php
index 64c25039a9..7e7e0cdc6f 100644
--- a/src/wp-content/themes/twentytwenty/404.php
+++ b/src/wp-content/themes/twentytwenty/404.php
@@ -21,7 +21,7 @@ get_header();
 		<?php
 		get_search_form(
 			array(
-				'label' => __( '404 not found', 'twentytwenty' ),
+				'aria_label' => __( '404 not found', 'twentytwenty' ),
 			)
 		);
 		?>
diff --git a/src/wp-content/themes/twentytwenty/index.php b/src/wp-content/themes/twentytwenty/index.php
index b3037b660d..fb0a5d809a 100644
--- a/src/wp-content/themes/twentytwenty/index.php
+++ b/src/wp-content/themes/twentytwenty/index.php
@@ -98,7 +98,7 @@ get_header();
 			<?php
 			get_search_form(
 				array(
-					'label' => __( 'search again', 'twentytwenty' ),
+					'aria_label' => __( 'search again', 'twentytwenty' ),
 				)
 			);
 			?>
diff --git a/src/wp-content/themes/twentytwenty/searchform.php b/src/wp-content/themes/twentytwenty/searchform.php
index 2acf8308b8..428a513b5c 100644
--- a/src/wp-content/themes/twentytwenty/searchform.php
+++ b/src/wp-content/themes/twentytwenty/searchform.php
@@ -17,7 +17,11 @@
  */
 $twentytwenty_unique_id = twentytwenty_unique_id( 'search-form-' );
 
-$twentytwenty_aria_label = ! empty( $args['label'] ) ? 'aria-label="' . esc_attr( $args['label'] ) . '"' : '';
+$twentytwenty_aria_label = ! empty( $args['aria_label'] ) ? 'aria-label="' . esc_attr( $args['aria_label'] ) . '"' : '';
+// Backward compatibility, in case a child theme template uses a `label` argument.
+if ( empty( $twentytwenty_aria_label ) && ! empty( $args['label'] ) ) {
+	$twentytwenty_aria_label = 'aria-label="' . esc_attr( $args['label'] ) . '"';
+}
 ?>
 <form role="search" <?php echo $twentytwenty_aria_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. ?> method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
 	<label for="<?php echo esc_attr( $twentytwenty_unique_id ); ?>">
diff --git a/src/wp-content/themes/twentytwenty/template-parts/modal-search.php b/src/wp-content/themes/twentytwenty/template-parts/modal-search.php
index 56e0b57366..32f9b51a0c 100644
--- a/src/wp-content/themes/twentytwenty/template-parts/modal-search.php
+++ b/src/wp-content/themes/twentytwenty/template-parts/modal-search.php
@@ -17,7 +17,7 @@
 			<?php
 			get_search_form(
 				array(
-					'label' => __( 'Search for:', 'twentytwenty' ),
+					'aria_label' => __( 'Search for:', 'twentytwenty' ),
 				)
 			);
 			?>