Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#9898 closed enhancement (fixed)

edit_post_link() does not accept post $id argument

Reported by: coffee2code's profile coffee2code Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: General Keywords: has-patch tested
Focuses: Cc:

Description

edit_post_link() is currently limited to only generating an "Edit" link for posts when called in the loop (or context where global $post is set).

edit_post_link() in wp-includes/link-template.php is used to display the "Edit" link for posts/pages. It does not accept an argument for the post and assumes the global $post. While get_edit_post_link() does accept an $id argument, that function merely returns the url, whereas edit_post_link() dresses that url with the link markup.

The attached patch adds $id as an optional argument. Current behavior is maintained, but you can now specify the ID of the post to get its marked-up edit link.

This allows for non-loop handling of posts to still be able to generate a canonical edit post link without having to reproduce the contents of the already existing core function.

Also, I corrected the function's phpdoc description which seems to have just been copied from get_edit_post_link().

Attachments (1)

9898.diff (869 bytes) - added by coffee2code 16 years ago.
Patch mentioned in original submission.

Download all attachments as: .zip

Change History (3)

@coffee2code
16 years ago

Patch mentioned in original submission.

#1 @ryan
16 years ago

  • Milestone changed from Unassigned to 2.8

#2 @ryan
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11425]) Add post ID arg to edit_post_link(). Props coffee2code. fixes #9898

Note: See TracTickets for help on using tickets.