Ticket #16891: 16891.2.diff
File 16891.2.diff, 3.4 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/media.php
33 33 * @return unknown 34 34 */ 35 35 function update_gallery_tab($tabs) { 36 static $attachments; 36 37 global $wpdb; 37 38 38 39 if ( !isset($_REQUEST['post_id']) ) { … … 42 43 43 44 $post_id = intval($_REQUEST['post_id']); 44 45 45 if ( $post_id )46 if ( $post_id && is_null( $attachments ) ) 46 47 $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 ) ) ); 47 48 48 49 if ( empty($attachments) ) { … … 1060 1061 * @return string HTML form for attachment. 1061 1062 */ 1062 1063 function get_media_item( $attachment_id, $args = null ) { 1063 global $redir_tab ;1064 global $redir_tab, $tab; 1064 1065 1065 1066 if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) 1066 1067 $thumb_url = $thumb_url[0]; … … 1173 1174 if ( $send ) 1174 1175 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 1175 1176 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)); 1176 1178 if ( !EMPTY_TRASH_DAYS ) { 1177 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&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&post={$attachment_id}{$wp_redirect}", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; 1178 1180 } elseif ( !MEDIA_TRASH ) { 1179 1181 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 1180 1182 <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&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&post={$attachment_id}{$wp_redirect}", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> 1182 1184 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 1183 1185 </div>"; 1184 1186 } else { 1185 $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&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&post={$attachment_id}{$wp_redirect}", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> 1186 1188 <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; 1187 1189 } 1188 1190 } else {