Ticket #4529: trash.diff
| File trash.diff, 90.2 KB (added by caesarsgrunt, 3 years ago) |
|---|
-
wp-app.php
1231 1231 log_app('Status','204: No Content'); 1232 1232 header('Content-Type: text/plain'); 1233 1233 status_header('204'); 1234 echo " Deleted.";1234 echo "Moved to Trash."; 1235 1235 exit; 1236 1236 } 1237 1237 -
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, 'trash' => 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 != 'trash' $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 = 'trash' $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) != 'trash' && EMPTY_TRASH_DAYS > 0) 1145 return wp_trash_post($postid); 1146 1147 if ($post->post_type == 'attachment') 1144 1148 return wp_delete_attachment($postid); 1145 1149 1146 1150 do_action('delete_post', $postid); 1151 1152 $trash_meta = get_option('wp_trash_meta'); 1153 if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) { 1154 unset($trash_meta['posts'][$postid]); 1155 update_option('wp_trash_meta', $trash_meta); 1156 } 1147 1157 1148 1158 /** @todo delete for pluggable post taxonomies too */ 1149 1159 wp_delete_object_term_relationships($postid, array('category', 'post_tag')); … … 1205 1215 } 1206 1216 1207 1217 /** 1218 * Moves a post or page to the Trash 1219 * 1220 * @since 2.9.0 1221 * @uses do_action() on 'trash_post' before trashing 1222 * @uses do_action() on 'trashed_post' after trashing 1223 * 1224 * @param int $postid Post ID. 1225 * @return mixed False on failure 1226 */ 1227 function wp_trash_post($postid = 0) { 1228 if (EMPTY_TRASH_DAYS == 0) 1229 return wp_delete_post($postid); 1230 1231 if (!$post = wp_get_single_post($postid, ARRAY_A)) 1232 return $post; 1233 1234 do_action('trash_post', $postid); 1235 1236 $trash_meta = get_option('wp_trash_meta'); 1237 if (!is_array($trash_meta)) 1238 $trash_meta = array(); 1239 $trash_meta['posts'][$postid]['status'] = $post['post_status']; 1240 $trash_meta['posts'][$postid]['time'] = time(); 1241 update_option('wp_trash_meta', $trash_meta); 1242 1243 $post['post_status'] = 'trash'; 1244 wp_insert_post($post); 1245 1246 do_action('trashed_post', $postid); 1247 1248 return $post; 1249 } 1250 1251 /** 1252 * Removes a post or page from the Trash 1253 * 1254 * @since 2.9.0 1255 * @uses do_action() on 'untrash_post' before undeletion 1256 * @uses do_action() on 'untrashed_post' after undeletion 1257 * 1258 * @param int $postid Post ID. 1259 * @return mixed False on failure 1260 */ 1261 function wp_untrash_post($postid = 0) { 1262 if (!$post = wp_get_single_post($postid, ARRAY_A)) 1263 return $post; 1264 1265 do_action('untrash_post', $postid); 1266 1267 $post['post_status'] = 'draft'; 1268 1269 $trash_meta = get_option('wp_trash_meta'); 1270 if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) { 1271 $post['post_status'] = $trash_meta['posts'][$postid]['status']; 1272 unset($trash_meta['posts'][$postid]); 1273 update_option('wp_trash_meta', $trash_meta); 1274 } 1275 1276 wp_insert_post($post); 1277 1278 do_action('untrashed_post', $postid); 1279 1280 return $post; 1281 } 1282 1283 /** 1208 1284 * Retrieve the list of categories for a post. 1209 1285 * 1210 1286 * Compatibility layer for themes and plugins. Also an easy layer of abstraction … … 2586 2662 2587 2663 if ( 'attachment' != $post->post_type ) 2588 2664 return false; 2665 2666 if (get_post_status($postid) != 'trash') { 2667 return wp_trash_post($postid); 2668 } 2669 2670 $trash_meta = get_option('wp_trash_meta'); 2671 if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) { 2672 unset($trash_meta['posts'][$postid]); 2673 update_option('wp_trash_meta', $trash_meta); 2674 } 2589 2675 2590 2676 $meta = wp_get_attachment_metadata( $postid ); 2591 2677 $file = get_attached_file( $postid ); -
wp-includes/comment.php
208 208 $approved = "comment_approved = '1'"; 209 209 elseif ( 'spam' == $status ) 210 210 $approved = "comment_approved = 'spam'"; 211 elseif ( ' deleted' == $status )212 $approved = "comment_approved = ' deleted'";211 elseif ( 'trash' == $status ) 212 $approved = "comment_approved = 'trash'"; 213 213 else 214 214 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 215 215 … … 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 <> 'trash'"; 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 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', ' deleted' => 'deleted');705 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash'); 705 706 $known_types = array_keys( $approved ); 706 707 foreach( (array) $count as $row_num => $row ) { 707 708 $total += $row['num_comments']; … … 737 738 * @return bool False if delete comment query failure, true on success. 738 739 */ 739 740 function wp_delete_comment($comment_id) { 740 if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam') 741 return wp_set_comment_status($comment_id, 'delete'); 741 global $wpdb; 742 if (!$comment = get_comment($comment_id)) 743 return false; 744 745 if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) 746 return wp_trash_comment($comment_id); 742 747 743 global $wpdb;744 748 do_action('delete_comment', $comment_id); 745 749 746 wp_unschedule_comment_delete($comment_id); 750 $trash_meta = get_option('wp_trash_meta'); 751 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { 752 unset($trash_meta['comments'][$comment_id]); 753 update_option('wp_trash_meta', $trash_meta); 754 } 747 755 748 $comment = get_comment($comment_id);749 750 756 if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) 751 757 return false; 752 758 … … 769 775 } 770 776 771 777 /** 778 * Moves a comment to the Trash 779 * 780 * @since 2.9.0 781 * @uses do_action() on 'trash_comment' before trashing 782 * @uses do_action() on 'trashed_comment' after trashing 783 * 784 * @param int $comment_id Comment ID. 785 * @return mixed False on failure 786 */ 787 function wp_trash_comment($comment_id = 0) { 788 if (EMPTY_TRASH_DAYS == 0) 789 return wp_delete_comment($comment_id); 790 791 if (!$comment = get_comment($comment_id)) 792 return false; 793 794 do_action('trash_comment', $comment_id); 795 796 $trash_meta = get_option('wp_trash_meta', array()); 797 $trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved; 798 $trash_meta['comments'][$comment_id]['time'] = time(); 799 update_option('wp_trash_meta', $trash_meta); 800 801 wp_set_comment_status($comment_id, 'trash'); 802 803 do_action('trashed_comment', $comment_id); 804 805 return true; 806 } 807 808 /** 809 * Removes a comment from the Trash 810 * 811 * @since 2.9.0 812 * @uses do_action() on 'untrash_comment' before undeletion 813 * @uses do_action() on 'untrashed_comment' after undeletion 814 * 815 * @param int $comment_id Comment ID. 816 * @return mixed False on failure 817 */ 818 function wp_untrash_comment($comment_id = 0) { 819 do_action('untrash_comment', $comment_id); 820 821 $comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0'); 822 823 $trash_meta = get_option('wp_trash_meta'); 824 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { 825 $comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status']; 826 unset($trash_meta['comments'][$comment_id]); 827 update_option('wp_trash_meta', $trash_meta); 828 } 829 830 wp_update_comment($comment); 831 832 do_action('untrashed_comment', $comment_id); 833 834 return true; 835 } 836 837 /** 772 838 * The status of a comment by ID. 773 839 * 774 840 * @since 1.0.0 775 841 * 776 842 * @param int $comment_id Comment ID 777 * @return string|bool Status might be ' deleted', 'approved', 'unapproved', 'spam'. False on failure.843 * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure. 778 844 */ 779 845 function wp_get_comment_status($comment_id) { 780 846 $comment = get_comment($comment_id); … … 784 850 $approved = $comment->comment_approved; 785 851 786 852 if ( $approved == NULL ) 787 return 'deleted';853 return false; 788 854 elseif ( $approved == '1' ) 789 855 return 'approved'; 790 856 elseif ( $approved == '0' ) 791 857 return 'unapproved'; 792 858 elseif ( $approved == 'spam' ) 793 859 return 'spam'; 794 elseif ( $approved == ' deleted' )795 return ' deleted';860 elseif ( $approved == 'trash' ) 861 return 'trash'; 796 862 else 797 863 return false; 798 864 } … … 1037 1103 */ 1038 1104 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { 1039 1105 global $wpdb; 1040 wp_unschedule_comment_delete($comment_id); 1041 1106 1042 1107 $status = '0'; 1043 switch ( $comment_status) {1108 switch ($comment_status) { 1044 1109 case 'hold': 1045 1110 $status = '0'; 1046 1111 break; … … 1054 1119 case 'spam': 1055 1120 $status = 'spam'; 1056 1121 break; 1057 case 'delete': 1058 if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam') 1059 return wp_delete_comment($comment_id); 1060 $status = 'deleted'; 1061 wp_schedule_comment_delete($comment_id); 1122 case 'trash': 1123 $status = 'trash'; 1062 1124 break; 1063 1125 default: 1064 1126 return false; … … 1084 1146 } 1085 1147 1086 1148 /** 1087 * Schedules a comment for destruction in 30 days.1088 *1089 * @since 2.9.01090 *1091 * @param int $comment_id Comment ID.1092 * @return void1093 */1094 function wp_schedule_comment_delete($comment_id) {1095 $to_delete = get_option('wp_scheduled_delete');1096 if ( !is_array($to_delete) )1097 $to_delete = array();1098 1099 $to_delete['comments'][$comment_id] = time();1100 1101 update_option('wp_scheduled_delete', $to_delete);1102 }1103 1104 /**1105 * Unschedules a comment for destruction.1106 *1107 * @since 2.9.01108 *1109 * @param int $comment_id Comment ID.1110 * @return void1111 */1112 function wp_unschedule_comment_delete($comment_id) {1113 $to_delete = get_option('wp_scheduled_delete');1114 if ( !is_array($to_delete) )1115 return;1116 1117 unset($to_delete['comments'][$comment_id]);1118 1119 update_option('wp_scheduled_delete', $to_delete);1120 }1121 1122 /**1123 1149 * Updates an existing comment in the database. 1124 1150 * 1125 1151 * Filters the comment and makes sure certain fields are valid before updating. -
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, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS. 3344 3343 * 3345 * @access private3346 3344 * @since 2.9.0 3347 3345 * 3348 3346 * @return void 3349 3347 */ 3350 3348 function wp_scheduled_delete() { 3351 $t o_delete = get_option('wp_scheduled_delete');3352 if (!is_array($t o_delete))3349 $trash_meta = get_option('wp_trash_meta'); 3350 if (!is_array($trash_meta)) 3353 3351 return; 3354 3352 3355 if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) ) 3356 $to_delete['comments'] = array(); 3357 3358 $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30); 3359 $deletetimestamp = time() - $delete_delay; 3360 foreach ($to_delete['comments'] as $comment_id => $timestamp) { 3361 if ($timestamp < $deletetimestamp) { 3362 wp_delete_comment($comment_id); 3363 unset($to_delete['comments'][$comment_id]); 3353 $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); 3354 3355 foreach ($trash_meta['comments'] as $id => $meta) { 3356 if ($meta['time'] < $delete_timestamp) { 3357 wp_delete_comment($id); 3358 unset($trash_meta['comments'][$id]); 3364 3359 } 3365 3360 } 3361 foreach ($trash_meta['posts'] as $id => $meta) { 3362 if ($meta['time'] < $delete_timestamp) { 3363 wp_delete_post($id); 3364 unset($to_delete['posts'][$id]); 3365 } 3366 } 3366 3367 3367 3368 update_option('wp_scheduled_delete', $to_delete); 3368 3369 } -
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( 'trash', $q_status ) ) 2103 $r_status[] = "$wpdb->posts.post_status = 'trash'"; 2102 2104 2103 2105 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 2104 2106 $r_status = array_merge($r_status, $p_status); -
wp-includes/script-loader.php
204 204 'upload_stopped' => __('Upload stopped.'), 205 205 'dismiss' => __('Dismiss'), 206 206 'crunching' => __('Crunching…'), 207 'deleted' => __(' Deleted'),207 'deleted' => __('Moved to Trash'), 208 208 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' 209 209 ) ); 210 210 -
wp-settings.php
534 534 if ( !defined( 'AUTOSAVE_INTERVAL' ) ) 535 535 define( 'AUTOSAVE_INTERVAL', 60 ); 536 536 537 /** 538 * It is possible to define this in wp-config.php 539 * @since 2.9.0 540 */ 541 if ( !defined( 'EMPTY_TRASH_DAYS' ) ) 542 define( 'EMPTY_TRASH_DAYS', 30 ); 537 543 544 538 545 require (ABSPATH . WPINC . '/vars.php'); 539 546 540 547 // make taxonomies available to plugins and themes -
wp-admin/edit-comments.php
14 14 15 15 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; 16 16 17 if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['de stroy_all']) || isset($_REQUEST['destroy_all2']) ) {17 if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) { 18 18 check_admin_referer('bulk-comments'); 19 19 20 if ((isset($_REQUEST['de stroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {20 if ((isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) { 21 21 $comment_status = $wpdb->escape($_REQUEST['comment_status']); 22 22 $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']); 23 23 $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" ); 24 $doaction = 'de stroy';24 $doaction = 'delete'; 25 25 } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) { 26 26 $comment_ids = $_REQUEST['delete_comments']; 27 27 $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; 28 28 } else wp_redirect($_SERVER['HTTP_REFERER']); 29 29 30 $approved = $unapproved = $spammed = $ deleted = $destroyed = 0;30 $approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 0; 31 31 32 32 foreach ($comment_ids as $comment_id) { // Check the permissions on each 33 33 $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); … … 48 48 wp_set_comment_status($comment_id, 'spam'); 49 49 $spammed++; 50 50 break; 51 case 'trash' : 52 wp_trash_comment($comment_id); 53 $trashed++; 54 break; 55 case 'untrash' : 56 wp_untrash_comment($comment_id); 57 $untrashed++; 58 break; 51 59 case 'delete' : 52 wp_ set_comment_status($comment_id, 'delete');60 wp_delete_comment($comment_id); 53 61 $deleted++; 54 62 break; 55 case 'destroy' :56 wp_set_comment_status($comment_id, 'delete');57 $destroyed++;58 break;59 63 } 60 64 } 61 65 62 $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '& deleted=' . $deleted . '&destroyed=' . $destroyed;66 $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted; 63 67 if ( $post_id ) 64 68 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); 65 69 if ( isset($_REQUEST['apage']) ) … … 86 90 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); 87 91 88 92 $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; 89 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', ' deleted')) )93 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) ) 90 94 $comment_status = 'all'; 91 95 92 96 $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; … … 102 106 </h2> 103 107 104 108 <?php 105 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['destroyed'] ) || isset( $_GET['spam'] ) ) { 106 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; 107 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; 108 $destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 0; 109 $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0; 109 if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spam']) ) { 110 $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0; 111 $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0; 112 $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0; 113 $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0; 114 $spam = isset($_GET['spam']) ? (int) $_GET['spam'] : 0; 110 115 111 if ( $approved > 0 || $deleted > 0 || $ destroyed > 0 || $spam > 0 ) {116 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spam > 0 ) { 112 117 echo '<div id="moderated" class="updated fade"><p>'; 113 118 114 119 if ( $approved > 0 ) { … … 119 124 printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); 120 125 echo '<br />'; 121 126 } 122 if ( $ deleted > 0 ) {123 printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );127 if ( $trashed > 0 ) { 128 printf( _n( '%s comment moved to the trash', '%s comments moved to the trash', $trashed ), $trashed ); 124 129 echo '<br />'; 125 130 } 126 if ( $ destroyed > 0 ) {127 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );131 if ( $untrashed > 0 ) { 132 printf( _n( '%s comment removed from the trash', '%s comments removed from the trash', $untrashed ), $untrashed ); 128 133 echo '<br />'; 129 134 } 135 if ( $deleted > 0 ) { 136 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 137 echo '<br />'; 138 } 130 139 131 140 echo '</p></div>'; 132 141 } … … 145 154 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 146 155 'approved' => _n_noop('Approved', 'Approved'), // singular not used 147 156 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 148 ' deleted' => _n_noop('Trash <span class="count">(<span class="deleted-count">%s</span>)</span>', 'Trash <span class="count">(<span class="deleted-count">%s</span>)</span>')157 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>') 149 158 ); 150 159 $link = 'edit-comments.php'; 151 160 if ( !empty($comment_type) && 'all' != $comment_type ) … … 256 265 <?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?> 257 266 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 258 267 <?php endif; ?> 259 <?php if ( ' deleted' == $comment_status ): ?>260 <option value="un approve"><?php _e('Return to Pending'); ?></option>268 <?php if ( 'trash' == $comment_status ): ?> 269 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 261 270 <?php endif; ?> 262 <?php if ( ' deleted' == $comment_status || 'spam' == $comment_status ): ?>263 <option value="de stroy"><?php _e('Delete Permanently'); ?></option>271 <?php if ( 'trash' == $comment_status || 'spam' == $comment_status ): ?> 272 <option value="delete"><?php _e('Delete Permanently'); ?></option> 264 273 <?php else: ?> 265 <option value=" delete"><?php _e('Move to Trash'); ?></option>274 <option value="trash"><?php _e('Move to Trash'); ?></option> 266 275 <?php endif; ?> 267 276 </select> 268 277 <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> … … 289 298 <input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" /> 290 299 <?php } 291 300 292 if ( ( 'spam' == $comment_status || ' deleted' == $comment_status) && current_user_can ('moderate_comments') ) {301 if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) { 293 302 wp_nonce_field('bulk-destroy', '_destroy_nonce'); 294 303 if ( 'spam' == $comment_status ) { ?> 295 <input type="submit" name="de stroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />296 <?php } elseif ( ' deleted' == $comment_status ) { ?>297 <input type="submit" name="de stroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />304 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 305 <?php } elseif ( 'trash' == $comment_status ) { ?> 306 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 298 307 <?php } 299 308 } ?> 300 309 <?php do_action('manage_comments_nav', $comment_status); ?> … … 352 361 <?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?> 353 362 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 354 363 <?php endif; ?> 355 <?php if ( ' deleted' == $comment_status ): ?>356 <option value="un approve"><?php _e('Return to Pending'); ?></option>364 <?php if ( 'trash' == $comment_status ): ?> 365 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 357 366 <?php endif; ?> 358 <?php if ( ' deleted' == $comment_status || 'spam' == $comment_status ): ?>359 <option value="de stroy"><?php _e('Delete Permanently'); ?></option>367 <?php if ( 'trash' == $comment_status || 'spam' == $comment_status ): ?> 368 <option value="delete"><?php _e('Delete Permanently'); ?></option> 360 369 <?php else: ?> 361 <option value=" delete"><?php _e('Move to Trash'); ?></option>370 <option value="trash"><?php _e('Move to Trash'); ?></option> 362 371 <?php endif; ?> 363 372 </select> 364 373 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> 365 374 366 375 <?php if ( 'spam' == $comment_status ) { ?> 367 <input type="submit" name="de stroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />368 <?php } elseif ( ' deleted' == $comment_status ) { ?>369 <input type="submit" name="de stroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />376 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 377 <?php } elseif ( 'trash' == $comment_status ) { ?> 378 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 370 379 <?php } ?> 371 380 <?php do_action('manage_comments_nav', $comment_status); ?> 372 381 </div> -
wp-admin/admin-ajax.php
181 181 $id = isset($_POST['id'])? (int) $_POST['id'] : 0; 182 182 switch ( $action = $_POST['action'] ) : 183 183 case 'delete-comment' : // On success, die with time() instead of 1 184 check_ajax_referer( "delete-comment_$id" );185 184 if ( !$comment = get_comment( $id ) ) 186 185 die( (string) time() ); 187 186 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 188 187 die('-1'); 189 188 190 if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { 189 if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { 190 check_ajax_referer( "trash-comment_$id" ); 191 if ( 'trash' == wp_get_comment_status( $comment->comment_ID ) ) 192 die( (string) time() ); 193 $r = wp_trash_comment( $comment->comment_ID ); 194 } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) { 195 check_ajax_referer( "untrash-comment_$id" ); 196 $r = wp_untrash_comment( $comment->comment_ID ); 197 } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { 198 check_ajax_referer( "delete-comment_$id" ); 191 199 if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) ) 192 200 die( (string) time() ); 193 201 $r = wp_set_comment_status( $comment->comment_ID, 'spam' ); 194 202 } else { 195 $r = wp_set_comment_status( $comment->comment_ID, 'delete' ); 203 check_ajax_referer( "delete-comment_$id" ); 204 $r = wp_delete_comment( $comment->comment_ID ); 196 205 } 197 206 if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts 198 207 _wp_ajax_delete_comment_response( $comment->comment_ID ); -
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 … … 444 445 display: none; 445 446 } 446 447 447 .unapproved .approve, .spam .approve, . deleted.approve {448 .unapproved .approve, .spam .approve, .trash .approve { 448 449 display: inline; 449 450 } 450 451 -
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 'trash' => 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 != 'trash' 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 != 'trash' ) { ?><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 ( '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) . "'>" . __('Remove from Trash') . "</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['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-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 != 'trash' ) { ?><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 == 'trash' && current_user_can('delete_page', $page->ID)) { 1663 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Remove from Trash') . "</a>"; 1664 $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>"; 1667 1665 } else { 1668 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1666 if ( current_user_can('edit_page', $page->ID) ) { 1667 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1668 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1669 } 1670 if ( current_user_can('delete_page', $page->ID) ) { 1671 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . wp_nonce_url("page.php?action=trash&post=$page->ID", 'trash-page_' . $page->ID) . "'>" . __('Trash') . "</a>"; 1672 } 1673 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1674 if ( current_user_can('edit_page', $page->ID) ) 1675 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1676 } else { 1677 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1678 } 1669 1679 } 1670 1680 $actions = apply_filters('page_row_actions', $actions, $page); 1671 1681 $action_count = count($actions); … … 1981 1991 * 1982 1992 * @since unknown 1983 1993 * 1984 * @param string $status Comment status (approved, spam, deleted, etc)1994 * @param string $status Comment status (approved, spam, trash, etc) 1985 1995 * @param string $s Term to search for 1986 1996 * @param int $start Offset to start at for pagination 1987 1997 * @param int $num Maximum number of comments to return … … 1999 2009 $index = ''; 2000 2010 2001 2011 if ( 'moderated' == $status ) { 2002 $approved = "c omment_approved = '0'";2012 $approved = "c.comment_approved = '0'"; 2003 2013 $total = $count->moderated; 2004 2014 } elseif ( 'approved' == $status ) { 2005 $approved = "c omment_approved = '1'";2015 $approved = "c.comment_approved = '1'"; 2006 2016 $total = $count->approved; 2007 2017 } elseif ( 'spam' == $status ) { 2008 $approved = "c omment_approved = 'spam'";2018 $approved = "c.comment_approved = 'spam'"; 2009 2019 $total = $count->spam; 2010 } elseif ( ' deleted' == $status ) {2011 $approved = "c omment_approved = 'deleted'";2012 $total = $count-> deleted;2020 } elseif ( 'trash' == $status ) { 2021 $approved = "c.comment_approved = 'trash'"; 2022 $total = $count->trash; 2013 2023 } else { 2014 $approved = "( c omment_approved = '0' ORcomment_approved = '1' )";2024 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; 2015 2025 $total = $count->moderated + $count->approved; 2016 $index = 'USE INDEX (c omment_date_gmt)';2026 $index = 'USE INDEX (c.comment_date_gmt)'; 2017 2027 } 2018 2028 2019 2029 if ( $post ) { 2020 2030 $total = ''; 2021 $post = " AND c omment_post_ID = '$post'";2022 $orderby = "ORDER BY c omment_date_gmt ASC LIMIT $start, $num";2031 $post = " AND c.comment_post_ID = '$post'"; 2032 $orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num"; 2023 2033 } else { 2024 2034 $post = ''; 2025 $orderby = "ORDER BY c omment_date_gmt DESC LIMIT $start, $num";2035 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; 2026 2036 } 2027 2037 2028 2038 if ( 'comment' == $type ) 2029 $typesql = "AND c omment_type = ''";2039 $typesql = "AND c.comment_type = ''"; 2030 2040 elseif ( 'pings' == $type ) 2031 $typesql = "AND ( c omment_type = 'pingback' ORcomment_type = 'trackback' )";2041 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; 2032 2042 elseif ( !empty($type) ) 2033 $typesql = $wpdb->prepare("AND c omment_type = %s", $type);2043 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type); 2034 2044 else 2035 2045 $typesql = ''; 2036 2046 2037 2047 if ( !empty($type) ) 2038 2048 $total = ''; 2039 2049 2050 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' "; 2040 2051 if ( $s ) { 2041 2052 $total = ''; 2042 2053 $s = $wpdb->escape($s); 2043 $query = "FROM $wpdb->comments WHERE2044 (c omment_author LIKE '%$s%' OR2045 c omment_author_email LIKE '%$s%' OR2046 c omment_author_url LIKE ('%$s%') OR2047 c omment_author_IP LIKE ('%$s%') OR2048 c omment_content LIKE ('%$s%') ) AND2054 $query .= "AND 2055 (c.comment_author LIKE '%$s%' OR 2056 c.comment_author_email LIKE '%$s%' OR 2057 c.comment_author_url LIKE ('%$s%') OR 2058 c.comment_author_IP LIKE ('%$s%') OR 2059 c.comment_content LIKE ('%$s%') ) AND 2049 2060 $approved 2050 2061 $typesql"; 2051 2062 } else { 2052 $query = "FROM $wpdb->comments $index WHERE$approved $post $typesql";2063 $query .= "AND $approved $post $typesql"; 2053 2064 } 2054 2065 2055 2066 $comments = $wpdb->get_results("SELECT * $query $orderby"); 2056 2067 if ( '' === $total ) 2057 $total = $wpdb->get_var("SELECT COUNT(c omment_ID) $query");2068 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); 2058 2069 2059 2070 update_comment_cache($comments); 2060 2071 … … 2095 2106 $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); 2096 2107 $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); 2097 2108 $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); 2109 $trash_url = esc_url( wp_nonce_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID", "trash-comment_$comment->comment_ID" ) ); 2110 $untrash_url = esc_url( wp_nonce_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID", "untrash-comment_$comment->comment_ID" ) ); 2098 2111 2099 2112 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; 2100 2113 $columns = get_column_headers('edit-comments'); … … 2134 2147 $actions = array(); 2135 2148 2136 2149 if ( $user_can ) { 2137 if ( ' deleted' == $the_comment_status ) {2138 $actions['un approve'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Return this comment to Unapproved status' ) . "'>" . __( 'Return to Pending' ) . '</a>';2139 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID ::deleted=1delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';2150 if ( 'trash' == $the_comment_status ) { 2151 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID::untrash=1 vim-t vim-destructive''>" . __( 'Remove from Trash' ) . '</a>'; 2152 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 2140 2153 } else { 2141 2154 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 2142 2155 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; … … 2152 2165 } 2153 2166 2154 2167 if ( 'spam' == $the_comment_status ) { 2155 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID ::deleted=1delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';2168 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 2156 2169 } else { 2157 2170 $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>'; 2158 $actions[' delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move toTrash') . '</a>';2171 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-t vim-destructive'>" . __('Trash') . '</a>'; 2159 2172 } 2160 2173 2161 2174 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; … … 2176 2189 // Reply and quickedit need a hide-if-no-js span when not added with ajax 2177 2190 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) 2178 2191 $action .= ' hide-if-no-js'; 2192 elseif ($action == 'untrash' && $the_comment_status == 'trash') { 2193 $trash_meta = get_option('wp_trash_meta'); 2194 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id]['status'])) { 2195 if ($trash_meta['comments'][$comment_id]['status'] == '1') 2196 $action .= ' approve'; 2197 else 2198 $action .= ' unapprove'; 2199 } 2200 } 2179 2201 2180 2202 echo "<span class='$action'>$sep$link</span>"; 2181 2203 } -
wp-admin/includes/media.php
1166 1166 'extra_rows' => array(), 1167 1167 ); 1168 1168 1169 $delete_href = wp_nonce_url("post.php?action= delete-post&post=$attachment_id", 'delete-post_' . $attachment_id);1169 $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'delete-post_' . $attachment_id); 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 == 'trash' ) 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' ) ); … … 181 182 exit(); 182 183 break; 183 184 185 case 'trash': 186 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 187 check_admin_referer('trash-post_' . $post_id); 188 189 $post = & get_post($post_id); 190 191 if ( !current_user_can('delete_post', $post_id) ) 192 wp_die( __('You are not allowed to move this post to the trash.') ); 193 194 if ( ! wp_trash_post($post_id) ) 195 wp_die( __('Error in moving to trash...') ); 196 197 $sendback = wp_get_referer(); 198 if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?trashed=1'); 199 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 200 else $sendback = add_query_arg('trashed', 1, $sendback); 201 wp_redirect($sendback); 202 exit(); 203 break; 204 205 case 'untrash': 206 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 207 check_admin_referer('untrash-post_' . $post_id); 208 209 $post = & get_post($post_id); 210 211 if ( !current_user_can('delete_post', $post_id) ) 212 wp_die( __('You are not allowed to remove this post from the trash.') ); 213 214 if ( ! wp_untrash_post($post_id) ) 215 wp_die( __('Error in removing from trash...') ); 216 217 $sendback = wp_get_referer(); 218 if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?untrashed=1'); 219 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 220 else $sendback = add_query_arg('untrashed', 1, $sendback); 221 wp_redirect($sendback); 222 exit(); 223 break; 224 184 225 case 'delete': 185 226 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 186 227 check_admin_referer('delete-post_' . $post_id); -
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
38 38 settings.data._page = pageInput.val(); 39 39 settings.data._url = document.location.href; 40 40 41 if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)42 return showNotice.warn() ? settings : false;43 44 41 return settings; 45 42 }; 46 43 … … 101 98 a.html(n); 102 99 }); 103 100 104 $('span. deleted-count').each( function() {101 $('span.trash-count').each( function() { 105 102 var a = $(this), n; 106 103 n = a.html().replace(/[ ,.]+/g, ''); 107 104 n = parseInt(n,10); 108 105 if ( isNaN(n) ) return; 109 if ( $(settings.target).parents( 'span.delete' ).size() && $('#' + settings.element).is('.deleted,.spam') ) { // we destroyed a deleted or spam comment 110 n--; 111 } else if ( $(settings.target).parents( 'span.delete' ).size() ) { // we deleted a comment 112 n++; 113 } else if ( $('#' + settings.element).is('.deleted') ) { // we approved or spammed a deleted comment 114 n--; 106 if ( $(settings.target).parents( 'span.trash' ).size() ) { // we trashed a comment 107 n = n + 1; 108 } else if ( $('#' + settings.element).is('.trash') ) { // we deleted or untrashed a trash comment 109 n = n - 1; 115 110 } 116 111 if ( n < 0 ) { n = 0; } 117 112 n = n.toString(); -
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=trash&post=$post->ID", 'trash-page_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 220 220 <?php } ?> 221 221 </div> 222 222 -
wp-admin/comment.php
44 44 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 45 45 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 46 46 47 if ( ' deleted' == $comment->comment_status )48 comment_footer_die( __('This comment has been deleted. Please move it out of the Trash if you want to edit it.') );47 if ( 'trash' == $comment->comment_status ) 48 comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); 49 49 50 50 $comment = get_comment_to_edit( $comment_id ); 51 51 … … 166 166 die; 167 167 break; 168 168 169 case 'trashcomment' : 170 case 'untrashcomment' : 171 $comment_id = absint( $_REQUEST['c'] ); 172 $noredir = isset($_REQUEST['noredir']); 173 174 if (!$comment = get_comment($comment_id)) 175 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); 176 if (!current_user_can('edit_post', $comment->comment_post_ID )) 177 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 178 179 if ($action == 'trashcomment') { 180 check_admin_referer( 'trash-comment_' . $comment_id ); 181 wp_trash_comment($comment_id); 182 } 183 else { 184 check_admin_referer( 'untrash-comment_' . $comment_id ); 185 wp_untrash_comment($comment_id); 186 } 187 188 if ('' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' )) 189 wp_redirect( wp_get_referer() ); 190 else if ('' != wp_get_original_referer() && false == $noredir) 191 wp_redirect(wp_get_original_referer()); 192 else 193 wp_redirect(admin_url('edit-comments.php')); 194 195 die; 196 break; 197 169 198 case 'unapprovecomment' : 170 199 $comment_id = absint( $_GET['c'] ); 171 200 check_admin_referer( 'unapprove-comment_' . $comment_id ); -
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 != 'trash') continue; 33 elseif (!$is_trash && $post->post_status == 'trash') 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['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-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['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-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 == 'trash' ) 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 = 'trash'" ); 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); 77 78 if ( !current_user_can('delete_post', $post_id_del) ) 79 wp_die( __('You are not allowed to delete this post.') ); 80 81 if ( $post_del->post_type == 'attachment' ) 82 if ( ! wp_delete_attachment($post_id_del) ) 87 switch ( $doaction ) { 88 case 'trash': 89 foreach( (array) $post_ids as $post_id ) { 90 if ( !current_user_can('delete_post', $post_id) ) 91 wp_die( __('You are not allowed to move this post to the trash.') ); 92 93 if ( !wp_trash_post($post_id) ) 94 wp_die( __('Error in moving to trash...') ); 95 } 96 $location = add_query_arg('message', 4, $location); 97 break; 98 case 'untrash': 99 foreach( (array) $post_ids as $post_id ) { 100 if ( !current_user_can('delete_post', $post_id) ) 101 wp_die( __('You are not allowed to remove this post from the trash.') ); 102 103 if ( !wp_untrash_post($post_id) ) 104 wp_die( __('Error in removing from trash...') ); 105 } 106 $location = add_query_arg('message', 5, $location); 107 break; 108 case 'delete': 109 foreach( (array) $post_ids as $post_id_del ) { 110 if ( !current_user_can('delete_post', $post_id_del) ) 111 wp_die( __('You are not allowed to delete this post.') ); 112 113 if ( !wp_delete_attachment($post_id_del) ) 83 114 wp_die( __('Error in deleting...') ); 84 } 115 } 116 $location = add_query_arg('message', 2, $location); 117 break; 118 } 85 119 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 } 120 $location = remove_query_arg('posted', $location); 121 wp_redirect($location); 122 exit; 97 123 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 98 124 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 99 125 exit; … … 115 141 $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" ); 116 142 } else { 117 143 $start = ( $_GET['paged'] - 1 ) * 25; 118 $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_ parent < 1 LIMIT $start, 25" );144 $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT $start, 25" ); 119 145 $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25); 120 146 } 121 147 … … 135 161 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 136 162 } 137 163 164 $is_trash = (isset($_GET['status']) && $_GET['status'] == 'trash'); 165 138 166 wp_enqueue_script('media'); 139 167 require_once('admin-header.php'); ?> 140 168 … … 153 181 $messages[1] = __('Media attachment updated.'); 154 182 $messages[2] = __('Media deleted.'); 155 183 $messages[3] = __('Error saving media attachment.'); 184 $messages[4] = __('Media moved to Trash.'); 185 $messages[5] = __('Media removed from Trash.'); 156 186 157 187 if ( isset($_GET['message']) && (int) $_GET['message'] ) { 158 188 $message = $messages[$_GET['message']]; … … 180 210 <?php 181 211 $type_links = array(); 182 212 $_num_posts = (array) wp_count_attachments(); 183 $_total_posts = array_sum( $_num_posts );213 $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 184 214 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 185 215 foreach ( $matches as $type => $reals ) 186 216 foreach ( $reals as $real ) 187 217 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; 188 218 189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';219 $class = (empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status'])) ? ' class="current"' : ''; 190 220 $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 221 foreach ( $post_mime_types as $mime_type => $label ) { 192 222 $class = ''; … … 199 229 200 230 $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 231 } 202 $ class = isset($_GET['detached']) ? ' class="current"' : '';203 $type_links[] = '<li><a href="upload.php? detached=1"' . $class . '>' . __('Unattached') . '</a>';232 $type_links[] = '<li><a href="upload.php?detached=1"' . (isset($_GET['detached']) ? ' class="current"' : '') . '>' . __('Unattached') . '</a>'; 233 $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>'; 204 234 205 235 echo implode( " |</li>\n", $type_links) . '</li>'; 206 236 unset($type_links); … … 242 272 <div class="alignleft actions"> 243 273 <select name="action" class="select-action"> 244 274 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 245 <option value="delete"><?php _e('Delete'); ?></option> 246 <?php if ( isset($orphans) ) { ?> 275 <?php if ($is_trash) { ?> 276 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 277 <option value="delete"><?php _e('Delete Permanently'); ?></option> 278 <?php } else { ?> 279 <option value="trash"><?php _e('Move to Trash'); ?></option> 280 <?php } if (isset($orphans)) { ?> 247 281 <option value="attach"><?php _e('Attach to a post'); ?></option> 248 282 <?php } ?> 249 283 </select> … … 251 285 <?php wp_nonce_field('bulk-media'); ?> 252 286 253 287 <?php 254 if ( ! is_singular() && ! isset($_GET['detached'])) {288 if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) { 255 289 $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 290 257 291 $arc_result = $wpdb->get_results( $arc_query ); … … 286 320 287 321 <?php if ( isset($_GET['detached']) ) { ?> 288 322 <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 323 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?> 324 <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 289 325 <?php } ?> 290 326 291 327 </div> … … 341 377 if ( current_user_can('edit_post', $post->ID) ) 342 378 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 343 379 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>";380 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 345 381 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 346 382 if ( current_user_can('edit_post', $post->ID) ) 347 383 $actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>'; … … 398 434 <div class="alignleft actions"> 399 435 <select name="action2" class="select-action"> 400 436 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 401 <option value="delete"><?php _e('Delete'); ?></option> 402 <?php if ( isset($orphans) ) { ?> 437 <?php if ($is_trash) { ?> 438 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 439 <option value="delete"><?php _e('Delete Permanently'); ?></option> 440 <?php } else { ?> 441 <option value="trash"><?php _e('Move to Trash'); ?></option> 442 <?php } if (isset($orphans)) { ?> 403 443 <option value="attach"><?php _e('Attach to a post'); ?></option> 404 444 <?php } ?> 405 445 </select> 406 446 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 447 448 <?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?> 449 <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 450 <?php } ?> 407 451 </div> 408 452 409 453 <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=trash&post=$post->ID", 'trash-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 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); 34 case 'trash': 35 $trashed = 0; 36 foreach( (array) $post_ids as $post_id ) { 37 $post_del = & get_post($post_id); 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 move this post to the trash.') ); 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++; 43 } 42 if ( !wp_trash_post($post_id) ) 43 wp_die( __('Error in moving to trash...') ); 44 45 $trashed++; 44 46 } 45 47 break; 46 case 'edit': 47 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 48 check_admin_referer('bulk-posts'); 48 case 'untrash': 49 $untrashed = 0; 50 foreach( (array) $post_ids as $post_id ) { 51 $post_del = & get_post($post_id); 49 52 50 if ( -1 == $_GET['_status'] ) { 51 $_GET['post_status'] = null; 52 unset($_GET['_status'], $_GET['post_status']); 53 if ( !current_user_can('delete_post', $post_id_del) ) 54 wp_die( __('You are not allowed to remove this post from the trash.') ); 55 56 if ( !wp_untrash_post($post_id) ) 57 wp_die( __('Error in removing from trash...') ); 58 59 $untrashed++; 60 } 61 break; 62 case 'delete': 63 $deleted = 0; 64 foreach( (array) $post_ids as $post_id_del ) { 65 $post_del = & get_post($post_id_del); 66 67 if ( !current_user_can('delete_post', $post_id_del) ) 68 wp_die( __('You are not allowed to delete this post.') ); 69 70 if ( $post_del->post_type == 'attachment' ) { 71 if ( ! wp_delete_attachment($post_id_del) ) 72 wp_die( __('Error in deleting...') ); 53 73 } else { 54 $_GET['post_status'] = $_GET['_status']; 74 if ( !wp_delete_post($post_id_del) ) 75 wp_die( __('Error in deleting...') ); 55 76 } 56 57 $done = bulk_edit_posts($_GET); 77 $deleted++; 58 78 } 59 79 break; 80 case 'edit': 81 if ( -1 == $_GET['_status'] ) { 82 $_GET['post_status'] = null; 83 unset($_GET['_status'], $_GET['post_status']); 84 } else { 85 $_GET['post_status'] = $_GET['_status']; 86 } 87 88 $done = bulk_edit_posts($_GET); 89 break; 60 90 } 61 91 62 92 $sendback = wp_get_referer(); … … 68 98 $done['locked'] = count( $done['locked'] ); 69 99 $sendback = add_query_arg( $done, $sendback ); 70 100 } 71 if ( isset($deleted))101 if (isset($deleted)) 72 102 $sendback = add_query_arg('deleted', $deleted, $sendback); 103 elseif (isset($trashed)) 104 $sendback = add_query_arg('trashed', $trashed, $sendback); 105 elseif (isset($untrashed)) 106 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 73 107 wp_redirect($sendback); 74 108 exit(); 75 109 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { … … 107 141 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); 108 142 endif; ?> 109 143 110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>144 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> 111 145 <div id="message" class="updated fade"><p> 112 146 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { 113 147 printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); … … 123 157 } 124 158 125 159 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { 126 printf( _n( 'Post deleted.', '%s postsdeleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );160 printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); 127 161 unset($_GET['deleted']); 128 162 } 129 163 164 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { 165 printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); 166 unset($_GET['deleted']); 167 } 168 169 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { 170 printf( _n( 'Post removed from the trash.', '%s posts removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 171 unset($_GET['undeleted']); 172 } 173 130 174 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); 131 175 ?> 132 176 </p></div> … … 139 183 if ( empty($locked_post_status) ) : 140 184 $status_links = array(); 141 185 $num_posts = wp_count_posts( 'post', 'readable' ); 142 $total_posts = array_sum( (array) $num_posts ) ;186 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; 143 187 $class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; 144 188 $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 189 … … 190 234 <div class="alignleft actions"> 191 235 <select name="action"> 192 236 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 237 <?php if ($_GET['post_status'] == 'trash') { ?> 238 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 239 <option value="delete"><?php _e('Delete Permanently'); ?></option> 240 <?php } else { ?> 193 241 <option value="edit"><?php _e('Edit'); ?></option> 194 <option value="delete"><?php _e('Delete'); ?></option> 242 <option value="trash"><?php _e('Move to Trash'); ?></option> 243 <?php } ?> 195 244 </select> 196 245 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 197 246 <?php wp_nonce_field('bulk-posts'); ?> … … 235 284 do_action('restrict_manage_posts'); 236 285 ?> 237 286 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 238 287 <?php } if ($_GET['post_status'] == 'trash') { ?> 288 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 239 289 <?php } ?> 240 290 </div> 241 291 … … 270 320 <div class="alignleft actions"> 271 321 <select name="action2"> 272 322 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 323 <?php if ($_GET['post_status'] == 'trash') { ?> 324 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 325 <option value="delete"><?php _e('Delete Permanently'); ?></option> 326 <?php } else { ?> 273 327 <option value="edit"><?php _e('Edit'); ?></option> 274 <option value="delete"><?php _e('Delete'); ?></option> 328 <option value="trash"><?php _e('Move to Trash'); ?></option> 329 <?php } ?> 275 330 </select> 276 331 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 332 <?php if ($_GET['post_status'] == 'trash') { ?> 333 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 334 <?php } ?> 277 335 <br class="clear" /> 278 336 </div> 279 337 <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 == 'trash' ) 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' ) ); … … 140 141 exit(); 141 142 break; 142 143 144 case 'trash': 145 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 146 check_admin_referer('trash-page_' . $post_id); 147 148 $post = & get_post($post_id); 149 150 if ( !current_user_can('delete_page', $page_id) ) 151 wp_die( __('You are not allowed to move this page to the trash.') ); 152 153 if ( !wp_trash_post($post_id) ) 154 wp_die( __('Error in removing from trash...') ); 155 156 $sendback = wp_get_referer(); 157 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?trashed=1'); 158 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 159 else $sendback = add_query_arg('trashed', 1, $sendback); 160 wp_redirect($sendback); 161 exit(); 162 break; 163 164 case 'untrash': 165 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 166 check_admin_referer('untrash-page_' . $post_id); 167 168 $post = & get_post($post_id); 169 170 if ( !current_user_can('delete_page', $page_id) ) 171 wp_die( __('You are not allowed to remove this page form the trash.') ); 172 173 if ( !wp_untrash_post($post_id) ) 174 wp_die( __('Error in removing from trash...') ); 175 176 $sendback = wp_get_referer(); 177 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?untrashed=1'); 178 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 179 else $sendback = add_query_arg('untrashed', 1, $sendback); 180 wp_redirect($sendback); 181 exit(); 182 break; 183 143 184 case 'delete': 144 185 $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 145 186 check_admin_referer('delete-page_' . $page_id); -
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 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); 26 case 'trash': 27 $trashed = 0; 28 foreach( (array) $post_ids as $post_id ) { 29 if ( !current_user_can('delete_page', $post_id) ) 30 wp_die( __('You are not allowed to move this page to the trash.') ); 23 31 24 if ( !current_user_can('delete_page', $post_id_del) ) 25 wp_die( __('You are not allowed to delete this page.') ); 32 if ( !wp_trash_post($post_id) ) 33 wp_die( __('Error in moving to trash...') ); 34 35 $trashed++; 36 } 37 break; 38 case 'untrash': 39 $untrashed = 0; 40 foreach( (array) $post_ids as $post_id ) { 41 if ( !current_user_can('delete_page', $post_id) ) 42 wp_die( __('You are not allowed to remove this page from the trash.') ); 26 43 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++; 35 } 44 if ( !wp_untrash_post($post_id) ) 45 wp_die( __('Error in removing from trash...') ); 46 47 $untrashed++; 36 48 } 37 49 break; 38 case 'edit': 39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 40 check_admin_referer('bulk-pages'); 50 case 'delete': 51 $deleted = 0; 52 foreach( (array) $post_ids as $post_id_del ) { 53 $post_del = & get_post($post_id_del); 41 54 42 if ( -1 == $_GET['_status'] ) { 43 $_GET['post_status'] = null; 44 unset($_GET['_status'], $_GET['post_status']); 55 if ( !current_user_can('delete_page', $post_id_del) ) 56 wp_die( __('You are not allowed to delete this page.') ); 57 58 if ( $post_del->post_type == 'attachment' ) { 59 if ( ! wp_delete_attachment($post_id_del) ) 60 wp_die( __('Error in deleting...') ); 45 61 } else { 46 $_GET['post_status'] = $_GET['_status']; 62 if ( !wp_delete_post($post_id_del) ) 63 wp_die( __('Error in deleting...') ); 47 64 } 48 49 $done = bulk_edit_posts($_GET); 65 $deleted++; 50 66 } 51 67 break; 68 case 'edit': 69 if ( -1 == $_GET['_status'] ) { 70 $_GET['post_status'] = null; 71 unset($_GET['_status'], $_GET['post_status']); 72 } else { 73 $_GET['post_status'] = $_GET['_status']; 74 } 75 76 $done = bulk_edit_posts($_GET); 77 break; 52 78 } 53 79 54 80 $sendback = wp_get_referer(); … … 62 88 } 63 89 if ( isset($deleted) ) 64 90 $sendback = add_query_arg('deleted', $deleted, $sendback); 91 elseif ( isset($trashed) ) 92 $sendback = add_query_arg('trashed', $trashed, $sendback); 93 elseif ( isset($untrashed) ) 94 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 65 95 wp_redirect($sendback); 66 96 exit(); 67 97 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { … … 79 109 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), 80 110 '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 111 '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')) 112 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), 113 'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')) 83 114 ); 84 115 85 116 $post_stati = apply_filters('page_stati', $post_stati); … … 111 142 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> 112 143 </h2> 113 144 114 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>145 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> 115 146 <div id="message" class="updated fade"><p> 116 147 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { 117 148 printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); 118 149 unset($_GET['updated']); 119 150 } 120 121 151 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) { 122 152 printf( _n( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) ); 123 153 unset($_GET['skipped']); 124 154 } 125 126 155 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { 127 156 printf( _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) ); 128 157 unset($_GET['locked']); 129 158 } 130 131 159 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { 132 printf( _n( 'Page deleted.', '%s pagesdeleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );160 printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); 133 161 unset($_GET['deleted']); 134 162 } 135 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); 163 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { 164 printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); 165 unset($_GET['trashed']); 166 } 167 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { 168 printf( _n( 'Page removed from the trash.', '%s pages removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 169 unset($_GET['untrashed']); 170 } 171 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); 136 172 ?> 137 173 </p></div> 138 174 <?php } ?> … … 150 186 if ( empty($locked_post_status) ) : 151 187 $status_links = array(); 152 188 $num_posts = wp_count_posts('page', 'readable'); 153 $total_posts = array_sum( (array) $num_posts ) ;189 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; 154 190 $class = empty($_GET['post_status']) ? ' class="current"' : ''; 155 191 $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 192 foreach ( $post_stati as $status => $label ) { … … 212 248 <div class="alignleft actions"> 213 249 <select name="action"> 214 250 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 251 <?php if ($_GET['post_status'] == 'trash') { ?> 252 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 253 <option value="delete"><?php _e('Delete Permanently'); ?></option> 254 <?php } else { ?> 215 255 <option value="edit"><?php _e('Edit'); ?></option> 216 <option value="delete"><?php _e('Delete'); ?></option> 256 <option value="trash"><?php _e('Move to Trash'); ?></option> 257 <?php } ?> 217 258 </select> 218 259 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 219 260 <?php wp_nonce_field('bulk-pages'); ?> 261 <?php if ($_GET['post_status'] == 'trash') { ?> 262 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 263 <?php } ?> 220 264 </div> 221 265 222 266 <br class="clear" /> … … 251 295 <div class="alignleft actions"> 252 296 <select name="action2"> 253 297 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 298 <?php if ($_GET['post_status'] == 'trash') { ?> 299 <option value="untrash"><?php _e('Remove from Trash'); ?></option> 300 <option value="delete"><?php _e('Delete Permanently'); ?></option> 301 <?php } else { ?> 254 302 <option value="edit"><?php _e('Edit'); ?></option> 255 <option value="delete"><?php _e('Delete'); ?></option> 303 <option value="trash"><?php _e('Move to Trash'); ?></option> 304 <?php } ?> 256 305 </select> 257 306 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 307 <?php if ($_GET['post_status'] == 'trash') { ?> 308 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 309 <?php } ?> 258 310 </div> 259 311 260 312 <br class="clear" />
