[wp-trac] [WordPress Trac] #12197: edit_post_link() - "Edit Post" shows as link title no matter what $link is entered
WordPress Trac
wp-trac at lists.automattic.com
Thu Feb 11 07:50:39 UTC 2010
#12197: edit_post_link() - "Edit Post" shows as link title no matter what $link is
entered
--------------------------+-------------------------------------------------
Reporter: sc0ttkclark | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Template | Version: 2.9.1
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
Currently when this is used:
{{{
edit_post_link('Edit this Blah Blah');
}}}
Then this is output:
{{{
<a class="post-edit-link" href="link-to-wp-admin-edit" title="Edit
Post">Edit this Blah Blah</a>
}}}
Of course, that's an i18n "Edit Post" but still, this should be
overwritten by the $link parameter (if provided). And even then, if none
is provided the Title should be the same as the Anchor text.
See below for my proposed bug fix:
{{{
/**
* Display edit post link for post.
*
* @since 1.0.0
*
* @param string $link 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 ) )
return;
if ( !$url = get_edit_post_link( $post->ID ) )
return;
if ( null === $link )
$link = __('Edit This');
$link = '<a class="post-edit-link" href="' . $url . '" title="' .
esc_attr( $link ) . '">' . $link . '</a>';
echo $before . apply_filters( 'edit_post_link', $link, $post->ID )
. $after;
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12197>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list