Make WordPress Core

Ticket #46122: 46122.2.diff

File 46122.2.diff, 5.9 KB (added by garrett-eclipse, 6 years ago)

Initial patch had the patch work from 46112, stripped in this version to isolate the changes

  • src/wp-admin/includes/class-wp-ms-users-list-table.php

     
    133133        protected function get_views() {
    134134                global $role;
    135135
     136                $role_links   = array();
     137
    136138                $total_users  = get_user_count();
     139
     140                $current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : '';
     141                $status_label            = sprintf(
     142                        /* translators: %s: all users count */
     143                        _nx(
     144                                'All <span class="count">(%s)</span>',
     145                                'All <span class="count">(%s)</span>',
     146                                $total_users,
     147                                'user roles'
     148                        ),
     149                        number_format_i18n( $total_users )
     150                );
     151
     152                $role_links['all'] = sprintf(
     153                        '<a href="%s"%s>%s</a>',
     154                        esc_url( network_admin_url( 'users.php' ) ),
     155                        $current_link_attributes,
     156                        $status_label
     157                );
     158
    137159                $super_admins = get_super_admins();
    138160                $total_admins = count( $super_admins );
    139161
    140                 $current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : '';
    141                 $role_links              = array();
    142                 $role_links['all']       = "<a href='" . network_admin_url( 'users.php' ) . "'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    143162                $current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : '';
    144                 $role_links['super']     = "<a href='" . network_admin_url( 'users.php?role=super' ) . "'$current_link_attributes>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
     163                $status_label            = sprintf(
     164                        /* translators: %s: all users count */
     165                        _nx(
     166                                'Super Admin <span class="count">(%s)</span>',
     167                                'Super Admins <span class="count">(%s)</span>',
     168                                $total_admins,
     169                                'user roles'
     170                        ),
     171                        number_format_i18n( $total_admins )
     172                );
    145173
     174                $role_links['super'] = sprintf(
     175                        '<a href="%s"%s>%s</a>',
     176                        esc_url( network_admin_url( 'users.php?role=super' ) ),
     177                        $current_link_attributes,
     178                        $status_label
     179                );
     180
    146181                return $role_links;
    147182        }
    148183
  • src/wp-admin/includes/class-wp-users-list-table.php

     
    175175        protected function get_views() {
    176176                global $role;
    177177
    178                 $wp_roles = wp_roles();
     178                $wp_roles       = wp_roles();
     179                $role_links = array();
    179180
    180181                if ( $this->is_site_users ) {
    181182                        $url = 'site-users.php?id=' . $this->site_id;
     
    192193                unset( $users_of_blog );
    193194
    194195                $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
     196                $status_label            = sprintf(
     197                        /* translators: %s: all users count */
     198                        _nx(
     199                                'All <span class="count">(%s)</span>',
     200                                'All <span class="count">(%s)</span>',
     201                                $total_users,
     202                                'user roles'
     203                        ),
     204                        number_format_i18n( $total_users )
     205                );
    195206
    196                 $role_links        = array();
    197                 $role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    198                 foreach ( $wp_roles->get_names() as $this_role => $name ) {
     207                $role_links['all'] = sprintf(
     208                        '<a href="%s"%s>%s</a>',
     209                        esc_url( $url ),
     210                        $current_link_attributes,
     211                        $status_label
     212                );
     213               
     214                foreach ( $wp_roles->get_names() as $this_role => $role_name ) {
    199215                        if ( ! isset( $avail_roles[ $this_role ] ) ) {
    200216                                continue;
    201217                        }
    202218
    203                         $current_link_attributes = '';
     219                        $current_link_attributes = $this_role === $role ? ' class="current" aria-current="page"' : '';
     220                        $role_name               = sprintf(
     221                                /* translators: User role name with count */
     222                                __( '%1$s <span class="count">(%2$s)</span>' ),
     223                                translate_user_role( $role_name ),
     224                                number_format_i18n( $avail_roles[ $this_role ] )
     225                        );
    204226
    205                         if ( $this_role === $role ) {
    206                                 $current_link_attributes = ' class="current" aria-current="page"';
    207                         }
    208 
    209                         $name = translate_user_role( $name );
    210                         /* translators: User role name with count */
    211                         $name                     = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) );
    212                         $role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
     227                        $role_links[ $this_role ] = sprintf(
     228                                '<a href="%s"%s>%s</a>',
     229                                esc_url( add_query_arg( 'role', $this_role, $url ) ),
     230                                $current_link_attributes,
     231                                $role_name                             
     232                        );
    213233                }
    214234
    215235                if ( ! empty( $avail_roles['none'] ) ) {
    216236
    217                         $current_link_attributes = '';
     237                        $current_link_attributes = 'none' === $role ? ' class="current" aria-current="page"' : '';
     238                        $role_name               = sprintf(
     239                                /* translators: User role name with count */
     240                                __( '%1$s <span class="count">(%2$s)</span>' ),
     241                                /* translators: No role available */
     242                                __( 'No role' ),
     243                                number_format_i18n( $avail_roles['none'] )
     244                        );
    218245
    219                         if ( 'none' === $role ) {
    220                                 $current_link_attributes = ' class="current" aria-current="page"';
    221                         }
     246                        $role_links[ 'none' ] = sprintf(
     247                                '<a href="%s"%s>%s</a>',
     248                                esc_url( add_query_arg( 'role', 'none', $url ) ),
     249                                $current_link_attributes,
     250                                $role_name                             
     251                        );                     
    222252
    223                         $name = __( 'No role' );
    224                         /* translators: User role name with count */
    225                         $name               = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles['none'] ) );
    226                         $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
    227 
    228253                }
    229254
    230255                return $role_links;