From 12ea0c3045d3e1d78f9b9b2d8d9c78ee29edeb12 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 27 May 2014 13:43:14 +0000 Subject: [PATCH] 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 --- wp-includes/link-template.php | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 436b6a0ec4..59ff4b9dc8 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -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 = '' . $link . ''; + $link = '' . $text . ''; /** * 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 = '' . $link . ''; + $link = '' . $text . ''; /** * 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; } /**