Changeset 11749
- Timestamp:
- 07/30/2009 01:39:34 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r11731 r11749 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() ); … … 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 -
trunk/wp-admin/comment.php
r11731 r11749 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 ); … … 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'] ); -
trunk/wp-admin/edit-attachment-rows.php
r11380 r11749 29 29 $posts_columns = get_column_headers('upload'); 30 30 $hidden = get_hidden_columns('upload'); 31 while (have_posts()) : the_post(); 31 32 while ( have_posts() ) : the_post(); 33 34 if ( $is_trash && $post->post_status != 'trash' ) 35 continue; 36 elseif ( !$is_trash && $post->post_status == 'trash' ) 37 continue; 38 32 39 $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; 33 40 global $current_user; 34 41 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 35 42 $att_title = _draft_or_post_title(); 36 37 43 ?> 38 44 <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top"> … … 61 67 <td <?php echo $attributes ?>><?php 62 68 if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { 63 ?> 64 69 if ( $is_trash ) echo $thumb; 70 else { 71 ?> 65 72 <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"> 66 73 <?php echo $thumb; ?> … … 68 75 69 76 <?php } 77 } 70 78 ?></td> 71 79 <?php … … 75 83 case 'media': 76 84 ?> 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 />85 <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 86 <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?> 79 87 <p> 80 88 <?php 81 89 $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>'; 90 if ( $is_trash && current_user_can('delete_post', $post->ID) ) { 91 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; 92 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 93 } else { 94 if ( current_user_can('edit_post', $post->ID) ) 95 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 96 if ( current_user_can('delete_post', $post->ID) ) 97 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 98 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 99 } 87 100 $action_count = count($actions); 88 101 $i = 0; -
trunk/wp-admin/edit-comments.php
r11741 r11749 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']; … … 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 … … 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 ); … … 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 … … 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; 110 111 if ( $approved > 0 || $deleted > 0 || $destroyed > 0 || $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; 115 116 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spam > 0 ) { 112 117 echo '<div id="moderated" class="updated fade"><p>'; 113 118 … … 120 125 echo '<br />'; 121 126 } 127 if ( $trashed > 0 ) { 128 printf( _n( '%s comment moved to the trash', '%s comments moved to the trash', $trashed ), $trashed ); 129 echo '<br />'; 130 } 131 if ( $untrashed > 0 ) { 132 printf( _n( '%s comment removed from the trash', '%s comments removed from the trash', $untrashed ), $untrashed ); 133 echo '<br />'; 134 } 122 135 if ( $deleted > 0 ) { 123 printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); 124 echo '<br />'; 125 } 126 if ( $destroyed > 0 ) { 127 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed ); 136 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 128 137 echo '<br />'; 129 138 } … … 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'; … … 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>261 <?php endif; ?> 262 <?php if ( ' deleted' == $comment_status || 'spam' == $comment_status ): ?>263 <option value="de stroy"><?php _e('Delete Permanently'); ?></option>268 <?php if ( 'trash' == $comment_status ): ?> 269 <option value="untrash"><?php _e('Restore'); ?></option> 270 <?php endif; ?> 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> … … 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 } ?> … … 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>357 <?php endif; ?> 358 <?php if ( ' deleted' == $comment_status || 'spam' == $comment_status ): ?>359 <option value="de stroy"><?php _e('Delete Permanently'); ?></option>364 <?php if ( 'trash' == $comment_status ): ?> 365 <option value="untrash"><?php _e('Restore'); ?></option> 366 <?php endif; ?> 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> … … 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); ?> -
trunk/wp-admin/edit-form-advanced.php
r11383 r11749 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> -
trunk/wp-admin/edit-form-comment.php
r11739 r11749 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"> -
trunk/wp-admin/edit-page-form.php
r11383 r11749 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> -
trunk/wp-admin/edit-pages.php
r11743 r11749 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 ) { 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.') ); 31 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.') ); 43 44 if ( !wp_untrash_post($post_id) ) 45 wp_die( __('Error in removing from trash...') ); 46 47 $untrashed++; 48 } 49 break; 17 50 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); 23 24 if ( !current_user_can('delete_page', $post_id_del) ) 25 wp_die( __('You are not allowed to delete this page.') ); 26 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++; 51 $deleted = 0; 52 foreach( (array) $post_ids as $post_id_del ) { 53 $post_del = & get_post($post_id_del); 54 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...') ); 61 } else { 62 if ( !wp_delete_post($post_id_del) ) 63 wp_die( __('Error in deleting...') ); 35 64 } 65 $deleted++; 36 66 } 37 67 break; 38 68 case 'edit': 39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 40 check_admin_referer('bulk-pages'); 41 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); 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']; 50 74 } 75 76 $done = bulk_edit_posts($_GET); 51 77 break; 52 78 } … … 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(); … … 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 … … 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'] ) { … … 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> … … 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>'; … … 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('Restore'); ?></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 … … 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('Restore'); ?></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 -
trunk/wp-admin/edit.php
r11743 r11749 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 ) { 34 case 'trash': 35 $trashed = 0; 36 foreach( (array) $post_ids as $post_id ) { 37 $post_del = & get_post($post_id); 38 39 if ( !current_user_can('delete_post', $post_id_del) ) 40 wp_die( __('You are not allowed to move this post to the trash.') ); 41 42 if ( !wp_trash_post($post_id) ) 43 wp_die( __('Error in moving to trash...') ); 44 45 $trashed++; 46 } 47 break; 48 case 'untrash': 49 $untrashed = 0; 50 foreach( (array) $post_ids as $post_id ) { 51 $post_del = & get_post($post_id); 52 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; 25 62 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); 31 32 if ( !current_user_can('delete_post', $post_id_del) ) 33 wp_die( __('You are not allowed to delete this post.') ); 34 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++; 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...') ); 73 } else { 74 if ( !wp_delete_post($post_id_del) ) 75 wp_die( __('Error in deleting...') ); 43 76 } 77 $deleted++; 44 78 } 45 79 break; 46 80 case 'edit': 47 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 48 check_admin_referer('bulk-posts'); 49 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); 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']; 58 86 } 87 88 $done = bulk_edit_posts($_GET); 59 89 break; 60 90 } … … 71 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(); … … 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'] ) { … … 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']); 162 } 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']); 128 172 } 129 173 … … 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>'; … … 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('Restore'); ?></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" /> … … 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> … … 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('Restore'); ?></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> -
trunk/wp-admin/includes/dashboard.php
r11741 r11749 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 ) { -
trunk/wp-admin/includes/media.php
r11704 r11749 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(); -
trunk/wp-admin/includes/post.php
r11534 r11749 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 … … 859 860 $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; 860 861 $q['post_type'] = 'attachment'; 861 $q['post_status'] = 'any';862 $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'any'; 862 863 $media_per_page = get_user_option('upload_per_page'); 863 864 if ( empty($media_per_page) ) -
trunk/wp-admin/includes/template.php
r11748 r11749 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 ) … … 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) . "'>" . __('Restore') . "</a>"; 1444 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 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); … … 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) . "'>" . __('Restore') . "</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); … … 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 … … 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 = ''; … … 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";2053 } 2054 2063 $query .= "AND $approved $post $typesql"; 2064 } 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); … … 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'>"; … … 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''>" . __( 'Restore' ) . '</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>'; … … 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 … … 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>"; -
trunk/wp-admin/js/common.dev.js
r11731 r11749 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 () { -
trunk/wp-admin/js/common.js
r11731 r11749 1 var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("# doaction, #doaction2").click(function(){if(d('select[name="action"]').val()=="destroy"||d('select[name="action2"]').val()=="destroy"){return showNotice.warn()}});d("#destroy_all, #destroy_all2").click(function(){return showNotice.warn()});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b(".turbo-nag");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()});1 var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b(".turbo-nag");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()}); -
trunk/wp-admin/js/edit-comments.dev.js
r11731 r11749 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 }; … … 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; } -
trunk/wp-admin/js/edit-comments.js
r11731 r11749 1 var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href; if("undefined"!=showNotice&&j.data.action&&j.data.action=="delete-comment"&&j.data.deleted){return showNotice.warn()?j:false}return j};d=function(j,k,l){if(k<f){return}g.val(j.toString());if(l){f=k}a("span.total-type-count").each(function(){var m=a(this),o;o=g.val().toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.deleted-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.delete").size()&&a("#"+j.element).is(".deleted,.spam")){o--}else{if(a(j.target).parents("span.delete").size()){o++}else{if(a("#"+j.element).is(".deleted")){o--}}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f<j.parsed.responses[0].supplemental.time){d(j.parsed.responses[0].supplemental.total,j.parsed.responses[0].supplemental.time,true);if(a.trim(j.parsed.responses[0].supplemental.pageLinks)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(j.parsed.responses[0].supplemental.pageLinks))}else{if("undefined"!=typeof j.parsed.responses[0].supplemental.pageLinks){a(".tablenav-pages").find(".page-numbers").remove()}}}else{var k=parseInt(g.val(),10);if(k--<0){k=0}d(k,l,false)}if(theExtraList.size()==0||theExtraList.children().size()==0){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:c,delAfter:b,addColor:"none"})};commentReply={init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send()});a("input#author, input#author-email, input#author-url",b).keypress(function(c){if(c.which==13){commentReply.send();c.preventDefault();return false}});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20<j){window.scroll(0,j-h+35)}else{if(l-20<m){window.scroll(0,l-35)}}a("#replycontent").focus().keyup(function(n){if(n.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;b.comments_listing=this.comments_listing;a.ajax({type:"POST",url:wpListL10n.url,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}if("edit-comment"==this.act){a(this.o).remove()}e=e.responses[0];g=e.data;a(g).hide();a("#replyrow").after(g);this.o=f="#comment-"+e.id;this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600);a.fn.wpList.process(a(f))},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);1 var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;return j};d=function(j,k,l){if(k<f){return}g.val(j.toString());if(l){f=k}a("span.total-type-count").each(function(){var m=a(this),o;o=g.val().toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.trash-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.trash").size()){o=o+1}else{if(a("#"+j.element).is(".trash")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f<j.parsed.responses[0].supplemental.time){d(j.parsed.responses[0].supplemental.total,j.parsed.responses[0].supplemental.time,true);if(a.trim(j.parsed.responses[0].supplemental.pageLinks)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(j.parsed.responses[0].supplemental.pageLinks))}else{if("undefined"!=typeof j.parsed.responses[0].supplemental.pageLinks){a(".tablenav-pages").find(".page-numbers").remove()}}}else{var k=parseInt(g.val(),10);if(k--<0){k=0}d(k,l,false)}if(theExtraList.size()==0||theExtraList.children().size()==0){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:c,delAfter:b,addColor:"none"})};commentReply={init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send()});a("input#author, input#author-email, input#author-url",b).keypress(function(c){if(c.which==13){commentReply.send();c.preventDefault();return false}});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20<j){window.scroll(0,j-h+35)}else{if(l-20<m){window.scroll(0,l-35)}}a("#replycontent").focus().keyup(function(n){if(n.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;b.comments_listing=this.comments_listing;a.ajax({type:"POST",url:wpListL10n.url,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}if("edit-comment"==this.act){a(this.o).remove()}e=e.responses[0];g=e.data;a(g).hide();a("#replyrow").after(g);this.o=f="#comment-"+e.id;this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600);a.fn.wpList.process(a(f))},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery); -
trunk/wp-admin/media.php
r11383 r11749 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 -
trunk/wp-admin/page.php
r11380 r11749 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 ) { … … 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']); -
trunk/wp-admin/post.php
r11380 r11749 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 ) { … … 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']); -
trunk/wp-admin/upload.php
r11715 r11749 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']; 73 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) ) 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 80 wp_redirect($_SERVER['HTTP_REFERER']); 81 82 $location = 'upload.php'; 83 if ( $referer = wp_get_referer() ) { 84 if ( false !== strpos($referer, 'upload.php') ) 85 $location = $referer; 86 } 87 88 switch ( $doaction ) { 89 case 'trash': 90 foreach( (array) $post_ids as $post_id ) { 91 if ( !current_user_can('delete_post', $post_id) ) 92 wp_die( __('You are not allowed to move this post to the trash.') ); 93 94 if ( !wp_trash_post($post_id) ) 95 wp_die( __('Error in moving to trash...') ); 96 } 97 $location = add_query_arg('message', 4, $location); 98 break; 99 case 'untrash': 100 foreach( (array) $post_ids as $post_id ) { 101 if ( !current_user_can('delete_post', $post_id) ) 102 wp_die( __('You are not allowed to remove this post from the trash.') ); 103 104 if ( !wp_untrash_post($post_id) ) 105 wp_die( __('Error in restoring from trash...') ); 106 } 107 $location = add_query_arg('message', 5, $location); 108 break; 109 case 'delete': 110 foreach( (array) $post_ids as $post_id_del ) { 111 if ( !current_user_can('delete_post', $post_id_del) ) 112 wp_die( __('You are not allowed to delete this post.') ); 113 114 if ( !wp_delete_attachment($post_id_del) ) 83 115 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 } 116 } 117 $location = add_query_arg('message', 2, $location); 118 break; 119 } 120 121 $location = remove_query_arg('posted', $location); 122 wp_redirect($location); 123 exit; 97 124 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 98 125 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); … … 116 143 } else { 117 144 $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" );145 $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 146 $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25); 120 147 } … … 136 163 } 137 164 165 $is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' ); 166 138 167 wp_enqueue_script('media'); 139 168 require_once('admin-header.php'); ?> … … 154 183 $messages[2] = __('Media deleted.'); 155 184 $messages[3] = __('Error saving media attachment.'); 185 $messages[4] = __('Media moved to Trash.'); 186 $messages[5] = __('Media removed from Trash.'); 156 187 157 188 if ( isset($_GET['message']) && (int) $_GET['message'] ) { … … 181 212 $type_links = array(); 182 213 $_num_posts = (array) wp_count_attachments(); 183 $_total_posts = array_sum( $_num_posts );214 $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 184 215 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 185 216 foreach ( $matches as $type => $reals ) … … 187 218 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; 188 219 189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';220 $class = ( empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status']) ) ? ' class="current"' : ''; 190 221 $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 222 foreach ( $post_mime_types as $mime_type => $label ) { … … 200 231 $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 232 } 202 $ class = isset($_GET['detached']) ? ' class="current"' : '';203 $type_links[] = '<li><a href="upload.php? detached=1"' . $class . '>' . __('Unattached') . '</a>';233 $type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>'; 234 $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 235 205 236 echo implode( " |</li>\n", $type_links) . '</li>'; … … 243 274 <select name="action" class="select-action"> 244 275 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 245 <option value="delete"><?php _e('Delete'); ?></option> 246 <?php if ( isset($orphans) ) { ?> 276 <?php if ( $is_trash ) { ?> 277 <option value="untrash"><?php _e('Restore'); ?></option> 278 <option value="delete"><?php _e('Delete Permanently'); ?></option> 279 <?php } else { ?> 280 <option value="trash"><?php _e('Move to Trash'); ?></option> 281 <?php } if ( isset($orphans) ) { ?> 247 282 <option value="attach"><?php _e('Attach to a post'); ?></option> 248 283 <?php } ?> … … 252 287 253 288 <?php 254 if ( ! is_singular() && ! isset($_GET['detached'])) {289 if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) { 255 290 $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 291 … … 287 322 <?php if ( isset($_GET['detached']) ) { ?> 288 323 <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 324 <?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?> 325 <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 289 326 <?php } ?> 290 327 … … 342 379 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 343 380 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>";381 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 345 382 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 346 383 if ( current_user_can('edit_post', $post->ID) ) … … 399 436 <select name="action2" class="select-action"> 400 437 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 401 <option value="delete"><?php _e('Delete'); ?></option> 402 <?php if ( isset($orphans) ) { ?> 438 <?php if ($is_trash) { ?> 439 <option value="untrash"><?php _e('Restore'); ?></option> 440 <option value="delete"><?php _e('Delete Permanently'); ?></option> 441 <?php } else { ?> 442 <option value="trash"><?php _e('Move to Trash'); ?></option> 443 <?php } if (isset($orphans)) { ?> 403 444 <option value="attach"><?php _e('Attach to a post'); ?></option> 404 445 <?php } ?> 405 446 </select> 406 447 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 448 449 <?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?> 450 <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 451 <?php } ?> 407 452 </div> 408 453 -
trunk/wp-admin/wp-admin.css
r11731 r11749 410 410 411 411 #doaction, 412 #doaction2 { 412 #doaction2, 413 #post-query-submit { 413 414 margin-right: 8px; 414 415 } … … 445 446 } 446 447 447 .unapproved .approve, .spam .approve, .deleted .approve { 448 .unapproved .approve, 449 .spam .approve, 450 .trash .approve { 448 451 display: inline; 449 452 } -
trunk/wp-app.php
r11416 r11749 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 } -
trunk/wp-includes/comment.php
r11741 r11749 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' )"; … … 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 ); 700 701 $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); 699 $where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id ); 700 $where .= "p.post_status <> 'trash'"; 701 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 ) { … … 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); 747 748 $comment = get_comment($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 } 749 755 750 756 if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) … … 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 * … … 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) { … … 785 851 786 852 if ( $approved == NULL ) 787 return 'deleted';853 return false; 788 854 elseif ( $approved == '1' ) 789 855 return 'approved'; … … 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; … … 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 1108 switch ( $comment_status ) { … … 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: … … 1082 1144 1083 1145 return true; 1084 }1085 1086 /**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 1146 } 1121 1147 -
trunk/wp-includes/functions.php
r11741 r11749 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 * … … 3349 3347 */ 3350 3348 function wp_scheduled_delete() { 3351 $t o_delete = get_option('wp_scheduled_delete');3352 if ( !is_array($to_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); -
trunk/wp-includes/post.php
r11734 r11749 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']; … … 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( ); … … 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; … … 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 */ … … 1201 1211 1202 1212 do_action('deleted_post', $postid); 1213 1214 return $post; 1215 } 1216 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); 1203 1279 1204 1280 return $post; … … 2587 2663 if ( 'attachment' != $post->post_type ) 2588 2664 return false; 2665 2666 if ( 'trash' != $post->post_status ) 2667 return wp_trash_post($postid); 2668 2669 $trash_meta = get_option('wp_trash_meta'); 2670 if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { 2671 unset($trash_meta['posts'][$postid]); 2672 update_option('wp_trash_meta', $trash_meta); 2673 } 2589 2674 2590 2675 $meta = wp_get_attachment_metadata( $postid ); -
trunk/wp-includes/query.php
r11606 r11749 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'] ) { -
trunk/wp-includes/script-loader.php
r11742 r11749 61 61 $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); 62 62 63 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '200907 20' );63 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090730' ); 64 64 $scripts->add_data( 'common', 'group', 1 ); 65 65 $scripts->localize( 'common', 'commonL10n', array( … … 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 ) ); … … 249 249 $scripts->add_data( 'user-profile', 'group', 1 ); 250 250 251 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '200907 20' );251 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090730' ); 252 252 $scripts->add_data( 'admin-comments', 'group', 1 ); 253 253 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( -
trunk/wp-settings.php
r11702 r11749 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 538 544 require (ABSPATH . WPINC . '/vars.php');
Note: See TracChangeset
for help on using the changeset viewer.