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.
Built from https://develop.svn.wordpress.org/trunk@50933


git-svn-id: http://core.svn.wordpress.org/trunk@50542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2021-05-19 18:39:56 +00:00
parent 96beaa51d3
commit 77cf4ea88d
5 changed files with 9 additions and 5 deletions

View File

@ -21,7 +21,7 @@ get_header();
<?php
get_search_form(
array(
'label' => __( '404 not found', 'twentytwenty' ),
'aria_label' => __( '404 not found', 'twentytwenty' ),
)
);
?>

View File

@ -98,7 +98,7 @@ get_header();
<?php
get_search_form(
array(
'label' => __( 'search again', 'twentytwenty' ),
'aria_label' => __( 'search again', 'twentytwenty' ),
)
);
?>

View File

@ -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 ); ?>">

View File

@ -17,7 +17,7 @@
<?php
get_search_form(
array(
'label' => __( 'Search for:', 'twentytwenty' ),
'aria_label' => __( 'Search for:', 'twentytwenty' ),
)
);
?>

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-50932';
$wp_version = '5.8-alpha-50933';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.