"Trash" updates, props caesarsgrunt, see #4529
git-svn-id: http://svn.automattic.com/wordpress/trunk@11841 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4c13a5acf4
commit
be026258fa
|
@ -312,6 +312,19 @@ case 'delete-post' :
|
|||
else
|
||||
die('0');
|
||||
break;
|
||||
case 'trash-post' :
|
||||
check_ajax_referer( "{$action}_$id" );
|
||||
if ( !current_user_can( 'delete_post', $id ) )
|
||||
die('-1');
|
||||
|
||||
if ( !get_post( $id ) )
|
||||
die('1');
|
||||
|
||||
if ( wp_trash_post( $id ) )
|
||||
die('1');
|
||||
else
|
||||
die('0');
|
||||
break;
|
||||
case 'delete-page' :
|
||||
check_ajax_referer( "{$action}_$id" );
|
||||
if ( !current_user_can( 'delete_page', $id ) )
|
||||
|
|
|
@ -59,7 +59,7 @@ foreach ($posts_columns as $column_name => $column_display_name ) {
|
|||
|
||||
case 'cb':
|
||||
?>
|
||||
<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
|
||||
<th scope="row" class="check-column"><?php if ( current_user_can('edit_post', $post->ID) ) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th>
|
||||
<?php
|
||||
break;
|
||||
|
||||
|
@ -89,9 +89,11 @@ foreach ($posts_columns as $column_name => $column_display_name ) {
|
|||
<p>
|
||||
<?php
|
||||
$actions = array();
|
||||
if ( $is_trash && current_user_can('delete_post', $post->ID) ) {
|
||||
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
if ( $is_trash ) {
|
||||
if ( current_user_can('delete_post', $post->ID) ) {
|
||||
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
} else {
|
||||
if ( current_user_can('edit_post', $post->ID) )
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
|
||||
|
|
|
@ -303,7 +303,7 @@ $page_links = paginate_links( array(
|
|||
|
||||
if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) {
|
||||
wp_nonce_field('bulk-destroy', '_destroy_nonce');
|
||||
if ( 'spam' == $comment_status ) { ?>
|
||||
if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
|
@ -375,7 +375,7 @@ if ( $page_links )
|
|||
</select>
|
||||
<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
|
||||
<?php if ( 'spam' == $comment_status ) { ?>
|
||||
<?php if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
|
|
|
@ -68,7 +68,7 @@ $date = date_i18n( $datef, strtotime( $comment->comment_date ) );
|
|||
|
||||
<div id="major-publishing-actions">
|
||||
<div id="delete-action">
|
||||
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&c=$comment->comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
|
||||
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=trashcomment&c=$comment->comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'trash-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
|
||||
</div>
|
||||
<div id="publishing-action">
|
||||
<input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />
|
||||
|
|
|
@ -1062,9 +1062,12 @@ function get_media_items( $post_id, $errors ) {
|
|||
}
|
||||
|
||||
$output = '';
|
||||
foreach ( (array) $attachments as $id => $attachment )
|
||||
foreach ( (array) $attachments as $id => $attachment ) {
|
||||
if ( $attachment->post_status == 'trash' )
|
||||
continue;
|
||||
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
|
||||
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -1166,11 +1169,11 @@ function get_media_item( $attachment_id, $args = null ) {
|
|||
'extra_rows' => array(),
|
||||
);
|
||||
|
||||
$delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'delete-post_' . $attachment_id);
|
||||
$delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id);
|
||||
if ( $send )
|
||||
$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
|
||||
if ( $delete )
|
||||
$delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>";
|
||||
$delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : "";
|
||||
if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
|
||||
$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n");
|
||||
|
||||
|
|
|
@ -1439,9 +1439,11 @@ function _post_row($a_post, $pending_comments, $mode) {
|
|||
the_excerpt();
|
||||
|
||||
$actions = array();
|
||||
if ( 'trash' == $post->post_status && current_user_can('delete_post', $post->ID) ) {
|
||||
$actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
if ('trash' == $post->post_status) {
|
||||
if ( current_user_can('delete_post', $post->ID) ) {
|
||||
$actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
} else {
|
||||
if ( current_user_can('edit_post', $post->ID) ) {
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
|
||||
|
|
|
@ -321,7 +321,7 @@ foreach ($arc_result as $arc_row) {
|
|||
|
||||
<?php if ( isset($_GET['detached']) ) { ?>
|
||||
<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
|
||||
<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
|
||||
<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
|
||||
<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
|
||||
|
@ -362,7 +362,7 @@ foreach ($arc_result as $arc_row) {
|
|||
$att_title = esc_html( _draft_or_post_title($post->ID) );
|
||||
?>
|
||||
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
|
||||
<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /></th>
|
||||
<th scope="row" class="check-column"><?php if ( current_user_can('edit_post', $post->ID) ) { ?><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /><?php } ?></th>
|
||||
|
||||
<td class="media-icon"><?php
|
||||
if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
|
||||
|
@ -446,7 +446,7 @@ if ( $page_links )
|
|||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
|
||||
<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
|
||||
<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
|
||||
<input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
|
|
@ -827,11 +827,16 @@ function map_meta_cap( $cap, $user_id ) {
|
|||
// If the user is the author...
|
||||
if ( $user_id == $post_author_data->ID ) {
|
||||
// If the post is published...
|
||||
if ( 'publish' == $post->post_status )
|
||||
if ( 'publish' == $post->post_status ) {
|
||||
$caps[] = 'edit_published_posts';
|
||||
else
|
||||
} elseif ( 'trash' == $post->post_status ) {
|
||||
$trash_meta = get_option('wp_trash_meta');
|
||||
if ( is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish' )
|
||||
$caps[] = 'edit_published_posts';
|
||||
} else {
|
||||
// If the post is draft...
|
||||
$caps[] = 'edit_posts';
|
||||
}
|
||||
} else {
|
||||
// The user is trying to edit someone else's post.
|
||||
$caps[] = 'edit_others_posts';
|
||||
|
@ -851,11 +856,16 @@ function map_meta_cap( $cap, $user_id ) {
|
|||
// If the user is the author...
|
||||
if ( $user_id == $page_author_data->ID ) {
|
||||
// If the page is published...
|
||||
if ( 'publish' == $page->post_status )
|
||||
if ( 'publish' == $page->post_status ) {
|
||||
$caps[] = 'edit_published_pages';
|
||||
else
|
||||
} elseif ( 'trash' == $page->post_status ) {
|
||||
$trash_meta = get_option('wp_trash_meta');
|
||||
if ( is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish' )
|
||||
$caps[] = 'edit_published_pages';
|
||||
} else {
|
||||
// If the page is draft...
|
||||
$caps[] = 'edit_pages';
|
||||
}
|
||||
} else {
|
||||
// The user is trying to edit someone else's page.
|
||||
$caps[] = 'edit_others_pages';
|
||||
|
|
|
@ -78,7 +78,7 @@ function prepareMediaItemInit(fileObj) {
|
|||
// Tell the server to delete it. TODO: handle exceptions
|
||||
jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
|
||||
id : this.id.replace(/[^0-9]/g,''),
|
||||
action : 'delete-post',
|
||||
action : 'trash-post',
|
||||
_ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
|
||||
});
|
||||
return false;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1264,7 +1264,7 @@ function wp_untrash_post($postid = 0) {
|
|||
|
||||
do_action('untrash_post', $postid);
|
||||
|
||||
$post['post_status'] = 'draft';
|
||||
$post['post_status'] = ($post->post_type == 'attachment') ? 'inherit' : 'draft';
|
||||
|
||||
$trash_meta = get_option('wp_trash_meta');
|
||||
if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) {
|
||||
|
|
|
@ -186,7 +186,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
|
||||
}
|
||||
|
||||
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20090515');
|
||||
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20090818');
|
||||
// these error messages came from the sample swfupload js, they might need changing.
|
||||
$scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
||||
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
|
||||
|
|
Loading…
Reference in New Issue