#24162 closed enhancement (invalid)
Add filter hook to get_post_format_meta()
Reported by: | stuntbox | Owned by: | markjaquith |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6 |
Component: | Post Formats | Keywords: | has-patch |
Focuses: | Cc: |
Description
As per a previous request from Alex King, it would be useful if a filter hook could be added to get_post_format_meta(), particularly for plugin and theme builders looking to reformat the output of post formats for uses like HiDPI image plugins, lazy loading techniques, picture element polyfills, etc.
Attachments (4)
Change History (15)
#2
@
11 years ago
- Component changed from General to Post Formats
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 3.6
#3
@
11 years ago
- Owner set to markjaquith
- Resolution set to fixed
- Status changed from new to closed
In 24080:
#4
follow-up:
↓ 5
@
11 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Whoops, I think my patch was incomplete - we should also pass the $post_id
to the filter so there is context to work with.
Additionally, the $post_id
param to the function is listed as optional, but there is nothing to have it fall back on the global $post
, I added this as well. The $post_id
is passed to get_post_format()
which requires the post id (doesn't fall back on global $post
).
Sorry for not catching this sooner. Updated patch attached.
#5
in reply to:
↑ 4
@
11 years ago
Replying to alexkingorg:
Additionally, the
$post_id
param to the function is listed as optional, but there is nothing to have it fall back on theglobal $post
, I added this as well.
We've replaced global $post
references with get_post()
in [21735]. 24162.2.diff uses get_post()
here for consistency.
The
$post_id
is passed toget_post_format()
which requires the post id (doesn't fall back onglobal $post
).
It does fall back to the global, via get_post()
. [24057] made that clear in the description. get_post_meta()
, however, does not.
#6
@
11 years ago
Hmm, interesting. I hadn't realized about the standardization on get_post()
vs global $post
, thanks for the explanation.
This does introduce an additional set of SQL calls for loading up the post if it's not already in object cache. Doesn't seem necessary if the $post_id isn't 0.
Is it the job of this function to check that the post ID is valid? Seems like a lot of responsibility to put on this guy. :)
#8
@
11 years ago
24162.3.diff works as expected for me.
The patch is here: http://core.trac.wordpress.org/attachment/ticket/19570/post-format-meta-filter.diff