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.

git-svn-id: https://develop.svn.wordpress.org/trunk@31696 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-03-10 15:31:54 +00:00
parent b1bbce3f6e
commit 3bb3d2f1a5
13 changed files with 47 additions and 25 deletions

View File

@ -1506,6 +1506,26 @@ form.upgrade .hint {
display: none;
}
.metabox-prefs .screen-options {
padding-top: 10px;
}
.metabox-prefs .screen-options input,
.metabox-prefs .screen-options label {
margin-top: 0;
margin-bottom: 0;
vertical-align: middle;
}
.metabox-prefs .screen-options .screen-per-page {
margin-right: 15px;
}
.metabox-prefs .screen-options label {
line-height: 28px;
padding-right: 0;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/

View File

@ -109,7 +109,7 @@ if ( $post_id )
else
$title = __('Comments');
add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -39,7 +39,7 @@ if ( 'post' != $post_type ) {
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
}
add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
$location = false;

View File

@ -165,8 +165,6 @@ $wp_list_table->prepare_items();
wp_enqueue_script('inline-edit-post');
wp_enqueue_script('heartbeat');
$title = $post_type_object->labels->name;
if ( 'post' == $post_type ) {
get_current_screen()->add_help_tab( array(
'id' => 'overview',
@ -234,7 +232,7 @@ if ( 'post' == $post_type ) {
);
}
add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
$bulk_counts = array(
'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,

View File

@ -1127,20 +1127,26 @@ final class WP_Screen {
* @since 3.3.0
*/
public function render_per_page_options() {
if ( ! $this->get_option( 'per_page' ) )
if ( null === $this->get_option( 'per_page' ) ) {
return;
}
$per_page_label = $this->get_option( 'per_page', 'label' );
if ( null === $per_page_label ) {
$per_page_label = __( 'Number of items per page:' );
}
$option = $this->get_option( 'per_page', 'option' );
if ( ! $option )
if ( ! $option ) {
$option = str_replace( '-', '_', "{$this->id}_per_page" );
}
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 ) {
$per_page = $this->get_option( 'per_page', 'default' );
if ( ! $per_page )
if ( ! $per_page ) {
$per_page = 20;
}
}
if ( 'edit_comments_per_page' == $option ) {
@ -1165,16 +1171,14 @@ final class WP_Screen {
?>
<div class="screen-options">
<?php if ( $per_page_label ) : ?>
<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
value="<?php echo esc_attr( $per_page ); ?>" />
<label for="<?php echo esc_attr( $option ); ?>">
<?php echo esc_html( $per_page_label ); ?>
</label>
<?php endif;
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
<input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
</div>
<?php
}

View File

@ -127,7 +127,7 @@ if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
}
add_thickbox();
add_screen_option( 'per_page', array( 'label' => _x( 'Themes', 'themes per page (screen options)' ) ) );
add_screen_option( 'per_page' );
$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
$title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );

View File

@ -155,7 +155,7 @@ if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
exit();
}
add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) );
add_screen_option( 'per_page' );
$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
$title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );

View File

@ -22,7 +22,7 @@ $pagenum = $wp_list_table->get_pagenum();
$title = __( 'Sites' );
$parent_file = 'sites.php';
add_screen_option( 'per_page', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -220,7 +220,7 @@ $wp_list_table->prepare_items();
add_thickbox();
add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -29,7 +29,7 @@ function confirm_delete_users( $users ) {
<?php else : ?>
<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
<?php endif; ?>
<form action="users.php?action=dodelete" method="post">
<input type="hidden" name="dodelete" />
<?php
@ -108,11 +108,11 @@ function confirm_delete_users( $users ) {
<?php else : ?>
<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
<?php endif;
submit_button( __('Confirm Deletion'), 'delete' );
?>
</form>
<?php
<?php
return true;
}
@ -136,8 +136,8 @@ if ( isset( $_GET['action'] ) ) {
echo '<div class="wrap">';
confirm_delete_users( $_POST['allusers'] );
echo '</div>';
require_once( ABSPATH . 'wp-admin/admin-footer.php' );
} else {
require_once( ABSPATH . 'wp-admin/admin-footer.php' );
} else {
wp_redirect( network_admin_url( 'users.php' ) );
}
exit();
@ -252,7 +252,7 @@ if ( $pagenum > $total_pages && $total_pages > 0 ) {
$title = __( 'Users' );
$parent_file = 'users.php';
add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -361,7 +361,7 @@ $wp_list_table->prepare_items();
wp_enqueue_script('plugin-install');
add_thickbox();
add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999 ) );
add_screen_option( 'per_page', array( 'default' => 999 ) );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -173,7 +173,7 @@ $parent_file = 'upload.php';
wp_enqueue_script( 'media' );
add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
'id' => 'overview',

View File

@ -17,7 +17,7 @@ $pagenum = $wp_list_table->get_pagenum();
$title = __('Users');
$parent_file = 'users.php';
add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
add_screen_option( 'per_page' );
// contextual help - choose Help on the top right of admin panel to preview this.
get_current_screen()->add_help_tab( array(