WordPress.org

Make WordPress Core

Ticket #27132: 27132.diff

File 27132.diff, 2.3 KB (added by mattheu, 7 years ago)

Alternative approach + don't display edit links if can't edit.

  • wp-admin/includes/dashboard.php

    diff --git wp-admin/includes/dashboard.php wp-admin/includes/dashboard.php
    index aced544..175f34a 100644
    function wp_dashboard_recent_drafts( $drafts = false ) { 
    429429function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
    430430        $GLOBALS['comment'] =& $comment;
    431431
    432         $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
    433432        $comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
    434         $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
     433
     434        if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     435                $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
     436                $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
     437        } else {
     438                $comment_post_link = "$comment_post_title";
     439        }
     440
    435441        $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
    436442
    437443        $actions_string = '';
    function wp_dashboard_site_activity() { 
    576582 * @return bool False if no posts were found. True otherwise.
    577583 */
    578584function wp_dashboard_recent_posts( $args ) {
     585
    579586        $query_args = array(
    580587                'post_type'      => 'post',
    581588                'post_status'    => $args['status'],
    function wp_dashboard_recent_posts( $args ) { 
    583590                'order'          => $args['order'],
    584591                'posts_per_page' => intval( $args['max'] ),
    585592                'no_found_rows'  => true,
    586                 'cache_results'  => false
     593                'cache_results'  => false,
     594                'perm'           => ( $args['status'] === 'future' ) ? 'editable' : 'readable'
    587595        );
     596
    588597        $posts = new WP_Query( $query_args );
    589598
    590599        if ( $posts->have_posts() ) {
    function wp_dashboard_recent_posts( $args ) { 
    616625                                $relative = date_i18n( __( 'M jS' ), $time );
    617626                        }
    618627
    619                         $text = sprintf(
     628                        if ( current_user_can( 'edit_post', get_the_id() ) ) {
     629                                /* translators: 1: relative date, 2: time, 4: post title */
     630                                $format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' );
     631                        } else {
    620632                                /* translators: 1: relative date, 2: time, 4: post title */
    621                                 __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' ),
     633                                $format = __( '<span>%1$s, %2$s</span> %4$s' );
     634                        }
     635
     636                        $text = sprintf(
     637                                $format,
    622638                                $relative,
    623639                                get_the_time(),
    624640                                get_edit_post_link(),