Changeset 13100 for trunk/wp-admin/upload.php
- Timestamp:
- 02/13/2010 08:49:27 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/upload.php
r12972 r13100 144 144 $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page; 145 145 $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 ); 147 148 } 148 149 … … 220 221 $_num_posts = (array) wp_count_attachments(); 221 222 $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 223 if ( !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" ); 222 225 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 223 226 foreach ( $matches as $type => $reals ) … … 235 238 if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) 236 239 $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 245 if ( !empty($_num_posts['trash']) ) 242 246 $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>'; 243 247 … … 256 260 257 261 <form id="posts-filter" action="" method="get"> 262 <?php if ( have_posts() || isset( $orphans ) ) { ?> 258 263 <div class="tablenav"> 259 264 <?php … … 280 285 281 286 <div class="alignleft actions"> 287 <?php if ( ! isset( $orphans ) || ! empty( $orphans ) ) { ?> 282 288 <select name="action" class="select-action"> 283 289 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> … … 329 335 <?php } // ! is_singular ?> 330 336 331 <?php if ( isset($_GET['detached']) ) { ?> 337 <?php 338 339 } // ! empty( $orphans ) 340 341 if ( isset($_GET['detached']) ) { ?> 332 342 <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 333 343 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?> … … 340 350 </div> 341 351 352 <?php } // have_posts() || !empty( $orphans ) ?> 353 342 354 <div class="clear"></div> 343 355 344 <?php if ( isset($orphans) ) { ?>356 <?php if ( ! empty( $orphans ) ) { ?> 345 357 <table class="widefat" cellspacing="0"> 346 358 <thead> … … 366 378 <tbody id="the-list" class="list:post"> 367 379 <?php 368 if ( $orphans ) {369 380 foreach ( $orphans as $post ) { 370 381 $class = 'alternate' == $class ? '' : 'alternate'; … … 424 435 <td class="date column-date"><?php echo $h_time ?></td> 425 436 </tr> 426 <?php } 427 428 } else { ?> 429 <tr><td colspan="5"><?php _e('No media attachments found.') ?></td></tr> 430 <?php } ?> 437 <?php } ?> 431 438 </tbody> 432 439 </table> … … 443 450 444 451 <?php 452 if ( have_posts() || ! empty( $orphans ) ) { 453 445 454 if ( $page_links ) 446 455 echo "<div class='tablenav-pages'>$page_links_text</div>"; … … 467 476 </div> 468 477 478 <?php } ?> 469 479 <br class="clear" /> 470 480 </div>
Note: See TracChangeset
for help on using the changeset viewer.