### Eclipse Workspace Patch 1.0
#P wordpress-trunk
|
|
|
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) ) { |
… |
… |
|
1171 | 1172 | * @return string HTML form for attachment. |
1172 | 1173 | */ |
1173 | 1174 | function get_media_item( $attachment_id, $args = null ) { |
1174 | | global $redir_tab; |
| 1175 | global $redir_tab, $tab; |
1175 | 1176 | |
1176 | 1177 | if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) |
1177 | 1178 | $thumb_url = $thumb_url[0]; |
… |
… |
|
1285 | 1286 | if ( $send ) |
1286 | 1287 | $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
1287 | 1288 | 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)); |
1288 | 1290 | if ( !EMPTY_TRASH_DAYS ) { |
1289 | | $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>'; |
| 1291 | $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>'; |
1290 | 1292 | } elseif ( !MEDIA_TRASH ) { |
1291 | 1293 | $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
1292 | 1294 | <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&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&post={$attachment_id}{$wp_redirect}", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
1294 | 1296 | <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
1295 | 1297 | </div>"; |
1296 | 1298 | } else { |
1297 | | $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> |
| 1299 | $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> |
1298 | 1300 | <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>"; |
1299 | 1301 | } |
1300 | 1302 | } else { |