WordPress.org

Make WordPress Core

Changeset 31696


Ignore:
Timestamp:
03/10/2015 03:31:54 PM (4 years ago)
Author:
ocean90
Message:

Screen Options: Improve items per page option label.

Previously the label just said "Posts", "Pages", or "Comments". This was bad in terms of accessibility and internationalization because of missing context.
This change adds a default label "Number of items per page:" to WP_Screen->render_per_page_options() and removes all the existing one-word labels.

props afercia.
fixes #31349, #15576.

Location:
trunk/src/wp-admin
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/common.css

    r31641 r31696  
    15051505.metabox-prefs label a {
    15061506    display: none;
     1507}
     1508
     1509.metabox-prefs .screen-options {
     1510    padding-top: 10px;
     1511}
     1512
     1513.metabox-prefs .screen-options input,
     1514.metabox-prefs .screen-options label {
     1515    margin-top: 0;
     1516    margin-bottom: 0;
     1517    vertical-align: middle;
     1518}
     1519
     1520.metabox-prefs .screen-options .screen-per-page {
     1521    margin-right: 15px;
     1522}
     1523
     1524.metabox-prefs .screen-options label {
     1525    line-height: 28px;
     1526    padding-right: 0;
    15071527}
    15081528
  • trunk/src/wp-admin/edit-comments.php

    r31200 r31696  
    110110    $title = __('Comments');
    111111
    112 add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
     112add_screen_option( 'per_page' );
    113113
    114114get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/edit-tags.php

    r31247 r31696  
    4040}
    4141
    42 add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
     42add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
    4343
    4444$location = false;
  • trunk/src/wp-admin/edit.php

    r31200 r31696  
    166166wp_enqueue_script('heartbeat');
    167167
    168 $title = $post_type_object->labels->name;
    169 
    170168if ( 'post' == $post_type ) {
    171169    get_current_screen()->add_help_tab( array(
     
    235233}
    236234
    237 add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
     235add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
    238236
    239237$bulk_counts = array(
  • trunk/src/wp-admin/includes/screen.php

    r31200 r31696  
    11281128     */
    11291129    public function render_per_page_options() {
    1130         if ( ! $this->get_option( 'per_page' ) )
     1130        if ( null === $this->get_option( 'per_page' ) ) {
    11311131            return;
     1132        }
    11321133
    11331134        $per_page_label = $this->get_option( 'per_page', 'label' );
     1135        if ( null === $per_page_label ) {
     1136            $per_page_label = __( 'Number of items per page:' );
     1137        }
    11341138
    11351139        $option = $this->get_option( 'per_page', 'option' );
    1136         if ( ! $option )
     1140        if ( ! $option ) {
    11371141            $option = str_replace( '-', '_', "{$this->id}_per_page" );
     1142        }
    11381143
    11391144        $per_page = (int) get_user_option( $option );
    11401145        if ( empty( $per_page ) || $per_page < 1 ) {
    11411146            $per_page = $this->get_option( 'per_page', 'default' );
    1142             if ( ! $per_page )
     1147            if ( ! $per_page ) {
    11431148                $per_page = 20;
     1149            }
    11441150        }
    11451151
     
    11661172        <div class="screen-options">
    11671173            <?php if ( $per_page_label ) : ?>
     1174                <label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
    11681175                <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
    11691176                    id="<?php echo esc_attr( $option ); ?>" maxlength="3"
    11701177                    value="<?php echo esc_attr( $per_page ); ?>" />
    1171                 <label for="<?php echo esc_attr( $option ); ?>">
    1172                     <?php echo esc_html( $per_page_label ); ?>
    1173                 </label>
    11741178            <?php endif;
    11751179
    11761180            echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
    1177             <input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />
     1181            <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
    11781182        </div>
    11791183        <?php
  • trunk/src/wp-admin/network/site-themes.php

    r31658 r31696  
    128128
    129129add_thickbox();
    130 add_screen_option( 'per_page', array( 'label' => _x( 'Themes', 'themes per page (screen options)' ) ) );
     130add_screen_option( 'per_page' );
    131131
    132132$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
  • trunk/src/wp-admin/network/site-users.php

    r31658 r31696  
    156156}
    157157
    158 add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) );
     158add_screen_option( 'per_page' );
    159159
    160160$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
  • trunk/src/wp-admin/network/sites.php

    r31658 r31696  
    2323$parent_file = 'sites.php';
    2424
    25 add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
     25add_screen_option( 'per_page' );
    2626
    2727get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/network/themes.php

    r31681 r31696  
    221221add_thickbox();
    222222
    223 add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) );
     223add_screen_option( 'per_page' );
    224224
    225225get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/network/users.php

    r31658 r31696  
    3030        <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
    3131    <?php endif; ?>
    32    
     32
    3333    <form action="users.php?action=dodelete" method="post">
    3434    <input type="hidden" name="dodelete" />
     
    109109        <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
    110110    <?php endif;
    111    
     111
    112112    submit_button( __('Confirm Deletion'), 'delete' );
    113113    ?>
    114114    </form>
    115     <?php
     115    <?php
    116116    return true;
    117117}
     
    137137                confirm_delete_users( $_POST['allusers'] );
    138138                echo '</div>';
    139                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
    140             } else {
     139                require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     140            } else {
    141141                wp_redirect( network_admin_url( 'users.php' ) );
    142142            }
     
    253253$parent_file = 'users.php';
    254254
    255 add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
     255add_screen_option( 'per_page' );
    256256
    257257get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/plugins.php

    r31681 r31696  
    362362add_thickbox();
    363363
    364 add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999 ) );
     364add_screen_option( 'per_page', array( 'default' => 999 ) );
    365365
    366366get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/upload.php

    r31624 r31696  
    174174wp_enqueue_script( 'media' );
    175175
    176 add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
     176add_screen_option( 'per_page' );
    177177
    178178get_current_screen()->add_help_tab( array(
  • trunk/src/wp-admin/users.php

    r31200 r31696  
    1818$parent_file = 'users.php';
    1919
    20 add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
     20add_screen_option( 'per_page' );
    2121
    2222// contextual help - choose Help on the top right of admin panel to preview this.
Note: See TracChangeset for help on using the changeset viewer.