Opened 10 years ago
Closed 10 years ago
#33723 closed enhancement (fixed)
Allow WP_Post on thumbnail functions
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Post Thumbnails | Keywords: | has-patch needs-refresh |
Focuses: | docs | Cc: |
Description
Since we can put WP_Post object as argument for get_the_title() or get_permalink() it can be nice to have theses on the thumbnail functions.
Here's my patch containing the changes for handling this kind of improvements and coding standards applyed.
Attachments (6)
Change History (17)
#1
follow-up:
↓ 2
@
10 years ago
- Focuses docs added
- Keywords has-patch dev-feedback added
- Milestone changed from Awaiting Review to 4.4
#2
in reply to:
↑ 1
@
10 years ago
- Keywords needs-unit-tests added
Replying to swissspidy:
Unfortunately these functions have no unit tests. We really should add some, but maybe in a separate ticket.
Unit tests should ship with the changes here in the same ticket.
#5
@
10 years ago
- Keywords needs-unit-tests added
Oh noes, looks like I attached the same again by mistake.
#7
@
10 years ago
- Version changed from 4.3 to 2.9
33723.4.diff improves the inline docs even more.
I'd say this could safely make it into core now, but of course a second pair of eyes would be great.
#8
@
10 years ago
@swissspidy: The docs look pretty good. The only thing missing is that all of the functions that accept $post = null
default to the global $post
, therefore the parameter should be documented as optional, and mention that it defaults to the global $post
.
Thanks for your patch! I think this enhancements makes sense as it is more convenient for developers.
Unfortunately I wasn't able to easily apply it because of the base directory. As a tip for next time, please make sure you patch from the
/src
directory, so it looks likesrc/wp-includes/post-thumbnail-template.php
in your patch.I created 33723.diff now that does the following:
@since
to the docblocks to reflect the changesupdate_post_thumbnail_cache
alone. We don't do refactoring just for the sake of refactoring, see https://make.wordpress.org/core/2011/03/23/code-refactoring/ for details.$post
is aWP_Post
inget_post_thumbnail_id
, otherwise usesnull
Unfortunately these functions have no unit tests. We really should add some, but maybe in a separate ticket.