Ticket #4529: trash-fixes.diff
File trash-fixes.diff, 13.0 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
1264 1264 1265 1265 do_action('untrash_post', $postid); 1266 1266 1267 $post['post_status'] = 'draft';1267 $post['post_status'] = ($post->post_type == 'attachment') ? 'inherit' : 'draft'; 1268 1268 1269 1269 $trash_meta = get_option('wp_trash_meta'); 1270 1270 if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { -
wp-includes/js/swfupload/handlers.dev.js
78 78 // Tell the server to delete it. TODO: handle exceptions 79 79 jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{ 80 80 id : this.id.replace(/[^0-9]/g,''), 81 action : ' delete-post',81 action : 'trash-post', 82 82 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')} 83 83 }); 84 84 return false; -
wp-includes/capabilities.php
775 775 // If the post is published... 776 776 if ( 'publish' == $post->post_status ) 777 777 $caps[] = 'delete_published_posts'; 778 elseif ( 'trash' == $post->post_status ) { 779 $trash_meta = get_option('wp_trash_meta'); 780 if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish') 781 $caps[] = 'delete_published_posts'; 782 } 778 783 else 779 784 // If the post is draft... 780 785 $caps[] = 'delete_posts'; … … 799 804 // If the page is published... 800 805 if ( $page->post_status == 'publish' ) 801 806 $caps[] = 'delete_published_pages'; 807 elseif ( 'trash' == $page->post_status ) { 808 $trash_meta = get_option('wp_trash_meta'); 809 if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish') 810 $caps[] = 'delete_published_pages'; 811 } 802 812 else 803 813 // If the page is draft... 804 814 $caps[] = 'delete_pages'; … … 829 839 // If the post is published... 830 840 if ( 'publish' == $post->post_status ) 831 841 $caps[] = 'edit_published_posts'; 842 elseif ( 'trash' == $post->post_status ) { 843 $trash_meta = get_option('wp_trash_meta'); 844 if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish') 845 $caps[] = 'edit_published_posts'; 846 } 832 847 else 833 848 // If the post is draft... 834 849 $caps[] = 'edit_posts'; … … 853 868 // If the page is published... 854 869 if ( 'publish' == $page->post_status ) 855 870 $caps[] = 'edit_published_pages'; 871 elseif ( 'trash' == $page->post_status ) { 872 $trash_meta = get_option('wp_trash_meta'); 873 if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish') 874 $caps[] = 'edit_published_pages'; 875 } 856 876 else 857 877 // If the page is draft... 858 878 $caps[] = 'edit_pages'; -
wp-admin/edit-comments.php
303 303 304 304 if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) { 305 305 wp_nonce_field('bulk-destroy', '_destroy_nonce'); 306 if ( 'spam' == $comment_status ) { ?>306 if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?> 307 307 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 308 308 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?> 309 309 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> … … 375 375 </select> 376 376 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> 377 377 378 <?php if ( 'spam' == $comment_status ) { ?>378 <?php if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?> 379 379 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 380 380 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?> 381 381 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> -
wp-admin/admin-ajax.php
312 312 else 313 313 die('0'); 314 314 break; 315 case 'trash-post' : 316 check_ajax_referer( "{$action}_$id" ); 317 if ( !current_user_can( 'delete_post', $id ) ) 318 die('-1'); 319 320 if ( !get_post( $id ) ) 321 die('1'); 322 323 if ( wp_trash_post( $id ) ) 324 die('1'); 325 else 326 die('0'); 327 break; 315 328 case 'delete-page' : 316 329 check_ajax_referer( "{$action}_$id" ); 317 330 if ( !current_user_can( 'delete_page', $id ) ) -
wp-admin/includes/template.php
1439 1439 the_excerpt(); 1440 1440 1441 1441 $actions = array(); 1442 if ( 'trash' == $post->post_status && current_user_can('delete_post', $post->ID) ) { 1443 $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>"; 1444 $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>"; 1442 if ('trash' == $post->post_status) { 1443 if (current_user_can('delete_post', $post->ID)) { 1444 $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>"; 1445 $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>"; 1446 } 1445 1447 } else { 1446 1448 if ( current_user_can('edit_post', $post->ID) ) { 1447 1449 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; -
wp-admin/includes/media.php
1062 1062 } 1063 1063 1064 1064 $output = ''; 1065 foreach ( (array) $attachments as $id => $attachment ) 1065 foreach ( (array) $attachments as $id => $attachment ) { 1066 if ( $attachment->post_status == 'trash' ) 1067 continue; 1066 1068 if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) 1067 1069 $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>"; 1070 } 1068 1071 1069 1072 return $output; 1070 1073 } … … 1166 1169 'extra_rows' => array(), 1167 1170 ); 1168 1171 1169 $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", ' delete-post_' . $attachment_id);1172 $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id); 1170 1173 if ( $send ) 1171 1174 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; 1172 1175 if ( $delete ) 1173 $delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>";1176 $delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : ""; 1174 1177 if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) 1175 1178 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n"); 1176 1179 -
wp-admin/edit-attachment-rows.php
59 59 60 60 case 'cb': 61 61 ?> 62 <th scope="row" class="check-column">< input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>62 <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> 63 63 <?php 64 64 break; 65 65 … … 89 89 <p> 90 90 <?php 91 91 $actions = array(); 92 if ( $is_trash && current_user_can('delete_post', $post->ID) ) { 93 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; 94 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 92 if ($is_trash) { 93 if (current_user_can('delete_post', $post->ID)) { 94 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; 95 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 96 } 95 97 } else { 96 98 if ( current_user_can('edit_post', $post->ID) ) 97 99 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; -
wp-admin/upload.php
321 321 322 322 <?php if ( isset($_GET['detached']) ) { ?> 323 323 <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 324 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>324 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts')) { ?> 325 325 <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 326 326 <?php } ?> 327 327 … … 362 362 $att_title = esc_html( _draft_or_post_title($post->ID) ); 363 363 ?> 364 364 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top"> 365 <th scope="row" class="check-column">< input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /></th>365 <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> 366 366 367 367 <td class="media-icon"><?php 368 368 if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?> … … 446 446 </select> 447 447 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 448 448 449 <?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>449 <?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts')) { ?> 450 450 <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 451 451 <?php } ?> 452 452 </div> -
wp-admin/edit-form-comment.php
68 68 69 69 <div id="major-publishing-actions"> 70 70 <div id="delete-action"> 71 <?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"; ?>71 <?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"; ?> 72 72 </div> 73 73 <div id="publishing-action"> 74 74 <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />