Make WordPress Core


Ignore:
Timestamp:
07/30/2009 01:39:34 PM (15 years ago)
Author:
azaozz
Message:

Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r11748 r11749  
    14341434            $attributes = 'class="post-title column-title"' . $style;
    14351435        ?>
    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 &#8220;%s&#8221;'), $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 &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
    14371437        <?php
    14381438            if ( 'excerpt' == $mode )
     
    14401440
    14411441            $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&nbsp;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&amp;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 &#8220;%s&#8221;'), $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&amp;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&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
    14521445            } else {
    1453                 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $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&nbsp;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&amp;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 &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1456                } else {
     1457                    $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1458                }
    14541459            }
    14551460            $actions = apply_filters('post_row_actions', $actions, $post);
     
    16521657        $edit_link = get_edit_post_link( $page->ID );
    16531658        ?>
    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 &#8220;%s&#8221;'), $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 &#8220;%s&#8221;'), $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>
    16551660        <?php
    16561661        $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&nbsp;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&amp;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 &#8220;%s&#8221;'), $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&amp;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&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
    16671665        } else {
    1668             $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $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&nbsp;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&amp;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 &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1676            } else {
     1677                $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1678            }
    16691679        }
    16701680        $actions = apply_filters('page_row_actions', $actions, $page);
     
    19821992 * @since unknown
    19831993 *
    1984  * @param string $status Comment status (approved, spam, deleted, etc)
     1994 * @param string $status Comment status (approved, spam, trash, etc)
    19851995 * @param string $s Term to search for
    19861996 * @param int $start Offset to start at for pagination
     
    20002010
    20012011    if ( 'moderated' == $status ) {
    2002         $approved = "comment_approved = '0'";
     2012        $approved = "c.comment_approved = '0'";
    20032013        $total = $count->moderated;
    20042014    } elseif ( 'approved' == $status ) {
    2005         $approved = "comment_approved = '1'";
     2015        $approved = "c.comment_approved = '1'";
    20062016        $total = $count->approved;
    20072017    } elseif ( 'spam' == $status ) {
    2008         $approved = "comment_approved = 'spam'";
     2018        $approved = "c.comment_approved = 'spam'";
    20092019        $total = $count->spam;
    2010     } elseif ( 'deleted' == $status ) {
    2011         $approved = "comment_approved = 'deleted'";
    2012         $total = $count->deleted;
     2020    } elseif ( 'trash' == $status ) {
     2021        $approved = "c.comment_approved = 'trash'";
     2022        $total = $count->trash;
    20132023    } else {
    2014         $approved = "( comment_approved = '0' OR comment_approved = '1' )";
     2024        $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
    20152025        $total = $count->moderated + $count->approved;
    2016         $index = 'USE INDEX (comment_date_gmt)';
     2026        $index = 'USE INDEX (c.comment_date_gmt)';
    20172027    }
    20182028
    20192029    if ( $post ) {
    20202030        $total = '';
    2021         $post = " AND comment_post_ID = '$post'";
    2022         $orderby = "ORDER BY comment_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";
    20232033    } else {
    20242034        $post = '';
    2025         $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
     2035        $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
    20262036    }
    20272037
    20282038    if ( 'comment' == $type )
    2029         $typesql = "AND comment_type = ''";
     2039        $typesql = "AND c.comment_type = ''";
    20302040    elseif ( 'pings' == $type )
    2031         $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
     2041        $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
    20322042    elseif ( !empty($type) )
    2033         $typesql = $wpdb->prepare("AND comment_type = %s", $type);
     2043        $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
    20342044    else
    20352045        $typesql = '';
     
    20382048        $total = '';
    20392049
     2050    $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
    20402051    if ( $s ) {
    20412052        $total = '';
    20422053        $s = $wpdb->escape($s);
    2043         $query = "FROM $wpdb->comments WHERE
    2044             (comment_author LIKE '%$s%' OR
    2045             comment_author_email LIKE '%$s%' OR
    2046             comment_author_url LIKE ('%$s%') OR
    2047             comment_author_IP LIKE ('%$s%') OR
    2048             comment_content LIKE ('%$s%') ) AND
     2054        $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
    20492060            $approved
    20502061            $typesql";
    20512062    } else {
    2052         $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
    2053     }
    2054 
     2063        $query .= "AND $approved $post $typesql";
     2064    }
     2065   
    20552066    $comments = $wpdb->get_results("SELECT * $query $orderby");
    20562067    if ( '' === $total )
    2057         $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
     2068        $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
    20582069
    20592070    update_comment_cache($comments);
     
    20962107    $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
    20972108    $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" ) );
    20982111
    20992112    echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
     
    21352148
    21362149                if ( $user_can ) {
    2137                     if ( 'deleted' == $the_comment_status ) {
    2138                         $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;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=1 delete 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>';
    21402153                    } else {
    21412154                        $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>';
     
    21532166
    21542167                        if ( 'spam' == $the_comment_status ) {
    2155                             $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
     2168                            $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
    21562169                        } else {
    21572170                            $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 to Trash') . '</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>';
    21592172                        }
    21602173
     
    21772190                        if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
    21782191                            $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                        }
    21792201
    21802202                        echo "<span class='$action'>$sep$link</span>";
Note: See TracChangeset for help on using the changeset viewer.