Make WordPress Core


Ignore:
Timestamp:
03/10/2015 03:31:54 PM (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.