Opened 8 years ago
Closed 8 years ago
#36879 closed enhancement (duplicate)
Allow post data to be filtered if is_customize_preview()
Reported by: | westonruter | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Customize | Keywords: | |
Focuses: | Cc: |
Description
This was originally reported as an an issue in the Customize Posts feature plugin for #34923. The plugin currently previews post data via the the_posts
filter. This is problematic, however, because this filter is not called in queries with suppress_filters
on or in calls to get_post()
:
When querying posts via
get_posts()
or when usingnew WP_Query( array( 'suppress_filters' => true ) )
, thethe_posts
filters which apply the previewed changes to the posts is not run. This is a problem with Core in that there are not always filters applied to post data. This necessitates, for example, for there to be acomments_open
filter in addition to athe_posts
filter, sinceget_post()
will return a pristine copy of the post without any hooks for Customize Posts to apply the previewed changes. In reality,get_post()
should be returning the dirty post as opposed to the pristine post, and so an additionalcomments_open
filter wouldn't be needed.
So, what is needed is a new filter to run whenever getting a post via
get_post()
to allow the array or object to be mutated. This filter can only be applied ifis_customize_preview()
since applying such a filter generally could be too far reaching.
Related: #30292.