-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Administration: Clean up counter item accessible names #12850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
298758c
d30ba34
2a4366a
90c2d21
7f440ab
3ab0955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,20 +49,36 @@ | |
| $capability = 'update_languages'; | ||
| } | ||
|
|
||
| $updates_count = sprintf( | ||
| '<span class="update-plugins count-%s" aria-hidden="true"><span class="update-count">%s</span></span>', | ||
| $update_data['counts']['total'], | ||
|
Check warning on line 54 in src/wp-admin/menu.php
|
||
| number_format_i18n( $update_data['counts']['total'] ) | ||
| ); | ||
|
|
||
| $updates_text = sprintf( | ||
| /* translators: Hidden accessibility text. %s: Number of updates available. */ | ||
| _n( '%s update available', '%s updates available', $update_data['counts']['total'] ), | ||
| number_format_i18n( $update_data['counts']['total'] ) | ||
| ); | ||
|
|
||
| $updates_description = '<span id="wp-menu-updates-count-description" class="wp-menu-count-description screen-reader-text" aria-hidden="true">' . $updates_text . '</span>'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than using screen-reader-text and aria-hidden, I'd consider to simplify and use the |
||
|
|
||
| $submenu['index.php'][10] = array( | ||
| sprintf( | ||
| /* translators: %s: Number of pending updates. */ | ||
| __( 'Updates %s' ), | ||
| sprintf( | ||
| '<span class="update-plugins count-%s"><span class="update-count">%s</span></span>', | ||
| $update_data['counts']['total'], | ||
| number_format_i18n( $update_data['counts']['total'] ) | ||
| ) | ||
| $updates_count | ||
| ), | ||
| $capability, | ||
| 'update-core.php', | ||
| ); | ||
|
|
||
| // Associate the hidden count description with the link. See _wp_menu_output(). | ||
| $submenu['index.php'][10]['count_description'] = array( | ||
| 'id' => 'wp-menu-updates-count-description', | ||
| 'html' => $updates_description, | ||
| ); | ||
|
|
||
| unset( $capability ); | ||
| } | ||
|
|
||
|
|
@@ -103,8 +119,11 @@ | |
| $awaiting_moderation_text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_moderation ), $awaiting_moderation_i18n ); | ||
|
|
||
| $menu[25] = array( | ||
| /* translators: %s: Number of comments. */ | ||
| sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_moderation ) . '"><span class="pending-count" aria-hidden="true">' . $awaiting_moderation_i18n . '</span><span class="comments-in-moderation-text screen-reader-text">' . $awaiting_moderation_text . '</span></span>' ), | ||
| sprintf( | ||
| /* translators: %s: Number of comments. */ | ||
| __( 'Comments %s' ), | ||
| '<span class="awaiting-mod count-' . absint( $awaiting_moderation ) . '" aria-hidden="true"><span class="pending-count">' . $awaiting_moderation_i18n . '</span></span>' | ||
| ), | ||
| 'edit_posts', | ||
| 'edit-comments.php', | ||
| '', | ||
|
|
@@ -113,6 +132,12 @@ | |
| 'dashicons-admin-comments', | ||
| ); | ||
|
|
||
| // Associate the hidden count description with the link. See _wp_menu_output(). | ||
| $menu[25]['count_description'] = array( | ||
| 'id' => 'wp-menu-comments-count-description', | ||
| 'html' => '<span id="wp-menu-comments-count-description" class="wp-menu-count-description comments-in-moderation-text screen-reader-text" aria-hidden="true">' . $awaiting_moderation_text . '</span>', | ||
| ); | ||
|
|
||
| unset( $awaiting_moderation ); | ||
| } | ||
|
|
||
|
|
@@ -208,22 +233,39 @@ | |
|
|
||
| $menu[60] = array( __( 'Appearance' ), $appearance_capability, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' ); | ||
|
|
||
| $count = ''; | ||
| $count = ''; | ||
| $description = ''; | ||
| if ( ! is_multisite() && current_user_can( 'update_themes' ) ) { | ||
| if ( ! isset( $update_data ) ) { | ||
| $update_data = wp_get_update_data(); | ||
| } | ||
|
|
||
| $count = sprintf( | ||
| '<span class="update-plugins count-%s"><span class="theme-count">%s</span></span>', | ||
| '<span class="update-plugins count-%s" aria-hidden="true"><span class="theme-count">%s</span></span>', | ||
| $update_data['counts']['themes'], | ||
| number_format_i18n( $update_data['counts']['themes'] ) | ||
| ); | ||
|
|
||
| $themes_text = sprintf( | ||
| /* translators: Hidden accessibility text. %s: Number of available theme updates. */ | ||
| _n( '%s theme update available', '%s theme updates available', $update_data['counts']['themes'] ), | ||
| number_format_i18n( $update_data['counts']['themes'] ) | ||
| ); | ||
|
|
||
| $description = '<span id="wp-menu-themes-count-description" class="wp-menu-count-description screen-reader-text" aria-hidden="true">' . $themes_text . '</span>'; | ||
| } | ||
|
|
||
| /* translators: %s: Number of available theme updates. */ | ||
| $submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_capability, 'themes.php' ); | ||
|
|
||
| // Associate the hidden count description with the link. See _wp_menu_output(). | ||
| if ( '' !== $description ) { | ||
| $submenu['themes.php'][5]['count_description'] = array( | ||
| 'id' => 'wp-menu-themes-count-description', | ||
| 'html' => $description, | ||
| ); | ||
| } | ||
|
|
||
| if ( wp_is_block_theme() ) { | ||
| $submenu['themes.php'][6] = array( _x( 'Editor', 'site editor menu item' ), 'edit_theme_options', 'site-editor.php' ); | ||
| } else { | ||
|
|
@@ -307,21 +349,38 @@ | |
| ); | ||
| } | ||
|
|
||
| $count = ''; | ||
| $count = ''; | ||
| $description = ''; | ||
| if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) { | ||
| if ( ! isset( $update_data ) ) { | ||
| $update_data = wp_get_update_data(); | ||
| } | ||
| $count = sprintf( | ||
| '<span class="update-plugins count-%s"><span class="plugin-count">%s</span></span>', | ||
| '<span class="update-plugins count-%s" aria-hidden="true"><span class="plugin-count">%s</span></span>', | ||
| $update_data['counts']['plugins'], | ||
| number_format_i18n( $update_data['counts']['plugins'] ) | ||
| ); | ||
|
|
||
| $plugins_text = sprintf( | ||
| /* translators: Hidden accessibility text. %s: Number of available plugin updates. */ | ||
| _n( '%s plugin update available', '%s plugin updates available', $update_data['counts']['plugins'] ), | ||
| number_format_i18n( $update_data['counts']['plugins'] ) | ||
| ); | ||
|
|
||
| $description = '<span id="wp-menu-plugins-count-description" class="wp-menu-count-description screen-reader-text" aria-hidden="true">' . $plugins_text . '</span>'; | ||
| } | ||
|
|
||
| /* translators: %s: Number of available plugin updates. */ | ||
| $menu[65] = array( sprintf( __( 'Plugins %s' ), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider to move the |
||
|
|
||
| // Associate the hidden count description with the link. See _wp_menu_output(). | ||
| if ( '' !== $description ) { | ||
| $menu[65]['count_description'] = array( | ||
| 'id' => 'wp-menu-plugins-count-description', | ||
| 'html' => $description, | ||
| ); | ||
| } | ||
|
|
||
| $submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'activate_plugins', 'plugins.php' ); | ||
|
|
||
| if ( ! is_multisite() ) { | ||
|
|
@@ -362,7 +421,8 @@ | |
| } | ||
| } | ||
|
|
||
| $site_health_count = ''; | ||
| $site_health_count = ''; | ||
| $site_health_description = ''; | ||
| if ( ! is_multisite() && current_user_can( 'view_site_health_checks' ) ) { | ||
| $get_issues = get_transient( 'health-check-site-status-result' ); | ||
|
|
||
|
|
@@ -381,10 +441,18 @@ | |
| } | ||
|
|
||
| $site_health_count = sprintf( | ||
| '<span class="menu-counter site-health-counter count-%s"><span class="count">%s</span></span>', | ||
| '<span class="menu-counter site-health-counter count-%s" aria-hidden="true"><span class="count">%s</span></span>', | ||
| $issue_counts['critical'], | ||
| number_format_i18n( $issue_counts['critical'] ) | ||
| ); | ||
|
|
||
| $site_health_text = sprintf( | ||
| /* translators: Hidden accessibility text. %s: Number of critical Site Health checks. */ | ||
| _n( '%s critical issue', '%s critical issues', $issue_counts['critical'] ), | ||
| number_format_i18n( $issue_counts['critical'] ) | ||
| ); | ||
|
|
||
| $site_health_description = '<span id="wp-menu-site-health-count-description" class="wp-menu-count-description screen-reader-text" aria-hidden="true">' . $site_health_text . '</span>'; | ||
| } | ||
|
|
||
| $menu[75] = array( __( 'Tools' ), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'dashicons-admin-tools' ); | ||
|
|
@@ -393,6 +461,14 @@ | |
| $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' ); | ||
| /* translators: %s: Number of critical Site Health checks. */ | ||
| $submenu['tools.php'][20] = array( sprintf( __( 'Site Health %s' ), $site_health_count ), 'view_site_health_checks', 'site-health.php' ); | ||
|
|
||
| // Associate the hidden count description with the link. See _wp_menu_output(). | ||
| if ( '' !== $site_health_description ) { | ||
| $submenu['tools.php'][20]['count_description'] = array( | ||
| 'id' => 'wp-menu-site-health-count-description', | ||
| 'html' => $site_health_description, | ||
| ); | ||
| } | ||
| $submenu['tools.php'][25] = array( __( 'Export Personal Data' ), 'export_others_personal_data', 'export-personal-data.php' ); | ||
| $submenu['tools.php'][30] = array( __( 'Erase Personal Data' ), 'erase_others_personal_data', 'erase-personal-data.php' ); | ||
| if ( is_multisite() && ! is_main_site() && '1' !== get_site()->deleted ) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1134,13 +1134,17 @@ function wp_admin_bar_comments_menu( $wp_admin_bar ) { | |
|
|
||
| $icon = '<span class="ab-icon" aria-hidden="true"></span>'; | ||
| $title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>'; | ||
| $title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>'; | ||
| $title .= '<span class="screen-reader-text">' . __( 'Comments' ) . '</span>'; | ||
| $title .= '<span id="wp-admin-bar-comments-count-description" class="screen-reader-text comments-in-moderation-text" aria-hidden="true">' . $awaiting_text . '</span>'; | ||
|
|
||
| $wp_admin_bar->add_node( | ||
| array( | ||
| 'id' => 'comments', | ||
| 'title' => $icon . $title, | ||
| 'href' => admin_url( 'edit-comments.php' ), | ||
| 'meta' => array( | ||
| 'aria-describedby' => 'wp-admin-bar-comments-count-description', | ||
| ), | ||
| ) | ||
|
Comment on lines
+1137
to
1148
|
||
| ); | ||
| } | ||
|
|
@@ -1249,13 +1253,17 @@ function wp_admin_bar_updates_menu( $wp_admin_bar ) { | |
|
|
||
| $icon = '<span class="ab-icon" aria-hidden="true"></span>'; | ||
| $title = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; | ||
| $title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>'; | ||
| $title .= '<span class="screen-reader-text">' . __( 'Updates' ) . '</span>'; | ||
| $title .= '<span id="wp-admin-bar-updates-count-description" class="screen-reader-text updates-available-text" aria-hidden="true">' . $updates_text . '</span>'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly to the admin menu, I would consider to use the |
||
|
|
||
| $wp_admin_bar->add_node( | ||
| array( | ||
| 'id' => 'updates', | ||
| 'title' => $icon . $title, | ||
| 'href' => network_admin_url( 'update-core.php' ), | ||
| 'meta' => array( | ||
| 'aria-describedby' => 'wp-admin-bar-updates-count-description', | ||
| ), | ||
| ) | ||
|
Comment on lines
+1256
to
1267
|
||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a valid concern that should be double checked.