[wp-trac] [WordPress Trac] #9898: edit_post_link() does not accept post $id argument

WordPress Trac wp-trac at lists.automattic.com
Thu May 21 18:39:51 GMT 2009


#9898: edit_post_link() does not accept post $id argument
-------------------------+--------------------------------------------------
 Reporter:  coffee2code  |       Owner:                  
     Type:  enhancement  |      Status:  new             
 Priority:  normal       |   Milestone:  Unassigned      
Component:  General      |     Version:  2.8             
 Severity:  normal       |    Keywords:  has-patch tested
-------------------------+--------------------------------------------------
 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()`.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9898>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list