Opened 6 years ago
Closed 6 years ago
#40780 closed enhancement (fixed)
Update docblocks & parameters in wp-includes/link-template.php for post-related functions
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.8 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | docs | Cc: |
Description
The following functions have docblocks and parameters that appear to only accept the post ID, but the underlying code calls get_post()
so either post ID or a post object can be accepted.
- get_post_permalink()
- get_edit_post_link()
- edit_post_link()
- get_delete_post_link()
Attachments (2)
Change History (8)
#3
in reply to:
↑ 2
@
6 years ago
In your change at line 267, you call
get_post_status
with a WP_Post object, but that function takes a post ID - maybe change to$post->ID
? Also I want to make sure the $id isn't used elsewhere.
Actually thats wrong :) I was looking at outdated docs! It should work as is.
#4
@
6 years ago
Maybe the changes should just be for the documentation and don't change the variable names?
#5
@
6 years ago
- Keywords has-patch added; needs-refresh removed
- Milestone changed from Awaiting Review to 4.9
I've iterated the patch with 40780.diff in what I think is a fair compromise.
I think we're fine keeping the $id
parameter since it's so consistent between the functions already, but there's definitely value in better documenting the types accepted.
Also, I've gone ahead and kept the suggested use of $post
for checking the post status in get_post_permalink()
as referencing back to the original $id
parameter several lines after retrieving the full object seemed weird. get_post_status()
can accept an ID or WP_Post
object too, so that's fine.
Maybe at some later point we should go through and rename all of these variables at once, but for the purposes of this ticket, let's keep it simple :-)
Overall this makes sense, however, I don't think
get_post_permalink
actually accepts a post object currently.In your change at line 267, you call
get_post_status
with a WP_Post object, but that function takes a post ID - maybe change to$post->ID
? Also I want to make sure the $id isn't used elsewhere.