Consult global comment in get_comment(). Don't show empty edit links.
git-svn-id: http://svn.automattic.com/wordpress/trunk@5328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8d6b81e175
commit
d44752d2ca
|
@ -73,16 +73,20 @@ function get_approved_comments($post_id) {
|
||||||
function &get_comment(&$comment, $output = OBJECT) {
|
function &get_comment(&$comment, $output = OBJECT) {
|
||||||
global $comment_cache, $wpdb;
|
global $comment_cache, $wpdb;
|
||||||
|
|
||||||
if ( empty($comment) )
|
if ( empty($comment) ) {
|
||||||
return null;
|
if ( isset($GLOBALS['comment']) )
|
||||||
|
$_comment = & $GLOBALS['comment'];
|
||||||
if ( is_object($comment) ) {
|
else
|
||||||
|
$_comment = null;
|
||||||
|
} elseif ( is_object($comment) ) {
|
||||||
if ( !isset($comment_cache[$comment->comment_ID]) )
|
if ( !isset($comment_cache[$comment->comment_ID]) )
|
||||||
$comment_cache[$comment->comment_ID] = &$comment;
|
$comment_cache[$comment->comment_ID] = &$comment;
|
||||||
$_comment = & $comment_cache[$comment->comment_ID];
|
$_comment = & $comment_cache[$comment->comment_ID];
|
||||||
} else {
|
} else {
|
||||||
$comment = (int) $comment;
|
$comment = (int) $comment;
|
||||||
if ( !isset($comment_cache[$comment]) ) {
|
if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->id == $comment) ) {
|
||||||
|
$_comment = & $GLOBALS['comment'];
|
||||||
|
} elseif ( !isset($comment_cache[$comment]) ) {
|
||||||
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
|
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
|
||||||
$comment_cache[$comment->comment_ID] = & $_comment;
|
$comment_cache[$comment->comment_ID] = & $_comment;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -296,7 +296,21 @@ function get_edit_post_link( $id = 0 ) {
|
||||||
|
|
||||||
function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
|
function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
if ( $post->post_type == 'attachment' )
|
||||||
|
return;
|
||||||
|
elseif ( $post->post_type == 'page' ) {
|
||||||
|
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$file = 'page';
|
||||||
|
} else {
|
||||||
|
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$file = 'post';
|
||||||
|
}
|
||||||
|
|
||||||
$link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
|
$link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
|
||||||
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
|
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
|
||||||
}
|
}
|
||||||
|
@ -319,8 +333,17 @@ function get_edit_comment_link( $comment_id = 0 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
|
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||||
global $comment;
|
global $comment, $post;
|
||||||
|
|
||||||
|
if ( $post->post_type == 'attachment' )
|
||||||
|
return;
|
||||||
|
elseif ( $post->post_type == 'page' )
|
||||||
|
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||||
|
return;
|
||||||
|
|
||||||
$link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
|
$link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
|
||||||
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
|
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue