Ticket #4529: delete-post.4.diff
| File delete-post.4.diff, 59.6 KB (added by caesarsgrunt, 3 years ago) |
|---|
-
wp-includes/post.php
998 998 999 999 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 1000 1000 1001 $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0 );1001 $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'deleted' => 0 ); 1002 1002 foreach( (array) $count as $row_num => $row ) { 1003 1003 $stats[$row['post_status']] = $row['num_posts']; 1004 1004 } … … 1027 1027 global $wpdb; 1028 1028 1029 1029 $and = wp_post_mime_type_where( $mime_type ); 1030 $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' $and GROUP BY post_mime_type", ARRAY_A );1030 $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'deleted' $and GROUP BY post_mime_type", ARRAY_A ); 1031 1031 1032 1032 $stats = array( ); 1033 1033 foreach( (array) $count as $row ) { 1034 1034 $stats[$row['post_mime_type']] = $row['num_posts']; 1035 1035 } 1036 $stats['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'deleted' $and"); 1036 1037 1037 1038 return (object) $stats; 1038 1039 } … … 1140 1141 if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 1141 1142 return $post; 1142 1143 1143 if ( 'attachment' == $post->post_type ) 1144 if (($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'deleted') { 1145 wp_update_post(array('ID'=>$postid, 'post_status'=>'deleted')); 1146 wp_schedule_post_delete($postid); 1147 return true; 1148 } 1149 else if ($post->post_type == 'attachment') 1144 1150 return wp_delete_attachment($postid); 1145 1151 1146 1152 do_action('delete_post', $postid); 1153 1154 wp_unschedule_post_delete($postid); 1147 1155 1148 1156 /** @todo delete for pluggable post taxonomies too */ 1149 1157 wp_delete_object_term_relationships($postid, array('category', 'post_tag')); … … 1205 1213 } 1206 1214 1207 1215 /** 1216 * Removes a post or page from the Trash 1217 * 1218 * @since 2.9.0 1219 * @uses do_action() on 'undelete_post' before deletion 1220 * @uses do_action() on 'undeleted_post' after deletion 1221 * 1222 * @param int $postid Post ID. 1223 * @return mixed False on failure 1224 */ 1225 function wp_undelete_post($postid = 0) { 1226 global $wpdb, $wp_rewrite; 1227 1228 if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 1229 return $post; 1230 1231 do_action('undelete_post', $postid); 1232 1233 wp_update_post(array('ID'=>$postid, 'post_status'=>'draft')); 1234 1235 wp_unschedule_post_delete($postid); 1236 1237 do_action('undeleted_post', $postid); 1238 1239 return $post; 1240 } 1241 1242 /** 1243 * Schedules a post for permanent deletion. 1244 * 1245 * @since 2.9.0 1246 * 1247 * @param int $post_id Post ID. 1248 * @return void 1249 */ 1250 function wp_schedule_post_delete($post_id) { 1251 $to_delete = get_option('wp_scheduled_delete'); 1252 if (!is_array($to_delete)) 1253 $to_delete = array(); 1254 1255 $to_delete['posts'][$post_id] = time(); 1256 1257 update_option('wp_scheduled_delete', $to_delete); 1258 } 1259 1260 /** 1261 * Unschedules a post for permanent deletion. 1262 * 1263 * @since 2.9.0 1264 * 1265 * @param int $post_id Post ID. 1266 * @return void 1267 */ 1268 function wp_unschedule_post_delete($post_id) { 1269 $to_delete = get_option('wp_scheduled_delete'); 1270 if (!is_array($to_delete)) 1271 return; 1272 1273 unset($to_delete['posts'][$post_id]); 1274 1275 update_option('wp_scheduled_delete', $to_delete); 1276 } 1277 1278 /** 1208 1279 * Retrieve the list of categories for a post. 1209 1280 * 1210 1281 * Compatibility layer for themes and plugins. Also an easy layer of abstraction … … 2586 2657 2587 2658 if ( 'attachment' != $post->post_type ) 2588 2659 return false; 2660 elseif (get_post_status($postid) != 'deleted') { 2661 $post = wp_get_single_post($postid, ARRAY_A); 2662 $post['post_status'] = 'deleted'; 2663 wp_insert_post($post); 2664 wp_schedule_post_delete($postid); 2665 return true; 2666 } 2589 2667 2590 2668 $meta = wp_get_attachment_metadata( $postid ); 2591 2669 $file = get_attached_file( $postid ); … … 2632 2710 } 2633 2711 2634 2712 /** 2713 * Removes an attachment from the Trash 2714 * 2715 * @since 2.9.0 2716 * @uses do_action() on 'undelete_attachment' before deletion 2717 * @uses do_action() on 'undeleted_attachment' after deletion 2718 * 2719 * @param int $postid Post ID. 2720 * @return mixed False on failure 2721 */ 2722 function wp_undelete_attachment($postid = 0) { 2723 global $wpdb, $wp_rewrite; 2724 2725 if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 2726 return $post; 2727 2728 do_action('undelete_attachment', $postid); 2729 2730 $post = wp_get_single_post($postid, ARRAY_A); 2731 $post['post_status'] = 'inherit'; 2732 wp_insert_post($post); 2733 2734 wp_unschedule_post_delete($postid); 2735 2736 do_action('undeleted_attachment', $postid); 2737 2738 return $post; 2739 } 2740 2741 /** 2635 2742 * Retrieve attachment meta field for attachment ID. 2636 2743 * 2637 2744 * @since 2.1.0 -
wp-includes/comment.php
694 694 if ( false !== $count ) 695 695 return $count; 696 696 697 $where = ' ';697 $where = 'WHERE '; 698 698 if( $post_id > 0 ) 699 $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id ); 699 $where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id ); 700 $where .= "p.post_status <> 'deleted'"; 700 701 701 $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );702 $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} c LEFT JOIN {$wpdb->posts} p ON c.comment_post_ID = p.ID {$where} GROUP BY comment_approved", ARRAY_A ); 702 703 703 704 $total = 0; 704 705 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted'); … … 1084 1085 } 1085 1086 1086 1087 /** 1087 * Schedules a comment for destruction in 30 days.1088 * Schedules a comment for permanent deletion. 1088 1089 * 1089 1090 * @since 2.9.0 1090 1091 * … … 1102 1103 } 1103 1104 1104 1105 /** 1105 * Unschedules a comment for destruction.1106 * Unschedules a comment for permanent deletion. 1106 1107 * 1107 1108 * @since 2.9.0 1108 1109 * -
wp-includes/functions.php
3339 3339 } 3340 3340 3341 3341 /** 3342 * Permanently deletes comments that have been scheduled for deleting. 3343 * Will do the same for posts, pages, etc in the future. 3342 * Permanently deletes posts, pages, and comments that have been scheduled for deleting. 3344 3343 * 3345 * @access private3346 3344 * @since 2.9.0 3347 3345 * 3348 3346 * @return void … … 3355 3353 if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) ) 3356 3354 $to_delete['comments'] = array(); 3357 3355 3358 $delete_d elay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);3359 $deletetimestamp = time() - $delete_delay;3356 $delete_days = defined('EMPTY_TRASH_DAYS') ? (int) EMPTY_TRASH_DAYS : 30; 3357 $deletetimestamp = time() - (60*60*24*$delete_days); 3360 3358 foreach ($to_delete['comments'] as $comment_id => $timestamp) { 3361 3359 if ($timestamp < $deletetimestamp) { 3362 3360 wp_delete_comment($comment_id); 3363 3361 unset($to_delete['comments'][$comment_id]); 3364 3362 } 3365 3363 } 3364 foreach ($to_delete['posts'] as $post_id => $timestamp) { 3365 if ($timestamp < $deletetimestamp) { 3366 wp_delete_post($post_id); 3367 unset($to_delete['posts'][$post_id]); 3368 } 3369 } 3366 3370 3367 3371 update_option('wp_scheduled_delete', $to_delete); 3368 3372 } -
wp-includes/query.php
2099 2099 $p_status[] = "$wpdb->posts.post_status = 'private'"; 2100 2100 if ( in_array( 'publish', $q_status ) ) 2101 2101 $r_status[] = "$wpdb->posts.post_status = 'publish'"; 2102 if ( in_array( 'deleted', $q_status ) ) 2103 $r_status[] = "$wpdb->posts.post_status = 'deleted'"; 2102 2104 2103 2105 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 2104 2106 $r_status = array_merge($r_status, $p_status); -
wp-admin/edit-comments.php
292 292 if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) { 293 293 wp_nonce_field('bulk-destroy', '_destroy_nonce'); 294 294 if ( 'spam' == $comment_status ) { ?> 295 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e(' Permanently Delete All'); ?>" class="button-secondary apply" />295 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 296 296 <?php } elseif ( 'deleted' == $comment_status ) { ?> 297 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button- primary apply" />297 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 298 298 <?php } 299 299 } ?> 300 300 <?php do_action('manage_comments_nav', $comment_status); ?> … … 364 364 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> 365 365 366 366 <?php if ( 'spam' == $comment_status ) { ?> 367 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />367 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 368 368 <?php } elseif ( 'deleted' == $comment_status ) { ?> 369 369 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 370 370 <?php } ?> -
wp-admin/wp-admin.css
409 409 } 410 410 411 411 #doaction, 412 #doaction2 { 412 #doaction2, 413 #post-query-submit { 413 414 margin-right: 8px; 414 415 } 415 416 -
wp-admin/includes/post.php
795 795 'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')), 796 796 'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')), 797 797 'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')), 798 'deleted' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')), 798 799 ); 799 800 800 801 $post_stati = apply_filters('post_stati', $post_stati); -
wp-admin/includes/dashboard.php
480 480 $comments = array(); 481 481 $start = 0; 482 482 483 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BYcomment_date_gmt DESC LIMIT $start, 50" ) ) {483 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'deleted' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { 484 484 485 485 foreach ( $possible as $comment ) { 486 486 if ( count( $comments ) >= 5 ) -
wp-admin/includes/template.php
1433 1433 case 'title': 1434 1434 $attributes = 'class="post-title column-title"' . $style; 1435 1435 ?> 1436 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID )) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>1436 <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_post', $post->ID) && $post->post_status != 'deleted' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong> 1437 1437 <?php 1438 1438 if ( 'excerpt' == $mode ) 1439 1439 the_excerpt(); 1440 1440 1441 1441 $actions = array(); 1442 if ( current_user_can('edit_post', $post->ID) ) { 1443 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; 1444 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; 1445 } 1446 if ( current_user_can('delete_post', $post->ID) ) { 1447 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 1448 } 1449 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1450 if ( current_user_can('edit_post', $post->ID) ) 1451 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1442 if ( 'deleted' == $post->post_status ) { 1443 $actions['undelete'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=undelete&post=$post->ID", 'undelete-post_' . $post->ID) . "'>" . __('Return to Drafts') . "</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>"; 1452 1445 } else { 1453 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1446 if ( current_user_can('edit_post', $post->ID) ) { 1447 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; 1448 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; 1449 } 1450 if ( current_user_can('delete_post', $post->ID) ) { 1451 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 1452 } 1453 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1454 if ( current_user_can('edit_post', $post->ID) ) 1455 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1456 } else { 1457 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1458 } 1454 1459 } 1455 1460 $actions = apply_filters('post_row_actions', $actions, $post); 1456 1461 $action_count = count($actions); … … 1651 1656 $attributes = 'class="post-title page-title column-title"' . $style; 1652 1657 $edit_link = get_edit_post_link( $page->ID ); 1653 1658 ?> 1654 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_page', $page->ID )) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>1659 <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'deleted' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong> 1655 1660 <?php 1656 1661 $actions = array(); 1657 if ( current_user_can('edit_page', $page->ID) ) { 1658 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1659 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1660 } 1661 if ( current_user_can('delete_page', $page->ID) ) { 1662 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 1663 } 1664 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1665 if ( current_user_can('edit_page', $page->ID) ) 1666 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1662 if ($post->post_status == 'deleted') { 1663 if ( current_user_can('delete_page', $page->ID) ) { 1664 $actions['undelete'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=undelete&post=$page->ID", 'undelete-page_' . $page->ID) . "'>" . __('Return to Drafts') . "</a>"; 1665 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>"; 1666 } 1667 1667 } else { 1668 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1668 if ( current_user_can('edit_page', $page->ID) ) { 1669 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1670 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1671 } 1672 if ( current_user_can('delete_page', $page->ID) ) { 1673 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Trash') . "</a>"; 1674 } 1675 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1676 if ( current_user_can('edit_page', $page->ID) ) 1677 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1678 } else { 1679 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1680 } 1669 1681 } 1670 1682 $actions = apply_filters('page_row_actions', $actions, $page); 1671 1683 $action_count = count($actions); … … 1999 2011 $index = ''; 2000 2012 2001 2013 if ( 'moderated' == $status ) { 2002 $approved = "c omment_approved = '0'";2014 $approved = "c.comment_approved = '0'"; 2003 2015 $total = $count->moderated; 2004 2016 } elseif ( 'approved' == $status ) { 2005 $approved = "c omment_approved = '1'";2017 $approved = "c.comment_approved = '1'"; 2006 2018 $total = $count->approved; 2007 2019 } elseif ( 'spam' == $status ) { 2008 $approved = "c omment_approved = 'spam'";2020 $approved = "c.comment_approved = 'spam'"; 2009 2021 $total = $count->spam; 2010 2022 } elseif ( 'deleted' == $status ) { 2011 $approved = "c omment_approved = 'deleted'";2023 $approved = "c.comment_approved = 'deleted'"; 2012 2024 $total = $count->deleted; 2013 2025 } else { 2014 $approved = "( c omment_approved = '0' ORcomment_approved = '1' )";2026 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; 2015 2027 $total = $count->moderated + $count->approved; 2016 $index = 'USE INDEX (c omment_date_gmt)';2028 $index = 'USE INDEX (c.comment_date_gmt)'; 2017 2029 } 2018 2030 2019 2031 if ( $post ) { 2020 2032 $total = ''; 2021 $post = " AND c omment_post_ID = '$post'";2022 $orderby = "ORDER BY c omment_date_gmt ASC LIMIT $start, $num";2033 $post = " AND c.comment_post_ID = '$post'"; 2034 $orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num"; 2023 2035 } else { 2024 2036 $post = ''; 2025 $orderby = "ORDER BY c omment_date_gmt DESC LIMIT $start, $num";2037 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; 2026 2038 } 2027 2039 2028 2040 if ( 'comment' == $type ) 2029 $typesql = "AND c omment_type = ''";2041 $typesql = "AND c.comment_type = ''"; 2030 2042 elseif ( 'pingback' == $type ) 2031 $typesql = "AND c omment_type = 'pingback'";2043 $typesql = "AND c.comment_type = 'pingback'"; 2032 2044 elseif ( 'trackback' == $type ) 2033 $typesql = "AND c omment_type = 'trackback'";2045 $typesql = "AND c.comment_type = 'trackback'"; 2034 2046 elseif ( 'pings' == $type ) 2035 $typesql = "AND ( c omment_type = 'pingback' ORcomment_type = 'trackback' )";2047 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; 2036 2048 else 2037 2049 $typesql = ''; 2038 2050 2039 2051 if ( !empty($type) ) 2040 2052 $total = ''; 2041 2053 2054 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'deleted' "; 2042 2055 if ( $s ) { 2043 2056 $total = ''; 2044 2057 $s = $wpdb->escape($s); 2045 $query = "FROM $wpdb->comments WHERE2046 (c omment_author LIKE '%$s%' OR2047 c omment_author_email LIKE '%$s%' OR2048 c omment_author_url LIKE ('%$s%') OR2049 c omment_author_IP LIKE ('%$s%') OR2050 c omment_content LIKE ('%$s%') ) AND2058 $query .= "AND 2059 (c.comment_author LIKE '%$s%' OR 2060 c.comment_author_email LIKE '%$s%' OR 2061 c.comment_author_url LIKE ('%$s%') OR 2062 c.comment_author_IP LIKE ('%$s%') OR 2063 c.comment_content LIKE ('%$s%') ) AND 2051 2064 $approved 2052 2065 $typesql"; 2053 2066 } else { 2054 $query = "FROM $wpdb->comments $index WHERE$approved $post $typesql";2067 $query .= "AND $approved $post $typesql"; 2055 2068 } 2056 2069 2057 2070 $comments = $wpdb->get_results("SELECT * $query $orderby"); 2058 2071 if ( '' === $total ) 2059 $total = $wpdb->get_var("SELECT COUNT(c omment_ID) $query");2072 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); 2060 2073 2061 2074 update_comment_cache($comments); 2062 2075 … … 2157 2170 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 2158 2171 } else { 2159 2172 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; 2160 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __(' Move toTrash') . '</a>';2173 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Trash') . '</a>'; 2161 2174 } 2162 2175 2163 2176 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; -
wp-admin/includes/media.php
1170 1170 if ( $send ) 1171 1171 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; 1172 1172 if ( $delete ) 1173 $delete = "<a href=\" #\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>";1173 $delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>"; 1174 1174 if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) 1175 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete 1176 <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Continue') . "</a> 1177 <a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n"); 1175 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n"); 1178 1176 1179 1177 $hidden_fields = array(); 1180 1178 -
wp-admin/post.php
116 116 $post = get_post($post_ID); 117 117 118 118 if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') ); 119 if ( $post->post_status == 'deleted' ) wp_die( __('You can’t edit this post because it is in the Trash. Please move it out of the Trash and try again.') ); 119 120 120 121 if ( 'post' != $post->post_type ) { 121 122 wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); … … 206 207 exit(); 207 208 break; 208 209 210 case 'undelete': 211 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 212 check_admin_referer('undelete-post_' . $post_id); 213 214 $post = & get_post($post_id); 215 216 if ( $post->post_type == 'attachment' ) { 217 if ( ! wp_undelete_attachment($post_id) ) 218 wp_die( __('Error in undeleting...') ); 219 } else { 220 if ( !wp_undelete_post($post_id) ) 221 wp_die( __('Error in undeleting...') ); 222 } 223 224 $sendback = wp_get_referer(); 225 if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?undeleted=1'); 226 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 227 else $sendback = add_query_arg('undeleted', 1, $sendback); 228 wp_redirect($sendback); 229 exit(); 230 break; 231 209 232 case 'preview': 210 233 check_admin_referer( 'autosave', 'autosavenonce' ); 211 234 -
wp-admin/js/common.dev.js
154 154 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 155 155 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); 156 156 157 // show warnings158 $('#doaction, #doaction2').click(function(){159 if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {160 return showNotice.warn();161 }162 });163 $('#destroy_all, #destroy_all2').click(function(){164 return showNotice.warn();165 });166 167 157 // screen settings tab 168 158 $('#show-settings-link').click(function () { 169 159 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) { -
wp-admin/js/edit-comments.dev.js
39 39 settings.data._url = document.location.href; 40 40 41 41 if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted) 42 return s howNotice.warn() ? settings : false;42 return settings; 43 43 44 44 return settings; 45 45 }; -
wp-admin/edit-page-form.php
216 216 <div id="delete-action"> 217 217 <?php 218 218 if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?> 219 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>219 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&post=$post->ID", 'delete-page_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 220 220 <?php } ?> 221 221 </div> 222 222 -
wp-admin/edit-attachment-rows.php
29 29 $posts_columns = get_column_headers('upload'); 30 30 $hidden = get_hidden_columns('upload'); 31 31 while (have_posts()) : the_post(); 32 if ($is_trash && $post->post_status != 'deleted') continue; 33 elseif (!$is_trash && $post->post_status == 'deleted') continue; 32 34 $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; 33 35 global $current_user; 34 36 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); … … 60 62 ?> 61 63 <td <?php echo $attributes ?>><?php 62 64 if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { 65 if ($is_trash) echo $thumb; 66 else { 63 67 ?> 64 65 68 <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"> 66 69 <?php echo $thumb; ?> 67 70 </a> 68 71 69 72 <?php } 73 } 70 74 ?></td> 71 75 <?php 72 76 // TODO … … 74 78 75 79 case 'media': 76 80 ?> 77 <td <?php echo $attributes ?>><strong>< a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />81 <td <?php echo $attributes ?>><strong><?php if ($is_trash) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php echo $att_title; ?></a><?php } ?></strong><br /> 78 82 <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?> 79 83 <p> 80 84 <?php 81 85 $actions = array(); 82 if ( current_user_can('edit_post', $post->ID) ) 83 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 84 if ( current_user_can('delete_post', $post->ID) ) 85 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 86 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 86 if ($is_trash && current_user_can('delete_post', $post->ID)) { 87 $actions['undelete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=undelete&post=$post->ID", 'undelete-post_' . $post->ID) . "'>" . __('Remove from Trash') . "</a>"; 88 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 89 } else { 90 if (current_user_can('edit_post', $post->ID)) 91 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 92 if (current_user_can('delete_post', $post->ID)) 93 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 94 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 95 } 87 96 $action_count = count($actions); 88 97 $i = 0; 89 98 echo '<div class="row-actions">'; -
wp-admin/media.php
58 58 59 59 $att = get_post($att_id); 60 60 61 if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') ); 62 if ( $att->post_status == 'deleted' ) wp_die( __('You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') ); 63 61 64 add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); 62 65 63 66 wp_enqueue_script( 'wp-ajax-response' ); -
wp-admin/upload.php
67 67 exit; 68 68 } 69 69 70 } elseif ( isset($_GET[' action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2']) ) {70 } elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 71 71 check_admin_referer('bulk-media'); 72 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 72 73 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 74 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'deleted'" ); 75 $doaction = 'delete'; 76 } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media'])) { 77 $post_ids = $_GET['media']; 78 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 79 } else wp_redirect($_SERVER['HTTP_REFERER']); 80 81 $location = 'upload.php'; 82 if ( $referer = wp_get_referer() ) { 83 if ( false !== strpos($referer, 'upload.php') ) 84 $location = $referer; 85 } 73 86 74 if ( 'delete' == $doaction ) { 75 foreach( (array) $_GET['media'] as $post_id_del ) { 76 $post_del = & get_post($post_id_del); 87 switch ( $doaction ) { 88 case 'delete': 89 foreach( (array) $post_ids as $post_id_del ) { 90 $post_del = & get_post($post_id_del); 91 92 if ( !current_user_can('delete_post', $post_id_del) ) 93 wp_die( __('You are not allowed to delete this post.') ); 94 95 if ( $post_del->post_type == 'attachment' ) 96 if ( !wp_delete_attachment($post_id_del) ) 97 wp_die( __('Error in deleting...') ); 98 } 99 $location = add_query_arg('message', 2, $location); 100 break; 101 case 'undelete': 102 foreach( (array) $post_ids as $post_id ) { 103 $post_del = & get_post($post_id); 77 104 78 if ( !current_user_can('delete_post', $post_id_del) ) 79 wp_die( __('You are not allowed to delete this post.') ); 105 if ( $post_del->post_type == 'attachment' ) 106 if ( !wp_undelete_attachment($post_id) ) 107 wp_die( __('Error in undeleting...') ); 108 } 109 $location = add_query_arg('message', 4, $location); 110 break; 111 } 80 112 81 if ( $post_del->post_type == 'attachment' ) 82 if ( ! wp_delete_attachment($post_id_del) ) 83 wp_die( __('Error in deleting...') ); 84 } 85 86 $location = 'upload.php'; 87 if ( $referer = wp_get_referer() ) { 88 if ( false !== strpos($referer, 'upload.php') ) 89 $location = $referer; 90 } 91 92 $location = add_query_arg('message', 2, $location); 93 $location = remove_query_arg('posted', $location); 94 wp_redirect($location); 95 exit; 96 } 113 $location = remove_query_arg('posted', $location); 114 wp_redirect($location); 115 exit; 97 116 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 98 117 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 99 118 exit; … … 135 154 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 136 155 } 137 156 157 $is_trash = (isset($_GET['status']) && $_GET['status'] == 'deleted'); 158 138 159 wp_enqueue_script('media'); 139 160 require_once('admin-header.php'); ?> 140 161 … … 153 174 $messages[1] = __('Media attachment updated.'); 154 175 $messages[2] = __('Media deleted.'); 155 176 $messages[3] = __('Error saving media attachment.'); 177 $messages[4] = __('Media removed from Trash.'); 156 178 157 179 if ( isset($_GET['message']) && (int) $_GET['message'] ) { 158 180 $message = $messages[$_GET['message']]; … … 180 202 <?php 181 203 $type_links = array(); 182 204 $_num_posts = (array) wp_count_attachments(); 183 $_total_posts = array_sum( $_num_posts );205 $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 184 206 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 185 207 foreach ( $matches as $type => $reals ) 186 208 foreach ( $reals as $real ) 187 209 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; 188 210 189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';211 $class = (empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status'])) ? ' class="current"' : ''; 190 212 $type_links[] = "<li><a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>'; 191 213 foreach ( $post_mime_types as $mime_type => $label ) { 192 214 $class = ''; … … 199 221 200 222 $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>'; 201 223 } 202 $ class = isset($_GET['detached']) ? ' class="current"' : '';203 $type_links[] = '<li><a href="upload.php? detached=1"' . $class . '>' . __('Unattached') . '</a>';224 $type_links[] = '<li><a href="upload.php?detached=1"' . (isset($_GET['detached']) ? ' class="current"' : '') . '>' . __('Unattached') . '</a>'; 225 $type_links[] = '<li><a href="upload.php?status=deleted"' . ((isset($_GET['status']) && $_GET['status'] == 'deleted') ? ' 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>'; 204 226 205 227 echo implode( " |</li>\n", $type_links) . '</li>'; 206 228 unset($type_links); … … 242 264 <div class="alignleft actions"> 243 265 <select name="action" class="select-action"> 244 266 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 245 <option value="delete"><?php _e('Delete'); ?></option> 246 <?php if ( isset($orphans) ) { ?> 267 <?php if ($is_trash) { ?> 268 <option value="undelete"><?php _e('Remove from Trash'); ?></option> 269 <option value="delete"><?php _e('Delete Permanently'); ?></option> 270 <?php } else { ?> 271 <option value="delete"><?php _e('Move to Trash'); ?></option> 272 <?php } if (isset($orphans)) { ?> 247 273 <option value="attach"><?php _e('Attach to a post'); ?></option> 248 274 <?php } ?> 249 275 </select> … … 251 277 <?php wp_nonce_field('bulk-media'); ?> 252 278 253 279 <?php 254 if ( ! is_singular() && ! isset($_GET['detached'])) {280 if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) { 255 281 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; 256 282 257 283 $arc_result = $wpdb->get_results( $arc_query ); … … 286 312 287 313 <?php if ( isset($_GET['detached']) ) { ?> 288 314 <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 315 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?> 316 <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 289 317 <?php } ?> 290 318 291 319 </div> … … 341 369 if ( current_user_can('edit_post', $post->ID) ) 342 370 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 343 371 if ( current_user_can('delete_post', $post->ID) ) 344 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";372 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 345 373 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 346 374 if ( current_user_can('edit_post', $post->ID) ) 347 375 $actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>'; … … 398 426 <div class="alignleft actions"> 399 427 <select name="action2" class="select-action"> 400 428 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 401 <option value="delete"><?php _e('Delete'); ?></option> 402 <?php if ( isset($orphans) ) { ?> 429 <?php if ($is_trash) { ?> 430 <option value="undelete"><?php _e('Remove from Trash'); ?></option> 431 <option value="delete"><?php _e('Delete Permanently'); ?></option> 432 <?php } else { ?> 433 <option value="delete"><?php _e('Move to Trash'); ?></option> 434 <?php } if (isset($orphans)) { ?> 403 435 <option value="attach"><?php _e('Attach to a post'); ?></option> 404 436 <?php } ?> 405 437 </select> 406 438 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 439 440 <?php if ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?> 441 <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 442 <?php } ?> 407 443 </div> 408 444 409 445 <br class="clear" /> -
wp-admin/edit-form-comment.php
64 64 65 65 <div id="major-publishing-actions"> 66 66 <div id="delete-action"> 67 <?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) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete') . "</a>\n"; ?>67 <?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"; ?> 68 68 </div> 69 69 <div id="publishing-action"> 70 70 <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" /> -
wp-admin/edit-form-advanced.php
229 229 <div id="delete-action"> 230 230 <?php 231 231 if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?> 232 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>232 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 233 233 <?php } ?> 234 234 </div> 235 235 -
wp-admin/edit.php
18 18 } 19 19 20 20 // Handle bulk actions 21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { 22 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 23 21 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 22 check_admin_referer('bulk-posts'); 23 24 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 25 $post_status = $wpdb->escape($_GET['post_status']); 26 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" ); 27 $doaction = 'delete'; 28 } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) { 29 $post_ids = $_GET['post']; 30 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 31 } else wp_redirect($_SERVER['HTTP_REFERER']); 32 24 33 switch ( $doaction ) { 25 34 case 'delete': 26 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { 27 check_admin_referer('bulk-posts'); 28 $deleted = 0; 29 foreach( (array) $_GET['post'] as $post_id_del ) { 30 $post_del = & get_post($post_id_del); 35 $deleted = 0; 36 foreach( (array) $post_ids as $post_id_del ) { 37 $post_del = & get_post($post_id_del); 31 38 32 if ( !current_user_can('delete_post', $post_id_del) )33 wp_die( __('You are not allowed to delete this post.') );39 if ( !current_user_can('delete_post', $post_id_del) ) 40 wp_die( __('You are not allowed to delete this post.') ); 34 41 35 if ( $post_del->post_type == 'attachment' ) { 36 if ( ! wp_delete_attachment($post_id_del) ) 37 wp_die( __('Error in deleting...') ); 38 } else { 39 if ( !wp_delete_post($post_id_del) ) 40 wp_die( __('Error in deleting...') ); 41 } 42 $deleted++; 42 if ( $post_del->post_type == 'attachment' ) { 43 if ( ! wp_delete_attachment($post_id_del) ) 44 wp_die( __('Error in deleting...') ); 45 } else { 46 if ( !wp_delete_post($post_id_del) ) 47 wp_die( __('Error in deleting...') ); 43 48 } 49 $deleted++; 44 50 } 45 51 break; 46 case 'edit': 47 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 48 check_admin_referer('bulk-posts'); 52 case 'undelete': 53 $undeleted = 0; 54 foreach( (array) $post_ids as $post_id ) { 55 $post_del = & get_post($post_id); 49 56 50 if ( -1 == $_GET['_status'] ) { 51 $_GET['post_status'] = null; 52 unset($_GET['_status'], $_GET['post_status']); 53 } else { 54 $_GET['post_status'] = $_GET['_status']; 55 } 56 57 $done = bulk_edit_posts($_GET); 57 if ( !wp_undelete_post($post_id) ) 58 wp_die( __('Error in undeleting...') ); 59 60 $undeleted++; 58 61 } 59 62 break; 63 case 'edit': 64 if ( -1 == $_GET['_status'] ) { 65 $_GET['post_status'] = null; 66 unset($_GET['_status'], $_GET['post_status']); 67 } else { 68 $_GET['post_status'] = $_GET['_status']; 69 } 70 71 $done = bulk_edit_posts($_GET); 72 break; 60 73 } 61 74 62 75 $sendback = wp_get_referer(); … … 70 83 } 71 84 if ( isset($deleted) ) 72 85 $sendback = add_query_arg('deleted', $deleted, $sendback); 86 elseif ( isset($undeleted) ) 87 $sendback = add_query_arg('undeleted', $undeleted, $sendback); 73 88 wp_redirect($sendback); 74 89 exit(); 75 90 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { … … 127 142 unset($_GET['deleted']); 128 143 } 129 144 145 if ( isset($_GET['undeleted']) && (int) $_GET['undeleted'] ) { 146 printf( _n( 'Post returned to Pending.', '%s posts returned to Pending.', $_GET['undeleted'] ), number_format_i18n( $_GET['undeleted'] ) ); 147 unset($_GET['undeleted']); 148 } 149 130 150 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); 131 151 ?> 132 152 </p></div> … … 139 159 if ( empty($locked_post_status) ) : 140 160 $status_links = array(); 141 161 $num_posts = wp_count_posts( 'post', 'readable' ); 142 $total_posts = array_sum( (array) $num_posts ) ;162 $total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted; 143 163 $class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; 144 164 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; 145 165 … … 190 210 <div class="alignleft actions"> 191 211 <select name="action"> 192 212 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 213 <?php if ($_GET['post_status'] == 'deleted') { ?> 214 <option value="undelete"><?php _e('Return to Pending'); ?></option> 215 <option value="delete"><?php _e('Delete Permanently'); ?></option> 216 <?php } else { ?> 193 217 <option value="edit"><?php _e('Edit'); ?></option> 194 <option value="delete"><?php _e('Delete'); ?></option> 218 <option value="delete"><?php _e('Move to Trash'); ?></option> 219 <?php } ?> 195 220 </select> 196 221 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 197 222 <?php wp_nonce_field('bulk-posts'); ?> … … 235 260 do_action('restrict_manage_posts'); 236 261 ?> 237 262 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 238 263 <?php } if ($_GET['post_status'] == 'deleted') { ?> 264 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 239 265 <?php } ?> 240 266 </div> 241 267 … … 270 296 <div class="alignleft actions"> 271 297 <select name="action2"> 272 298 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 299 <?php if ($_GET['post_status'] == 'deleted') { ?> 300 <option value="undelete"><?php _e('Return to Pending'); ?></option> 301 <option value="delete"><?php _e('Delete Permanently'); ?></option> 302 <?php } else { ?> 273 303 <option value="edit"><?php _e('Edit'); ?></option> 274 <option value="delete"><?php _e('Delete'); ?></option> 304 <option value="delete"><?php _e('Move to Trash'); ?></option> 305 <?php } ?> 275 306 </select> 276 307 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 308 <?php if ($_GET['post_status'] == 'deleted') { ?> 309 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 310 <?php } ?> 277 311 <br class="clear" /> 278 312 </div> 279 313 <br class="clear" /> -
wp-admin/page.php
83 83 $post = get_post_to_edit($page_ID); 84 84 85 85 if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') ); 86 if ( $post->post_status == 'deleted' ) wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') ); 86 87 87 88 if ( 'page' != $post->post_type ) { 88 89 wp_redirect( get_edit_post_link( $post_ID, 'url' ) ); … … 165 166 exit(); 166 167 break; 167 168 169 case 'undelete': 170 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 171 check_admin_referer('undelete-page_' . $post_id); 172 173 $post = & get_post($post_id); 174 175 if ( $post->post_type == 'attachment' ) { 176 if ( ! wp_undelete_attachment($post_id) ) 177 wp_die( __('Error in undeleting...') ); 178 } else { 179 if ( !wp_undelete_post($post_id) ) 180 wp_die( __('Error in undeleting...') ); 181 } 182 183 $sendback = wp_get_referer(); 184 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit.php?undeleted=1'); 185 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 186 else $sendback = add_query_arg('undeleted', 1, $sendback); 187 wp_redirect($sendback); 188 exit(); 189 break; 190 168 191 case 'preview': 169 192 check_admin_referer( 'autosave', 'autosavenonce' ); 170 193 -
wp-admin/edit-pages.php
10 10 require_once('admin.php'); 11 11 12 12 // Handle bulk actions 13 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { 14 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 13 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 14 check_admin_referer('bulk-pages'); 15 16 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 17 $post_status = $wpdb->escape($_GET['post_status']); 18 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" ); 19 $doaction = 'delete'; 20 } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) { 21 $post_ids = $_GET['post']; 22 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 23 } else wp_redirect($_SERVER['HTTP_REFERER']); 15 24 16 25 switch ( $doaction ) { 17 26 case 'delete': 18 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { 19 check_admin_referer('bulk-pages'); 20 $deleted = 0; 21 foreach( (array) $_GET['post'] as $post_id_del ) { 22 $post_del = & get_post($post_id_del); 27 $deleted = 0; 28 foreach( (array) $post_ids as $post_id_del ) { 29 $post_del = & get_post($post_id_del); 23 30 24 if ( !current_user_can('delete_page', $post_id_del) )25 wp_die( __('You are not allowed to delete this page.') );31 if ( !current_user_can('delete_page', $post_id_del) ) 32 wp_die( __('You are not allowed to delete this page.') ); 26 33 27 if ( $post_del->post_type == 'attachment' ) { 28 if ( ! wp_delete_attachment($post_id_del) ) 29 wp_die( __('Error in deleting...') ); 30 } else { 31 if ( !wp_delete_post($post_id_del) ) 32 wp_die( __('Error in deleting...') ); 33 } 34 $deleted++; 34 if ( $post_del->post_type == 'attachment' ) { 35 if ( ! wp_delete_attachment($post_id_del) ) 36 wp_die( __('Error in deleting...') ); 37 } else { 38 if ( !wp_delete_post($post_id_del) ) 39 wp_die( __('Error in deleting...') ); 35 40 } 41 $deleted++; 36 42 } 37 43 break; 38 case 'edit': 39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 40 check_admin_referer('bulk-pages'); 44 case 'undelete': 45 $undeleted = 0; 46 foreach( (array) $post_ids as $post_id ) { 47 $post_del = & get_post($post_id); 41 48 42 if ( -1 == $_GET['_status'] ) { 43 $_GET['post_status'] = null; 44 unset($_GET['_status'], $_GET['post_status']); 45 } else { 46 $_GET['post_status'] = $_GET['_status']; 47 } 48 49 $done = bulk_edit_posts($_GET); 49 if ( !wp_undelete_post($post_id) ) 50 wp_die( __('Error in undeleting...') ); 51 52 $undeleted++; 50 53 } 51 54 break; 55 case 'edit': 56 if ( -1 == $_GET['_status'] ) { 57 $_GET['post_status'] = null; 58 unset($_GET['_status'], $_GET['post_status']); 59 } else { 60 $_GET['post_status'] = $_GET['_status']; 61 } 62 63 $done = bulk_edit_posts($_GET); 64 break; 52 65 } 53 66 54 67 $sendback = wp_get_referer(); … … 62 75 } 63 76 if ( isset($deleted) ) 64 77 $sendback = add_query_arg('deleted', $deleted, $sendback); 78 elseif ( isset($undeleted) ) 79 $sendback = add_query_arg('undeleted', $undeleted, $sendback); 65 80 wp_redirect($sendback); 66 81 exit(); 67 82 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { … … 79 94 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), 80 95 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')), 81 96 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')), 82 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')) 97 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), 98 'deleted' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')) 83 99 ); 84 100 85 101 $post_stati = apply_filters('page_stati', $post_stati); … … 150 166 if ( empty($locked_post_status) ) : 151 167 $status_links = array(); 152 168 $num_posts = wp_count_posts('page', 'readable'); 153 $total_posts = array_sum( (array) $num_posts ) ;169 $total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted; 154 170 $class = empty($_GET['post_status']) ? ' class="current"' : ''; 155 171 $status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . '</a>'; 156 172 foreach ( $post_stati as $status => $label ) { … … 212 228 <div class="alignleft actions"> 213 229 <select name="action"> 214 230 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 231 <?php if ($_GET['post_status'] == 'deleted') { ?> 232 <option value="undelete"><?php _e('Return to Pending'); ?></option> 233 <option value="delete"><?php _e('Delete Permanently'); ?></option> 234 <?php } else { ?> 215 235 <option value="edit"><?php _e('Edit'); ?></option> 216 <option value="delete"><?php _e('Delete'); ?></option> 236 <option value="delete"><?php _e('Move to Trash'); ?></option> 237 <?php } ?> 217 238 </select> 218 239 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 219 240 <?php wp_nonce_field('bulk-pages'); ?> 241 <?php if ($_GET['post_status'] == 'deleted') { ?> 242 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 243 <?php } ?> 220 244 </div> 221 245 222 246 <br class="clear" /> … … 251 275 <div class="alignleft actions"> 252 276 <select name="action2"> 253 277 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 278 <?php if ($_GET['post_status'] == 'deleted') { ?> 279 <option value="undelete"><?php _e('Return to Pending'); ?></option> 280 <option value="delete"><?php _e('Delete Permanently'); ?></option> 281 <?php } else { ?> 254 282 <option value="edit"><?php _e('Edit'); ?></option> 255 <option value="delete"><?php _e('Delete'); ?></option> 283 <option value="delete"><?php _e('Move to Trash'); ?></option> 284 <?php } ?> 256 285 </select> 257 286 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 287 <?php if ($_GET['post_status'] == 'deleted') { ?> 288 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 289 <?php } ?> 258 290 </div> 259 291 260 292 <br class="clear" />
