Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#24162 closed enhancement (invalid)

Add filter hook to get_post_format_meta()

Reported by: stuntbox's profile stuntbox Owned by: markjaquith's profile 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)

24162.diff (372 bytes) - added by wonderboymusic 11 years ago.
post-meta-values-post-id.diff (786 bytes) - added by alexkingorg 11 years ago.
24162.2.diff (802 bytes) - added by SergeyBiryukov 11 years ago.
24162.3.diff (843 bytes) - added by alexkingorg 11 years ago.
always call filters

Download all attachments as: .zip

Change History (15)

#2 @SergeyBiryukov
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 @markjaquith
11 years ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In 24080:

Add a post_format_meta filter.

props alexkingorg. fixes #24162.

#4 follow-up: @alexkingorg
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 @SergeyBiryukov
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 the global $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 to get_post_format() which requires the post id (doesn't fall back on global $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 @alexkingorg
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. :)

#7 @alexkingorg
11 years ago

Here's a slight mod so that the filter always gets called.

@alexkingorg
11 years ago

always call filters

#8 @DrewAPicture
11 years ago

24162.3.diff works as expected for me.

#9 @ocean90
11 years ago

  • Milestone 3.6 deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

#10 @alexkingorg
11 years ago

We're just throwing away code and ideas relating to post formats now?

#11 @SergeyBiryukov
11 years ago

All the patches and ideas are still available for future reference.

Note: See TracTickets for help on using tickets.