WordPress.org

Make WordPress Core

Changeset 13100


Ignore:
Timestamp:
02/13/10 08:49:27 (4 years ago)
Author:
nacin
Message:

Consistently hide bulk actions, filters, and subpage links on admin panels when there are no items to show. Fixes #12086

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r12789 r13100  
    193193 
    194194foreach ( $stati as $status => $label ) { 
    195     $class = ''; 
    196  
    197     if ( $status == $comment_status ) 
    198         $class = ' class="current"'; 
     195    $class = ( $status == $comment_status ) ? ' class="current"' : ''; 
     196 
    199197    if ( !isset( $num_comments->$status ) ) 
    200198        $num_comments->$status = 10; 
     199    if ( empty( $num_comments->$status ) ) 
     200        continue; 
    201201    $link = add_query_arg( 'comment_status', $status, $link ); 
    202202    if ( $post_id ) 
     
    271271<div class="tablenav"> 
    272272 
     273<?php if ( $comments ) { ?> 
    273274<?php if ( $page_links ) : ?> 
    274275<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s', 
     
    347348<div class="clear"></div> 
    348349 
    349 <?php if ( $comments ) { ?> 
    350350<table class="widefat comments fixed" cellspacing="0"> 
    351351<thead> 
     
    437437 
    438438<?php } else { ?> 
    439 <p><?php _e('No results found.') ?></p> 
     439<p><?php _e('No comments found.') ?></p> 
    440440</form> 
    441441 
  • trunk/wp-admin/edit.php

    r12994 r13100  
    400400<p><?php 
    401401if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] ) 
    402     _e('No posts found in the trash'); 
     402    _e( 'No posts found in the Trash.' ); 
    403403else 
    404     _e('No posts found'); 
     404    _e( 'No posts found.' ); 
    405405?></p> 
    406406<?php } ?> 
  • trunk/wp-admin/link-manager.php

    r12895 r13100  
    100100<div class="tablenav"> 
    101101 
     102<?php 
     103if ( 'all' == $cat_id ) 
     104    $cat_id = ''; 
     105$args = array( 'category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0 ); 
     106if ( ! empty( $_GET['s'] ) ) 
     107    $args['search'] = $_GET['s']; 
     108$links = get_bookmarks( $args ); 
     109if ( $links ) { 
     110?> 
     111 
    102112<div class="alignleft actions"> 
    103113<select name="action"> 
     
    136146 
    137147<?php 
    138 if ( 'all' == $cat_id ) 
    139     $cat_id = ''; 
    140 $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0); 
    141 if ( !empty($_GET['s']) ) 
    142     $args['search'] = $_GET['s']; 
    143 $links = get_bookmarks( $args ); 
    144 if ( $links ) { 
    145148    $link_columns = get_column_headers('link-manager'); 
    146149    $hidden = get_hidden_columns('link-manager'); 
     
    252255</table> 
    253256 
    254 <?php } else { ?> 
    255 <p><?php _e('No links found.') ?></p> 
    256 <?php } ?> 
    257  
    258257<div class="tablenav"> 
    259258 
     
    266265</div> 
    267266 
     267<?php } else { ?> 
     268<p><?php _e( 'No links found.' ) ?></p> 
     269<?php } ?> 
     270 
    268271<br class="clear" /> 
    269272</div> 
  • trunk/wp-admin/plugins.php

    r12996 r13100  
    634634</ul> 
    635635 
     636<?php if ( ! empty( $plugins ) ) { ?> 
     637 
    636638<div class="tablenav"> 
    637639<?php 
     
    657659?> 
    658660</div> 
     661<?php } elseif ( ! empty( $all_plugins ) ) { ?> 
     662<p><?php __( 'No plugins found.' ); ?></p> 
     663<?php } ?> 
    659664</form> 
    660665 
    661666<?php if ( empty($all_plugins) ) : ?> 
     667<br class="clear" /> 
    662668<p><?php _e('You do not appear to have any plugins available at this time.') ?></p> 
    663669<?php endif; ?> 
  • trunk/wp-admin/upload.php

    r12972 r13100  
    144144        $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page; 
    145145        $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 ) ); 
    146         $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page); 
     146        $total_orphans = $wpdb->get_var( "SELECT FOUND_ROWS()" ); 
     147        $page_links_total = ceil( $total_orphans / $media_per_page ); 
    147148    } 
    148149 
     
    220221$_num_posts = (array) wp_count_attachments(); 
    221222$_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 
     223if ( !isset( $total_orphans ) ) 
     224        $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" ); 
    222225$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 
    223226foreach ( $matches as $type => $reals ) 
     
    235238    if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) 
    236239        $class = ' class="current"'; 
    237  
    238     $type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>'; 
    239 } 
    240 $type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>'; 
    241 if ( EMPTY_TRASH_DAYS && ( MEDIA_TRASH || !empty($_num_posts['trash']) ) ) 
     240    if ( !empty( $num_posts[$mime_type] ) ) 
     241        $type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>'; 
     242} 
     243$type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>'; 
     244 
     245if ( !empty($_num_posts['trash']) ) 
    242246    $type_links[] = '<li><a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>'; 
    243247 
     
    256260 
    257261<form id="posts-filter" action="" method="get"> 
     262<?php if ( have_posts() || isset( $orphans ) ) { ?> 
    258263<div class="tablenav"> 
    259264<?php 
     
    280285 
    281286<div class="alignleft actions"> 
     287<?php if ( ! isset( $orphans ) || ! empty( $orphans ) ) { ?> 
    282288<select name="action" class="select-action"> 
    283289<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
     
    329335<?php } // ! is_singular ?> 
    330336 
    331 <?php if ( isset($_GET['detached']) ) { ?> 
     337<?php 
     338 
     339} // ! empty( $orphans ) 
     340 
     341if ( isset($_GET['detached']) ) { ?> 
    332342    <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 
    333343<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?> 
     
    340350</div> 
    341351 
     352<?php } // have_posts() || !empty( $orphans ) ?> 
     353 
    342354<div class="clear"></div> 
    343355 
    344 <?php if ( isset($orphans) ) { ?> 
     356<?php if ( ! empty( $orphans ) ) { ?> 
    345357<table class="widefat" cellspacing="0"> 
    346358<thead> 
     
    366378<tbody id="the-list" class="list:post"> 
    367379<?php 
    368     if ( $orphans ) { 
    369380        foreach ( $orphans as $post ) { 
    370381            $class = 'alternate' == $class ? '' : 'alternate'; 
     
    424435        <td class="date column-date"><?php echo $h_time ?></td> 
    425436    </tr> 
    426 <?php   } 
    427  
    428     } else { ?> 
    429     <tr><td colspan="5"><?php _e('No media attachments found.') ?></td></tr> 
    430 <?php } ?> 
     437<?php   } ?> 
    431438</tbody> 
    432439</table> 
     
    443450 
    444451<?php 
     452if ( have_posts() || ! empty( $orphans ) ) { 
     453 
    445454if ( $page_links ) 
    446455    echo "<div class='tablenav-pages'>$page_links_text</div>"; 
     
    467476</div> 
    468477 
     478<?php } ?> 
    469479<br class="clear" /> 
    470480</div> 
Note: See TracChangeset for help on using the changeset viewer.