Opened 3 years ago
Last modified 18 months ago
#53602 new enhancement
Expand get_post's $filter parameter to allow a blocks as a return shape
Reported by: | gziolo | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
Part of "PHP APIs Overview" in Gutenberg: https://github.com/WordPress/gutenberg/issues/8352.
get_posts
accepts three arguments at the moment:
https://developer.wordpress.org/reference/functions/get_post/#parameters
The proposal is to expand the $filter
parameter to accept also blocks
as an option:
(string) (Optional) Type of filter to apply. Accepts 'raw', 'edit', 'db', or 'display'.
Default value: 'raw'
The implementation details are still to be defined but it would probably require a `parse_block` function call.
Change History (4)
#2
@
3 years ago
This doesn't seem right to me. The purpose of filter
is to apply certain transformations to the WP_Post
properties. So in this case, blocks
would have to be a proxy for one of the other filter values for the other fields. Then if you wanted blocks, you'd lose the ability to set a desired filter
for the other fields.
Instead, it seems like we can introduce a blocks
property on WP_Post
like ancestors
and lazily parse_blocks
when called.
#3
@
3 years ago
Instead, it seems like we can introduce a
blocks
property onWP_Post
likeancestors
and lazilyparse_blocks
when called.
I was only moving the existing issue to Trac from Gutenberg so I don't have strong opinions here. The solution you proposed sounds good as well. @matveb should know better how to proceed.
To expand a bit on the rationale: this aims to make consuming content in block format, if so desired, better supported at a lower level in WordPress.