Make WordPress Core

Ticket #16891: 16891.2.diff

File 16891.2.diff, 3.4 KB (added by kawauso, 13 years ago)

Refreshed against [20375]

  • wp-admin/includes/media.php

     
    3333 * @return unknown
    3434 */
    3535function update_gallery_tab($tabs) {
     36        static $attachments;
    3637        global $wpdb;
    3738
    3839        if ( !isset($_REQUEST['post_id']) ) {
     
    4243
    4344        $post_id = intval($_REQUEST['post_id']);
    4445
    45         if ( $post_id )
     46        if ( $post_id && is_null( $attachments ) )
    4647                $attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
    4748
    4849        if ( empty($attachments) ) {
     
    10601061 * @return string HTML form for attachment.
    10611062 */
    10621063function get_media_item( $attachment_id, $args = null ) {
    1063         global $redir_tab;
     1064        global $redir_tab, $tab;
    10641065
    10651066        if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
    10661067                $thumb_url = $thumb_url[0];
     
    11731174        if ( $send )
    11741175                $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );
    11751176        if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
     1177                $wp_redirect = empty( $redir_tab ) || $redir_tab == $tab ? '' : '&_wp_http_referer=' . urlencode(add_query_arg('tab', $redir_tab));
    11761178                if ( !EMPTY_TRASH_DAYS ) {
    1177                         $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>';
     1179                        $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post={$attachment_id}{$wp_redirect}", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>';
    11781180                } elseif ( !MEDIA_TRASH ) {
    11791181                        $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a>
    11801182                         <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p>
    1181                          <a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>
     1183                         <a href='" . wp_nonce_url( "post.php?action=delete&amp;post={$attachment_id}{$wp_redirect}", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>
    11821184                         <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a>
    11831185                         </div>";
    11841186                } else {
    1185                         $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>
     1187                        $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post={$attachment_id}{$wp_redirect}", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>
    11861188                        <a href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>";
    11871189                }
    11881190        } else {