#12197 closed defect (bug) (fixed)
edit_post_link() - "Edit Post" shows as link title no matter what $link is entered
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 3.1 | Priority: | normal |
| Severity: | normal | Version: | 2.9.1 |
| Component: | Template | Keywords: | |
| Focuses: | Cc: |
Description
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;
}
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
patch