#38610 closed defect (bug) (fixed)
Set `format` enum based on the post formats registered to the theme
Reported by: | danielbachhuber | Owned by: | rmccue |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | needs-unit-tests has-patch |
Focuses: | Cc: |
Description
In the Post schema, we're registering the enum
based on get_post_format_slugs()
, which returns all slugs, not those specific to the theme.
Instead, we should make sure the enum
is specific to the post formats supported by the theme.
Attachments (1)
Change History (6)
#2
@
8 years ago
- Keywords has-patch added; needs-patch removed
Attached patch that uses get_theme_support
- we know it's going to be truthy, as has_theme_support
is checked in the loop above.
Unsure how best to unit test this.
#4
@
8 years ago
I have some questions about this commit because it seems to mean that themes are informing the data that gets returned via the api. However, I might be misunderstanding what got changed here.
If I'm understanding correctly, with this change, it means that the schema will only return the enum values for post formats that are registered by the active theme on a site (regardless of what post format slugs may be in the database).
Does this mean that any validation of rest request queries against post_format only allow these slugs?
Are clients still able to discover all post_formats available on a WP site (regardless) of what the theme has registered?
If clients want to utilize post_formats for how the client is displaying the data, are they still able to POST and GET any custom formats that are _not_ registered by the active theme on the WordPress site?
#5
@
8 years ago
@nerrad so, the theme is dictating what post formats you can create, this was done to reflect the WordPress admin, where you can't create a post of a format that your theme does not support.
This change basically means different wordpress sites will have different formats available (depending on what theme they have activated).
We can use
get_theme_support( 'post-formats' )
here, which does anarray_intersect
withget_post_format_slugs
internally.