Opened 16 years ago
Closed 16 years ago
#9898 closed enhancement (fixed)
edit_post_link() does not accept post $id argument
| Reported by: |
|
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().
Patch mentioned in original submission.