Make WordPress Core

Ticket #35392: 35392.3.diff

File 35392.3.diff, 5.9 KB (added by rachelbaker, 10 years ago)

Only show "on" if there is a post title to show

  • src/wp-admin/css/dashboard.css

     
    693693
    694694#activity-widget #the-comment-list .avatar {
    695695        position: absolute;
    696         top: 13px;
     696        top: 12px;
    697697}
    698698
    699699#activity-widget #the-comment-list .dashboard-comment-wrap {
     
    806806}
    807807
    808808#activity-widget #latest-comments #the-comment-list .comment-item {
    809         padding: 1em 12px;
     809        /* the row-actions paragraph is output only for users with 'edit_comment' capabilities,
     810           for other users this needs a min height equal to the gravatar image */
     811        min-height: 50px;
     812        margin: 0;
     813        padding: 12px;
    810814}
    811815
    812816#latest-comments #the-comment-list .pingback {
  • src/wp-admin/css/list-tables.css

     
    896896tr:hover .row-actions,
    897897.mobile .row-actions,
    898898.row-actions.visible,
    899 div.comment-item:hover .row-actions {
     899.comment-item:hover .row-actions {
    900900        position: static;
    901901}
    902902
  • src/wp-admin/includes/dashboard.php

     
    583583function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
    584584        $GLOBALS['comment'] = clone $comment;
    585585
    586         if ( $comment->comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     586        if ( $comment->comment_post_ID > 0 ) {
     587
    587588                $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
    588                 $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
    589                 $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
     589
     590                if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     591                        $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
     592                        $comment_post_link_or_title = "<a href='$comment_post_url'>$comment_post_title</a>";
     593                } else {
     594                        // translators: %s: post title
     595                        $comment_post_link_or_title = sprintf( __( '&#8220;%s&#8221;' ), $comment_post_title );
     596                }
    590597        } else {
    591                 $comment_post_link = '';
     598                $comment_post_link_or_title = '';
    592599        }
    593600
    594601        $actions_string = '';
     
    653660                        $actions_string .= "<span class='$action'>$sep$link</span>";
    654661                }
    655662        }
    656 
    657663?>
    658664
    659                 <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
     665                <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
    660666
    661667                        <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
    662668
     
    664670
    665671                        <div class="dashboard-comment-wrap has-row-actions">
    666672                        <p class="comment-meta">
    667                                 <?php
    668                                 if ( $comment_post_link ) {
     673                        <?php
     674                                if ( $comment_post_link_or_title ) {
    669675                                        printf(
    670                                                 /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
     676                                                /* translators: 1: comment author, 2: post title, 3: notification if the comment is pending */
    671677                                                __( 'From %1$s on %2$s%3$s' ),
    672678                                                '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
    673                                                 $comment_post_link,
    674                                                 ' <span class="approve">' . __( '[Pending]' ) . '</span>'
     679                                                $comment_post_link_or_title,
     680                                                ' <span class="approve" aria-hidden="true">' . __( '[Pending]' ) . '</span>'
    675681                                        );
    676682                                } else {
    677683                                        printf(
    678684                                                /* translators: 1: comment author, 2: notification if the comment is pending */
    679                                                 __( 'From %1$s %2$s' ),
     685                                                __( 'From %1$s%2$s' ),
    680686                                                '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
    681                                                 ' <span class="approve">' . __( '[Pending]' ) . '</span>'
     687                                                ' <span class="approve" aria-hidden="true">' . __( '[Pending]' ) . '</span>'
    682688                                        );
    683689                                }
    684                                 ?>
     690                        ?>
    685691                        </p>
    686692
    687693                        <?php
     
    699705                                $type = esc_html( $type );
    700706                        ?>
    701707                        <div class="dashboard-comment-wrap has-row-actions">
    702                         <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
    703                         <p class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link ); ?></p>
     708                        <p class="comment-meta">
     709                        <?php
     710                                if ( $comment_post_link_or_title ) {
     711                                        /* translators: 1: type of comment, 2: post link or title */
     712                                        printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link_or_title );
     713                                } else {
     714                                        /* translators: 1: type of comment */
     715                                        printf( _x( '%1$s', 'dashboard' ), "<strong>$type</strong>" );
     716                                }
     717                        ?>
     718                        </p>
    704719                        <p class="comment-author"><?php comment_author_link( $comment ); ?></p>
    705720
    706721                        <?php endif; // comment_type ?>
    707722                        <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
     723                        <?php if ( $actions_string ) : ?>
    708724                        <p class="row-actions"><?php echo $actions_string; ?></p>
     725                        <?php endif; ?>
    709726                        </div>
    710                 </div>
     727                </li>
    711728<?php
    712729        $GLOBALS['comment'] = null;
    713730}
     
    877894
    878895        if ( $comments ) {
    879896                echo '<div id="latest-comments" class="activity-block">';
    880                 echo '<h3>' . __( 'Comments' ) . '</h3>';
     897                echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
    881898
    882                 echo '<div id="the-comment-list" data-wp-lists="list:comment">';
     899                echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
    883900                foreach ( $comments as $comment )
    884901                        _wp_dashboard_recent_comments_row( $comment );
    885                 echo '</div>';
     902                echo '</ul>';
    886903
    887                 if ( current_user_can('edit_posts') )
    888                         _get_list_table('WP_Comments_List_Table')->views();
     904                if ( current_user_can( 'edit_posts' ) ) {
     905                        echo '<h4 class="screen-reader-text">' . __( 'View more comments' ) . '</h4>';
     906                        _get_list_table( 'WP_Comments_List_Table' )->views();
     907                }
    889908
    890909                wp_comment_reply( -1, false, 'dashboard', false );
    891910                wp_comment_trashnotice();