From 3bb3d2f1a5e92701285beff3267c79ca27af8d64 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Tue, 10 Mar 2015 15:31:54 +0000 Subject: [PATCH] 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 --- src/wp-admin/css/common.css | 20 ++++++++++++++++++++ src/wp-admin/edit-comments.php | 2 +- src/wp-admin/edit-tags.php | 2 +- src/wp-admin/edit.php | 4 +--- src/wp-admin/includes/screen.php | 18 +++++++++++------- src/wp-admin/network/site-themes.php | 2 +- src/wp-admin/network/site-users.php | 2 +- src/wp-admin/network/sites.php | 2 +- src/wp-admin/network/themes.php | 2 +- src/wp-admin/network/users.php | 12 ++++++------ src/wp-admin/plugins.php | 2 +- src/wp-admin/upload.php | 2 +- src/wp-admin/users.php | 2 +- 13 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index f6ec9d3413..ee91b4bea4 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -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 ------------------------------------------------------------------------------*/ diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index 1a4c78c8b6..29717d8002 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -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', diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php index cce4715e9a..b8a422e2fa 100644 --- a/src/wp-admin/edit-tags.php +++ b/src/wp-admin/edit-tags.php @@ -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; diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index 93d7d0e82c..5293106408 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -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, diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index 13bf4d4b62..3572446d89 100644 --- a/src/wp-admin/includes/screen.php +++ b/src/wp-admin/includes/screen.php @@ -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 { ?>
+ - - +
_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: %2$s'), get_blogaddress_by_id( $id ), $site_url_no_http ); diff --git a/src/wp-admin/network/site-users.php b/src/wp-admin/network/site-users.php index 5c1dc5bcf4..3638f2b29d 100644 --- a/src/wp-admin/network/site-users.php +++ b/src/wp-admin/network/site-users.php @@ -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: %2$s'), get_blogaddress_by_id( $id ), $site_url_no_http ); diff --git a/src/wp-admin/network/sites.php b/src/wp-admin/network/sites.php index 8feaf45e40..508f69ebc9 100644 --- a/src/wp-admin/network/sites.php +++ b/src/wp-admin/network/sites.php @@ -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', diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php index 18966d3a20..d37dd88316 100644 --- a/src/wp-admin/network/themes.php +++ b/src/wp-admin/network/themes.php @@ -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', diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index f75c35a0f3..3bb9854ef4 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -29,7 +29,7 @@ function confirm_delete_users( $users ) {

- +

- '; confirm_delete_users( $_POST['allusers'] ); echo ''; - 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', diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index 265c1ea7c3..c73cc8ce86 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -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', diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index 6e16c75ea1..c62c219506 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -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', diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index 0dddb39b24..39d3ae4af8 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -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(