Disable trash for attachments for now pending improvements in 3.0, fixes #11149

git-svn-id: https://develop.svn.wordpress.org/trunk@12377 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2009-12-12 06:40:16 +00:00
parent ee79c9e7d0
commit 770fd776d7
7 changed files with 26 additions and 11 deletions

View File

@ -94,9 +94,9 @@ foreach ($posts_columns as $column_name => $column_display_name ) {
if ( current_user_can('delete_post', $post->ID) ) {
if ( $is_trash )
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
elseif ( EMPTY_TRASH_DAYS )
elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
if ( $is_trash || !EMPTY_TRASH_DAYS )
if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH )
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
}
if ( !$is_trash )

View File

@ -1230,10 +1230,13 @@ function get_media_item( $attachment_id, $args = null ) {
if ( $send )
$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
if ( $delete && current_user_can('delete_post', $attachment_id) ) {
if ( !EMPTY_TRASH_DAYS )
if ( !EMPTY_TRASH_DAYS ) {
$delete = "<a href=\"" . wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Delete Permanently') . "</a>";
else
} elseif ( !MEDIA_TRASH ) {
$delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a> <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"" . wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"button\">" . __('Continue') . "</a> <a href=\"#\" class=\"button\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div>";
} else {
$delete = "<a href=\"" . wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a> <a href=\"" . wp_nonce_url("post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_' . $attachment_id) . "\" id=\"undo[$attachment_id]\" class=\"undo hidden\">" . __('Undo') . "</a>";
}
} else {
$delete = '';
}

View File

@ -231,11 +231,13 @@ case 'delete':
if ( !current_user_can('delete_post', $post_id) )
wp_die( __('You are not allowed to delete this post.') );
$force = !EMPTY_TRASH_DAYS;
if ( $post->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
$force = ( $force || !MEDIA_TRASH );
if ( ! wp_delete_attachment($post_id, $force) )
wp_die( __('Error in deleting...') );
} else {
if ( !wp_delete_post($post_id) )
if ( !wp_delete_post($post_id, $force) )
wp_die( __('Error in deleting...') );
}

View File

@ -243,7 +243,7 @@ foreach ( $post_mime_types as $mime_type => $label ) {
$type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
}
$type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>';
if ( EMPTY_TRASH_DAYS )
if ( EMPTY_TRASH_DAYS && ( MEDIA_TRASH || !empty($_num_posts['trash']) ) )
$type_links[] = '<li><a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
echo implode( " |</li>\n", $type_links) . '</li>';
@ -288,7 +288,7 @@ if ( $page_links ) : ?>
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
<?php if ( $is_trash ) { ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
<?php } else { ?>
<option value="trash"><?php _e('Move to Trash'); ?></option>
@ -392,7 +392,7 @@ foreach ($arc_result as $arc_row) {
if ( current_user_can('edit_post', $post->ID) )
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
if ( current_user_can('delete_post', $post->ID) )
if ( EMPTY_TRASH_DAYS )
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
else
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
@ -454,7 +454,7 @@ if ( $page_links )
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
<?php if ($is_trash) { ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
<?php } else { ?>
<option value="trash"><?php _e('Move to Trash'); ?></option>

File diff suppressed because one or more lines are too long

View File

@ -3619,3 +3619,7 @@ span.imgedit-scale-warn {
border-spacing: 3px;
padding: 3px;
}
.describe .del-link {
padding-left: 5px;
}

View File

@ -224,6 +224,12 @@ if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
if ( defined('WP_CACHE') && WP_CACHE )
@include WP_CONTENT_DIR . '/advanced-cache.php';
/**
* Private
*/
if ( !defined('MEDIA_TRASH') )
define('MEDIA_TRASH', false);
/**
* Stores the location of the WordPress directory of functions, classes, and core content.
*