[wp-trac] [WordPress Trac] #36582: Export main query from Customizer preview
WordPress Trac
noreply at wordpress.org
Sat Apr 23 23:36:23 UTC 2016
#36582: Export main query from Customizer preview
-------------------------+------------------
Reporter: westonruter | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.6
Component: Customize | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------
Description changed by westonruter:
Old description:
> Controls, sections, and panels in the Customizer support the concept of
> an active state (#27993) which controls whether or not the control is
> contextual to the current query. Controls may want more information than
> whether to hide/show, but to show contextual information based on which
> kind of query is loaded in the Customizer preview, such as if it
> `is_singular` or which post specifically was queried. This information
> should be exposed from the Customizer preview to the pane as well.
>
> An initial implementation of this has been implemented in the Customize
> Posts feature plugin: https://github.com/xwp/wp-customize-posts
>
> See Slack: https://wordpress.slack.com/archives/core-
> customize/p1461011732000103
New description:
Controls, sections, and panels in the Customizer support the concept of an
active state (#27993) which controls whether or not the control is
contextual to the current query. Controls may want more information than
whether to hide/show, but to show contextual information based on which
kind of query is loaded in the Customizer preview, such as if it
`is_singular` or which post specifically was queried. This information
should be exposed from the Customizer preview to the pane as well.
An initial implementation of this has been implemented in the Customize
Posts feature plugin: https://github.com/xwp/wp-customize-posts
When the preview syncs the `WP_Query` data from the preview to the pane,
the data should get sent along with the `ready` message along with the
`activeControls`, `activeSections`, and `activePanels` data. When the data
is received by the pane, it should get populated into a model which can
have events attached to it. For example, a `wp.customize.Values` instance
could be used as a collection to represent the query_vars. Or there could
be one single `wp.customize.Value` that stores the exported `WP_Query`
data in like `wp.customize.previewedQuery` which plugins could then listen
to changes on. For example:
{{{#!js
wp.customize.previewedQuery.bind( function( newQuery, oldQuery ) {
if ( newQuery.is_singular !== oldQuery.is_singular ) {
if ( newQuery.is_singular ) {
// We switched to a singular template!
} else {
// We switched to a non-singular template!
}
}
} );
}}}
Some thought will need to be given to how a JavaScript object is used to
represent `WP_Query`.
See Slack: https://wordpress.slack.com/archives/core-
customize/p1461011732000103
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36582#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list