Skip to content

Commit

Permalink
Disable trash for attachments for now pending improvements in 3.0, fi…
Browse files Browse the repository at this point in the history
…xes #11149

git-svn-id: http://svn.automattic.com/wordpress/trunk@12377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
azaozz committed Dec 12, 2009
1 parent a8686bb commit d4d309a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions wp-admin/edit-attachment-rows.php
Expand Up @@ -94,9 +94,9 @@
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 )
Expand Down
7 changes: 5 additions & 2 deletions wp-admin/includes/media.php
Expand Up @@ -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 = '';
}
Expand Down
6 changes: 4 additions & 2 deletions wp-admin/post.php
Expand Up @@ -231,11 +231,13 @@ function redirect_post($post_ID = '') {
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...') );
}

Expand Down
8 changes: 4 additions & 4 deletions wp-admin/upload.php
Expand Up @@ -243,7 +243,7 @@
$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>';
Expand Down Expand Up @@ -288,7 +288,7 @@
<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>
Expand Down Expand Up @@ -392,7 +392,7 @@
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>";
Expand Down Expand Up @@ -454,7 +454,7 @@
<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>
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/wp-admin.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions wp-admin/wp-admin.dev.css
Expand Up @@ -3619,3 +3619,7 @@ span.imgedit-scale-warn {
border-spacing: 3px;
padding: 3px;
}

.describe .del-link {
padding-left: 5px;
}
6 changes: 6 additions & 0 deletions wp-settings.php
Expand Up @@ -224,6 +224,12 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
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.
*
Expand Down

0 comments on commit d4d309a

Please sign in to comment.