From 8aede6cab7bb46689353bf1b805fbfb242612f6f Mon Sep 17 00:00:00 2001 From: nacin Date: Sat, 13 Feb 2010 08:49:27 +0000 Subject: [PATCH] Consistently hide bulk actions, filters, and subpage links on admin panels when there are no items to show. Fixes #12086 git-svn-id: http://svn.automattic.com/wordpress/trunk@13100 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 10 +++++----- wp-admin/edit.php | 4 ++-- wp-admin/link-manager.php | 25 ++++++++++++++----------- wp-admin/plugins.php | 6 ++++++ wp-admin/upload.php | 36 +++++++++++++++++++++++------------- 5 files changed, 50 insertions(+), 31 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 0ea72a3ba..19dd035d4 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -192,12 +192,12 @@ if ( !empty($comment_type) && 'all' != $comment_type ) $link = add_query_arg( 'comment_type', $comment_type, $link ); foreach ( $stati as $status => $label ) { - $class = ''; + $class = ( $status == $comment_status ) ? ' class="current"' : ''; - if ( $status == $comment_status ) - $class = ' class="current"'; if ( !isset( $num_comments->$status ) ) $num_comments->$status = 10; + if ( empty( $num_comments->$status ) ) + continue; $link = add_query_arg( 'comment_status', $status, $link ); if ( $post_id ) $link = add_query_arg( 'p', absint( $post_id ), $link ); @@ -270,6 +270,7 @@ $page_links = paginate_links( array(
+
' . __( 'Displaying %s–%s of %s' ) . '%s', number_format_i18n( $start + 1 ), @@ -346,7 +347,6 @@ if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_
- @@ -436,7 +436,7 @@ if ( $page_links ) -

+

diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 14b008fb8..b3ac11e1d 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -399,9 +399,9 @@ if ( $page_links )

diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 1d74cfd74..90279dcb3 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -99,6 +99,16 @@ if ( isset($_GET['deleted']) ) {
+ $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0 ); +if ( ! empty( $_GET['s'] ) ) + $args['search'] = $_GET['s']; +$links = get_bookmarks( $args ); +if ( $links ) { +?> +
- -

- -
@@ -265,6 +264,10 @@ if ( $links ) {
+ +

+ +
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 1919bf04d..0b2668069 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -633,6 +633,8 @@ unset( $status_links ); ?> + +
+ +

+ +

diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 08cd4cf30..94f9c9dcd 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -143,7 +143,8 @@ if ( isset($_GET['detached']) ) { } else { $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page; $orphans = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT %d, %d", $start, $media_per_page ) ); - $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page); + $total_orphans = $wpdb->get_var( "SELECT FOUND_ROWS()" ); + $page_links_total = ceil( $total_orphans / $media_per_page ); } $post_mime_types = get_post_mime_types(); @@ -219,6 +220,8 @@ if ( !empty($message) ) { ?> $type_links = array(); $_num_posts = (array) wp_count_attachments(); $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; +if ( !isset( $total_orphans ) ) + $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" ); $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); foreach ( $matches as $type => $reals ) foreach ( $reals as $real ) @@ -234,11 +237,12 @@ foreach ( $post_mime_types as $mime_type => $label ) { if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) $class = ' class="current"'; - - $type_links[] = "
  • " . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; + if ( !empty( $num_posts[$mime_type] ) ) + $type_links[] = "
  • " . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; } -$type_links[] = '
  • ' . __('Unattached') . ''; -if ( EMPTY_TRASH_DAYS && ( MEDIA_TRASH || !empty($_num_posts['trash']) ) ) +$type_links[] = '
  • ' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . ''; + +if ( !empty($_num_posts['trash']) ) $type_links[] = '
  • ' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . ''; echo implode( " |
  • \n", $type_links) . ''; @@ -255,6 +259,7 @@ unset($type_links);
    +
    + @@ -339,9 +349,11 @@ foreach ($arc_result as $arc_row) {
    + +
    - + @@ -365,7 +377,6 @@ foreach ($arc_result as $arc_row) { ID) ); @@ -423,11 +434,7 @@ foreach ($arc_result as $arc_row) { } ?> - - - +
    @@ -442,6 +449,8 @@ foreach ($arc_result as $arc_row) {
    $page_links_text
    "; ?> @@ -466,6 +475,7 @@ if ( $page_links )
    +