Media: Remove unnecessary aria-required attribute from legacy (pre-3.5.0) media functions, added in [7888].

At the time, having both `required` and `aria-required` meant a wider range of support for browsers and assistive technology. Today, it's safe to use just `required`.

Props shital-patel, afercia, audrasjb.
Fixes #43415.
Built from https://develop.svn.wordpress.org/trunk@42759


git-svn-id: http://core.svn.wordpress.org/trunk@42589 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-02-26 23:10:31 +00:00
parent d3b2daf490
commit 669f8bb750
2 changed files with 8 additions and 10 deletions

View File

@ -1656,7 +1656,6 @@ function get_media_item( $attachment_id, $args = null ) {
$required = $field['required'] ? '<span class="required">*</span>' : '';
$required_attr = $field['required'] ? ' required' : '';
$aria_required = $field['required'] ? " aria-required='true'" : '';
$class = $id;
$class .= $field['required'] ? ' form-required' : '';
@ -1669,9 +1668,9 @@ function get_media_item( $attachment_id, $args = null ) {
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
}
// Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit().
$item .= "<textarea id='$name' name='$name'{$required_attr}{$aria_required}>" . $field['value'] . '</textarea>';
$item .= "<textarea id='$name' name='$name'{$required_attr}>" . $field['value'] . '</textarea>';
} else {
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr}{$aria_required} />";
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr} />";
}
if ( ! empty( $field['helps'] ) ) {
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
@ -1829,7 +1828,6 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
$readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : '';
$required = $field['required'] ? '<span class="required">*</span>' : '';
$required_attr = $field['required'] ? ' required' : '';
$aria_required = $field['required'] ? " aria-required='true'" : '';
$class = 'compat-field-' . $id;
$class .= $field['required'] ? ' form-required' : '';
@ -1844,9 +1842,9 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
// sanitize_post() skips the post_content when user_can_richedit.
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
}
$item .= "<textarea id='$id_attr' name='$name'{$required_attr}{$aria_required}>" . $field['value'] . '</textarea>';
$item .= "<textarea id='$id_attr' name='$name'{$required_attr}>" . $field['value'] . '</textarea>';
} else {
$item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly{$required_attr}{$aria_required} />";
$item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly{$required_attr} />";
}
if ( ! empty( $field['helps'] ) ) {
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
@ -2753,14 +2751,14 @@ function wp_media_insert_url_form( $default_view = 'image' ) {
<label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> <span class="required">*</span></label>
<span class="alignright" id="status_img"></span>
</th>
<td class="field"><input id="src" name="src" value="" type="text" required aria-required="true" onblur="addExtImage.getImageData()" /></td>
<td class="field"><input id="src" name="src" value="" type="text" required onblur="addExtImage.getImageData()" /></td>
</tr>
<tr>
<th scope="row" class="label">
<label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> <span class="required">*</span></label>
</th>
<td class="field"><input id="title" name="title" value="" type="text" required aria-required="true" /></td>
<td class="field"><input id="title" name="title" value="" type="text" required /></td>
</tr>
<tr class="not-image"><td></td><td><p class="help">' . __( 'Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;' ) . '</p></td></tr>
@ -2769,7 +2767,7 @@ function wp_media_insert_url_form( $default_view = 'image' ) {
<th scope="row" class="label">
<label for="alt"><span class="alignleft">' . __( 'Alternative Text' ) . '</span></label>
</th>
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
<td class="field"><input id="alt" name="alt" value="" type="text" required />
<p class="help">' . __( 'Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;' ) . '</p></td>
</tr>
' . $caption . '

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42758';
$wp_version = '5.0-alpha-42759';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.