Make WordPress Core


Ignore:
Timestamp:
03/18/2019 03:21:17 PM (6 years ago)
Author:
afercia
Message:

Accessibility: Improve the Comments and Privacy count text.

  • standardizes the Comment count string to %s Comment in moderation', '%s Comments in moderation so it can be bulk-updated
  • adds the string as visually hidden text in the admin menu
  • introduces an updateInModerationText JS simple function, responsible to correctly update all the related text using the data from the AJAX response
  • adds a visually hidden text "1 Privacy Policy update" to the Privacy menu items count
  • adds/improves translators comments

Changes that apply to all the count bubbles (Updates, plugins, etc.)

  • makes the bubbles and their text slightly bigger
  • improves the active menu item bubble contrast by changing the background color to red (option 2 in the screenshot attached in a previous comment)

Props adamsoucie, afercia.
Fixes #33030.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/menu.php

    r43223 r44924  
    4343        $cap = 'update_languages';
    4444    }
     45    /* translators: %s: number of pending updates */
    4546    $submenu['index.php'][10] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-{$update_data['counts']['total']}'><span class='update-count'>" . number_format_i18n( $update_data['counts']['total'] ) . '</span></span>' ), $cap, 'update-core.php' );
    4647    unset( $cap );
     
    7576// Avoid the comment count query for users who cannot edit_posts.
    7677if ( current_user_can( 'edit_posts' ) ) {
    77     $awaiting_mod = wp_count_comments();
    78     $awaiting_mod = $awaiting_mod->moderated;
    79     $menu[25]     = array(
    80         sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ),
     78    $awaiting_mod      = wp_count_comments();
     79    $awaiting_mod      = $awaiting_mod->moderated;
     80    $awaiting_mod_i18n = number_format_i18n( $awaiting_mod );
     81    /* translators: %s: number of comments in moderation */
     82    $awaiting_mod_text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ), $awaiting_mod_i18n );
     83
     84    $menu[25] = array(
     85        /* translators: %s: number of comments in moderation */
     86        sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count" aria-hidden="true">' . $awaiting_mod_i18n . '</span><span class="comments-in-moderation-text screen-reader-text">' . $awaiting_mod_text . '</span></span>' ),
    8187        'edit_posts',
    8288        'edit-comments.php',
     
    215221}
    216222
     223/* translators: %s: number of pending plugin updates */
    217224$menu[65] = array( sprintf( __( 'Plugins %s' ), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' );
    218225
     
    265272
    266273$change_notice = '';
    267 if ( current_user_can( 'manage_privacy_options' ) && WP_Privacy_Policy_Content::text_change_check() ) {
    268     $change_notice = ' <span class="update-plugins 1"><span class="plugin-count">' . number_format_i18n( 1 ) . '</span></span>';
    269 }
    270 
    271 // translators: %s is the update notification bubble, if updates are available.
     274if ( current_user_can( 'manage_privacy_options' ) && ! WP_Privacy_Policy_Content::text_change_check() ) {
     275    $change_notice_number = number_format_i18n( 1 );
     276    /* translators: %s: number of Privacy Policy update is always 1 */
     277    $change_notice_text = sprintf( __( '%s Privacy Policy update' ), $change_notice_number );
     278    $change_notice      = '<span class="update-plugins 1"><span class="plugin-count" aria-hidden="true">' . $change_notice_number . '</span><span class="screen-reader-text">' . $change_notice_text . '</span></span>';
     279}
     280
     281/* translators: %s: update notification bubble, if updates are available */
    272282$menu[80]                               = array( sprintf( __( 'Settings %s' ), $change_notice ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
    273283    $submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' );
     
    277287    $submenu['options-general.php'][30] = array( __( 'Media' ), 'manage_options', 'options-media.php' );
    278288    $submenu['options-general.php'][40] = array( __( 'Permalinks' ), 'manage_options', 'options-permalink.php' );
    279     // translators: %s is the update notification bubble, if updates are available.
     289    /* translators: %s: update notification bubble, if updates are available */
    280290    $submenu['options-general.php'][45] = array( sprintf( __( 'Privacy %s' ), $change_notice ), 'manage_privacy_options', 'privacy.php' );
    281291
Note: See TracChangeset for help on using the changeset viewer.