Plugins: Assign role of button to links that act as buttons.

Clicking on these links initiates an action, so they are more semantically a button rather than a link. Keeping them as an anchor in html allows any existing JS that is targeted to these items to continue to function. The addition of the role helps assistive technology to know that they should treat this as a button.

Props stevejonesdev, sabernhardt, vipulgupta003, rcreators, joedolson.
Fixes #61011.

Built from https://develop.svn.wordpress.org/trunk@58161


git-svn-id: http://core.svn.wordpress.org/trunk@57624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2024-05-16 15:31:12 +00:00
parent fdbe1f11a5
commit a91012a34b
2 changed files with 5 additions and 5 deletions

View File

@ -943,7 +943,7 @@ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible
$all_plugin_dependencies_active = $active_plugin_dependencies_count === $plugin_dependencies_count;
sprintf(
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s" role="button">%s</a>',
esc_attr( $data->slug ),
esc_url( $status['url'] ),
/* translators: %s: Plugin name and version. */
@ -958,7 +958,7 @@ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible
if ( $status['url'] ) {
if ( $compatible_php && $compatible_wp && $all_plugin_dependencies_installed && ! empty( $data->download_link ) ) {
$button = sprintf(
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
'<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s" role="button">%s</a>',
esc_attr( $data->slug ),
esc_url( $status['url'] ),
/* translators: %s: Plugin name and version. */
@ -979,7 +979,7 @@ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible
if ( $status['url'] ) {
if ( $compatible_php && $compatible_wp ) {
$button = sprintf(
'<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
'<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s" role="button">%s</a>',
esc_attr( $status['file'] ),
esc_attr( $data->slug ),
esc_url( $status['url'] ),
@ -1026,7 +1026,7 @@ function wp_get_plugin_action_button( $name, $data, $compatible_php, $compatible
}
$button = sprintf(
'<a href="%1$s" data-name="%2$s" data-slug="%3$s" data-plugin="%4$s" class="button button-primary activate-now" aria-label="%5$s">%6$s</a>',
'<a href="%1$s" data-name="%2$s" data-slug="%3$s" data-plugin="%4$s" class="button button-primary activate-now" aria-label="%5$s" role="button">%6$s</a>',
esc_url( $activate_url ),
esc_attr( $name ),
esc_attr( $data->slug ),

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-58160';
$wp_version = '6.6-alpha-58161';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.