Consistently hide bulk actions, filters, and subpage links on admin panels when there are no items to show. Fixes #12086
git-svn-id: https://develop.svn.wordpress.org/trunk@13100 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a5ad001b73
commit
8be6c296b1
@ -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(
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php if ( $comments ) { ?>
|
||||
<?php if ( $page_links ) : ?>
|
||||
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( $start + 1 ),
|
||||
@ -346,7 +347,6 @@ if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php if ( $comments ) { ?>
|
||||
<table class="widefat comments fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -436,7 +436,7 @@ if ( $page_links )
|
||||
</form>
|
||||
|
||||
<?php } else { ?>
|
||||
<p><?php _e('No results found.') ?></p>
|
||||
<p><?php _e('No comments found.') ?></p>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
@ -399,9 +399,9 @@ if ( $page_links )
|
||||
<div class="clear"></div>
|
||||
<p><?php
|
||||
if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] )
|
||||
_e('No posts found in the trash');
|
||||
_e( 'No posts found in the Trash.' );
|
||||
else
|
||||
_e('No posts found');
|
||||
_e( 'No posts found.' );
|
||||
?></p>
|
||||
<?php } ?>
|
||||
|
||||
|
@ -99,6 +99,16 @@ if ( isset($_GET['deleted']) ) {
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
if ( 'all' == $cat_id )
|
||||
$cat_id = '';
|
||||
$args = array( 'category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0 );
|
||||
if ( ! empty( $_GET['s'] ) )
|
||||
$args['search'] = $_GET['s'];
|
||||
$links = get_bookmarks( $args );
|
||||
if ( $links ) {
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
@ -135,13 +145,6 @@ echo $select_order;
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php
|
||||
if ( 'all' == $cat_id )
|
||||
$cat_id = '';
|
||||
$args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
|
||||
if ( !empty($_GET['s']) )
|
||||
$args['search'] = $_GET['s'];
|
||||
$links = get_bookmarks( $args );
|
||||
if ( $links ) {
|
||||
$link_columns = get_column_headers('link-manager');
|
||||
$hidden = get_hidden_columns('link-manager');
|
||||
?>
|
||||
@ -251,10 +254,6 @@ if ( $links ) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php } else { ?>
|
||||
<p><?php _e('No links found.') ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<div class="alignleft actions">
|
||||
@ -265,6 +264,10 @@ if ( $links ) {
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
<p><?php _e( 'No links found.' ) ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
|
@ -633,6 +633,8 @@ unset( $status_links );
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php if ( ! empty( $plugins ) ) { ?>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
@ -656,9 +658,13 @@ if ( $page_links )
|
||||
print_plugin_actions($status, "action2");
|
||||
?>
|
||||
</div>
|
||||
<?php } elseif ( ! empty( $all_plugins ) ) { ?>
|
||||
<p><?php __( 'No plugins found.' ); ?></p>
|
||||
<?php } ?>
|
||||
</form>
|
||||
|
||||
<?php if ( empty($all_plugins) ) : ?>
|
||||
<br class="clear" />
|
||||
<p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -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"';
|
||||
|
||||
if ( !empty( $num_posts[$mime_type] ) )
|
||||
$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>';
|
||||
}
|
||||
$type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>';
|
||||
if ( EMPTY_TRASH_DAYS && ( MEDIA_TRASH || !empty($_num_posts['trash']) ) )
|
||||
$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>';
|
||||
|
||||
if ( !empty($_num_posts['trash']) )
|
||||
$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>';
|
||||
|
||||
echo implode( " |</li>\n", $type_links) . '</li>';
|
||||
@ -255,6 +259,7 @@ unset($type_links);
|
||||
</form>
|
||||
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<?php if ( have_posts() || isset( $orphans ) ) { ?>
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( ! isset($page_links_total) )
|
||||
@ -279,6 +284,7 @@ if ( $page_links ) : ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<?php if ( ! isset( $orphans ) || ! empty( $orphans ) ) { ?>
|
||||
<select name="action" class="select-action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( $is_trash ) { ?>
|
||||
@ -328,7 +334,11 @@ foreach ($arc_result as $arc_row) {
|
||||
|
||||
<?php } // ! is_singular ?>
|
||||
|
||||
<?php if ( isset($_GET['detached']) ) { ?>
|
||||
<?php
|
||||
|
||||
} // ! empty( $orphans )
|
||||
|
||||
if ( isset($_GET['detached']) ) { ?>
|
||||
<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
|
||||
<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
|
||||
<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
@ -339,9 +349,11 @@ foreach ($arc_result as $arc_row) {
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php } // have_posts() || !empty( $orphans ) ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php if ( isset($orphans) ) { ?>
|
||||
<?php if ( ! empty( $orphans ) ) { ?>
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -365,7 +377,6 @@ foreach ($arc_result as $arc_row) {
|
||||
|
||||
<tbody id="the-list" class="list:post">
|
||||
<?php
|
||||
if ( $orphans ) {
|
||||
foreach ( $orphans as $post ) {
|
||||
$class = 'alternate' == $class ? '' : 'alternate';
|
||||
$att_title = esc_html( _draft_or_post_title($post->ID) );
|
||||
@ -423,10 +434,6 @@ foreach ($arc_result as $arc_row) {
|
||||
} ?>
|
||||
<td class="date column-date"><?php echo $h_time ?></td>
|
||||
</tr>
|
||||
<?php }
|
||||
|
||||
} else { ?>
|
||||
<tr><td colspan="5"><?php _e('No media attachments found.') ?></td></tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -442,6 +449,8 @@ foreach ($arc_result as $arc_row) {
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
if ( have_posts() || ! empty( $orphans ) ) {
|
||||
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
@ -466,6 +475,7 @@ if ( $page_links )
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php find_posts_div(); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user