Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload.php

    r12162 r12308  
    6363        }
    6464
    65         $location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location );
     65        $location = add_query_arg( array( 'attached' => $attached ) , $location );
    6666        wp_redirect($location);
    6767        exit;
     
    7777        $post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
    7878        $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    79     } else
     79    } else {
    8080        wp_redirect($_SERVER['HTTP_REFERER']);
     81    }
    8182
    8283    $location = 'upload.php';
    8384    if ( $referer = wp_get_referer() ) {
    8485        if ( false !== strpos($referer, 'upload.php') )
    85             $location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids'), $referer );
     86            $location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer );
    8687    }
    8788
     
    119120    }
    120121
    121     $location = remove_query_arg('posted', $location);
    122122    wp_redirect($location);
    123123    exit;
     
    135135if ( isset($_GET['detached']) ) {
    136136
     137    $media_per_page = (int) get_user_option('upload_per_page');
     138    if ( empty($media_per_page) )
     139        $media_per_page = 20;
     140
    137141    if ( !empty($lost) ) {
    138         $start = ( $_GET['paged'] - 1 ) * 50;
    139         $page_links_total = ceil(count($lost) / 50);
     142        $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
     143        $page_links_total = ceil(count($lost) / $media_per_page);
    140144        $lost = implode(',', $lost);
    141145
    142         $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" );
     146        $orphans = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN (%s) LIMIT %d, %d", $lost, $start, $media_per_page ) );
    143147    } else {
    144         $start = ( $_GET['paged'] - 1 ) * 25;
    145         $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT $start, 25" );
    146         $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
     148        $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
     149        $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 ) );
     150        $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page);
    147151    }
    148152
     
    167171<div class="wrap">
    168172<?php screen_icon(); ?>
    169 <h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="button add-new-h2"><?php esc_html_e('Add New'); ?></a> <?php
     173<h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> <?php
    170174if ( isset($_GET['s']) && $_GET['s'] )
    171175    printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
     
    203207$messages[2] = __('Media permanently deleted.');
    204208$messages[3] = __('Error saving media attachment.');
    205 $messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.$_GET['ids'], "bulk-media" ) ) . '">' . __('Undo?') . '</a>';
     209$messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
    206210$messages[5] = __('Media restored from the trash.');
    207211
     
    305309    if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
    306310<select name='m'>
    307 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
     311<option value='0'><?php _e('Show all dates'); ?></option>
    308312<?php
    309313foreach ($arc_result as $arc_row) {
     
    430434</table>
    431435
    432 <?php find_posts_div();
     436<?php
    433437
    434438} else {
     
    467471<br class="clear" />
    468472</div>
     473<?php find_posts_div(); ?>
    469474</form>
    470475<br class="clear" />
Note: See TracChangeset for help on using the changeset viewer.