Make WordPress Core

Changeset 34038


Ignore:
Timestamp:
09/11/2015 05:55:27 AM (9 years ago)
Author:
wonderboymusic
Message:

After [34015], handle orphaned comments in the Dashboard comments widget. Pass full $comment versus just passing the comment ID when possible.

See #33710.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r34006 r34038  
    557557    $GLOBALS['comment'] =& $comment;
    558558
    559     $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
    560 
    561     if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     559    if ( $comment->comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     560        $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
    562561        $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
    563562        $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
    564563    } else {
    565         $comment_post_link = $comment_post_title;
     564        $comment_post_link = '';
    566565    }
    567566
     
    600599
    601600        if ( '1' === $comment->comment_approved ) {
    602             $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link() ) . '">' . _x( 'View', 'verb' ) . '</a>';
     601            $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . _x( 'View', 'verb' ) . '</a>';
    603602        }
    604603
     
    631630?>
    632631
    633         <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
     632        <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ) ); ?>>
    634633
    635634            <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
     
    639638            <div class="dashboard-comment-wrap has-row-actions">
    640639            <h4 class="comment-meta">
    641                 <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
    642                     '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
     640                <?php
     641                if ( $comment_post_link ) {
     642                    printf(
     643                        /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
     644                        __( 'From %1$s on %2$s%3$s' ),
     645                        '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
     646                        $comment_post_link,
     647                        ' <span class="approve">' . __( '[Pending]' ) . '</span>'
     648                    );
     649                } else {
     650                    printf(
     651                        /* translators: 1: comment author, 2: notification if the comment is pending */
     652                        __( 'From %1$s %2$s' ),
     653                        '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
     654                        ' <span class="approve">' . __( '[Pending]' ) . '</span>'
     655                    );
     656                }
     657                ?>
    643658            </h4>
    644659
     
    660675            <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
    661676            <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link ); ?></h4>
    662             <p class="comment-author"><?php comment_author_link(); ?></p>
     677            <p class="comment-author"><?php comment_author_link( $comment ); ?></p>
    663678
    664679            <?php endif; // comment_type ?>
    665             <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
     680            <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
    666681            <p class="row-actions"><?php echo $actions_string; ?></p>
    667682            </div>
    668683        </div>
    669684<?php
     685    $GLOBALS['comment'] = null;
    670686}
    671687
  • trunk/src/wp-includes/pluggable.php

    r33891 r34038  
    13631363
    13641364    $comment = get_comment( $comment_id );
    1365     if ( empty( $comment ) )
     1365    if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
    13661366        return false;
    13671367
     
    18221822     * @param WP_User    $user   The current user object.
    18231823     * @param string     $token  The user's session token.
    1824      */ 
     1824     */
    18251825    do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token );
    18261826
Note: See TracChangeset for help on using the changeset viewer.