Pass anchor text to 'edit_post_link' and 'edit_comment_link' filters.

props kwight.
fixes #28373.
Built from https://develop.svn.wordpress.org/trunk@28590


git-svn-id: http://core.svn.wordpress.org/trunk@28415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-05-27 13:43:14 +00:00
parent 84422e6d7d
commit 12ea0c3045
1 changed files with 22 additions and 15 deletions

View File

@ -1196,22 +1196,25 @@ function get_edit_post_link( $id = 0, $context = 'display' ) {
*
* @since 1.0.0
*
* @param string $link Optional. Anchor text.
* @param string $text Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int $id Optional. Post ID.
*/
function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
if ( !$post = get_post( $id ) )
function edit_post_link( $text = null, $before = '', $after = '', $id = 0 ) {
if ( ! $post = get_post( $id ) ) {
return;
}
if ( !$url = get_edit_post_link( $post->ID ) )
if ( ! $url = get_edit_post_link( $post->ID ) ) {
return;
}
if ( null === $link )
$link = __('Edit This');
if ( null === $text ) {
$text = __( 'Edit This' );
}
$link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>';
$link = '<a class="post-edit-link" href="' . $url . '">' . $text . '</a>';
/**
* Filter the post edit link anchor tag.
@ -1220,8 +1223,9 @@ function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
*
* @param string $link Anchor tag for the edit link.
* @param int $post_id Post ID.
* @param string $text Anchor text.
*/
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after;
}
/**
@ -1297,20 +1301,22 @@ function get_edit_comment_link( $comment_id = 0 ) {
*
* @since 1.0.0
*
* @param string $link Optional. Anchor text.
* @param string $text Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
*/
function edit_comment_link( $link = null, $before = '', $after = '' ) {
function edit_comment_link( $text = null, $before = '', $after = '' ) {
global $comment;
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
return;
}
if ( null === $link )
$link = __('Edit This');
if ( null === $text ) {
$text = __( 'Edit This' );
}
$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>';
$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $text . '</a>';
/**
* Filter the comment edit link anchor tag.
@ -1319,8 +1325,9 @@ function edit_comment_link( $link = null, $before = '', $after = '' ) {
*
* @param string $link Anchor tag for the edit link.
* @param int $comment_id Comment ID.
* @param string $text Anchor text.
*/
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after;
}
/**