WordPress.org

Make WordPress Core

Changeset 27596


Ignore:
Timestamp:
03/18/2014 10:43:41 PM (7 years ago)
Author:
johnbillion
Message:

Introduce permission checks for post queries and edit links in the At a Glance dashboard widget. Fixes #27132. Props mattheu.

File:
1 edited

Legend:

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

    r27583 r27596  
    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
     
    581587        'posts_per_page' => intval( $args['max'] ),
    582588        'no_found_rows'  => true,
    583         'cache_results'  => false
     589        'cache_results'  => false,
     590        'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
    584591    );
    585592    $posts = new WP_Query( $query_args );
     
    610617            }
    611618
     619            if ( current_user_can( 'edit_post', get_the_ID() ) ) {
     620                /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
     621                $format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' );
     622            } else {
     623                /* translators: 1: relative date, 2: time, 4: post title */
     624                $format = __( '<span>%1$s, %2$s</span> %4$s' );
     625            }
     626
    612627            $text = sprintf(
    613                 /* translators: 1: relative date, 2: time, 4: post title */
    614                 __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' ),
     628                $format,
    615629                $relative,
    616630                get_the_time(),
Note: See TracChangeset for help on using the changeset viewer.