WordPress.org

Make WordPress Core

Ticket #16891: 16891.patch

File 16891.patch, 3.5 KB (added by hakre, 3 years ago)

Reviewed Patch

  • wp-admin/includes/media.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk
     
    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) ) { 
     
    11711172 * @return string HTML form for attachment. 
    11721173 */ 
    11731174function get_media_item( $attachment_id, $args = null ) { 
    1174         global $redir_tab; 
     1175        global $redir_tab, $tab; 
    11751176 
    11761177        if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) 
    11771178                $thumb_url = $thumb_url[0]; 
     
    12851286        if ( $send ) 
    12861287                $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 
    12871288        if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { 
     1289                $wp_redirect = empty( $redir_tab ) || $redir_tab == $tab ? '' : '&_wp_http_referer=' . urlencode(add_query_arg('tab', $redir_tab)); 
    12881290                if ( !EMPTY_TRASH_DAYS ) { 
    1289                         $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>'; 
     1291                        $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>'; 
    12901292                } elseif ( !MEDIA_TRASH ) { 
    12911293                        $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 
    12921294                         <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " 
    1293                          <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> 
     1295                         <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> 
    12941296                         <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 
    12951297                         </div>"; 
    12961298                } else { 
    1297                         $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> 
     1299                        $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> 
    12981300                        <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>"; 
    12991301                } 
    13001302        } else {