Make WordPress Core

Changeset 10082


Ignore:
Timestamp:
12/06/2008 03:59:03 AM (16 years ago)
Author:
markjaquith
Message:

Cron order for single-post Edit Comments page. Remember Single Post when searching, switching comment statuses, and filtering comment types

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r10067 r10082  
    1313enqueue_comment_hotkeys_js();
    1414
     15$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
     16
    1517if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
    1618    check_admin_referer('bulk-spam-delete', '_spam_nonce');
     
    1921    $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
    2022
    21     wp_redirect('edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam);
     23    $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
     24    if ( $post_id )
     25        $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
     26    wp_redirect( $redirect_to );
    2227} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
    2328    check_admin_referer('bulk-comments');
     
    2732    foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
    2833        $comment_id = (int) $comment_id;
    29         $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
    30 
    31         if ( !current_user_can('edit_post', $post_id) )
     34        $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
     35
     36        if ( !current_user_can('edit_post', $_post_id) )
    3237            continue;
    3338
     
    5358
    5459    $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
     60    if ( $post_id )
     61        $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
    5562    if ( isset($_REQUEST['apage']) )
    5663        $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
     
    6774}
    6875
    69 $post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0;
    70 
    7176if ( $post_id )
    7277    $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
     
    8994<h2><?php echo wp_specialchars( $title );
    9095if ( isset($_GET['s']) && $_GET['s'] )
    91     printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
     96    printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( wp_specialchars( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
    9297</h2>
    9398
     
    125130<?php
    126131$status_links = array();
    127 $num_comments = wp_count_comments();
     132$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
    128133//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
    129134//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
    130135$stati = array(
     136        'all' => __ngettext_noop('All', 'All'), // singular not used
    131137        'moderated' => __ngettext_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
    132138        'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
     
    134140    );
    135141$class = ( '' === $comment_status ) ? ' class="current"' : '';
    136 $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
    137 $type = ( !$comment_type && 'all' != $comment_type ) ? '' : "&amp;comment_type=$comment_type";
     142// $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
     143$link = 'edit-comments.php';
     144if ( !empty($comment_type) && 'all' != $comment_type )
     145    $link = add_query_arg( 'comment_type', $comment_type, $link );
    138146foreach ( $stati as $status => $label ) {
    139147    $class = '';
    140148
    141     if ( $status == $comment_status )
     149    if ( str_replace( 'all', '', $status ) == $comment_status )
    142150        $class = ' class="current"';
    143151    if ( !isset( $num_comments->$status ) )
    144152        $num_comments->$status = 10;
    145 
    146     $status_links[] = "<li class='$status'><a href='edit-comments.php?comment_status=$status$type'$class>" . sprintf(
     153    if ( 'all' != $status )
     154        $link = add_query_arg( 'comment_status', $status, $link );
     155    if ( $post_id )
     156        $link = add_query_arg( 'p', absint( $post_id ), $link );
     157    /*
     158    // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
     159    if ( !empty( $_GET['s'] ) )
     160        $link = add_query_arg( 's', attribute_escape( stripslashes( $_GET['s'] ) ), $link );
     161    */
     162    $status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
    147163        __ngettext( $label[0], $label[1], $num_comments->$status ),
    148164        number_format_i18n( $num_comments->$status )
     
    190206
    191207<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
     208<?php if ( $post_id ) : ?>
     209<input type="hidden" name="p" value="<?php echo intval( $post_id ); ?>" />
     210<?php endif; ?>
    192211<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
    193212<input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?>" />
  • trunk/wp-admin/includes/template.php

    r10071 r10082  
    18911891        $approved = "( comment_approved = '0' OR comment_approved = '1' )";
    18921892
    1893     if ( $post )
     1893    if ( $post ) {
    18941894        $post = " AND comment_post_ID = '$post'";
    1895     else
     1895        $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
     1896    } else {
    18961897        $post = '';
     1898        $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
     1899    }
    18971900
    18981901    if ( 'comment' == $type )
     
    19171920            $approved
    19181921            $typesql
    1919             ORDER BY comment_date_gmt DESC LIMIT $start, $num");
     1922            $orderby");
    19201923    } else {
    1921         $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql ORDER BY comment_date_gmt DESC LIMIT $start, $num" );
     1924        $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
    19221925    }
    19231926
Note: See TracChangeset for help on using the changeset viewer.