WordPress.org

Make WordPress Core

Opened 20 months ago

Last modified 15 months ago

#36582 assigned enhancement

Export main query from Customizer preview

Reported by: westonruter Owned by: westonruter
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description (last modified by westonruter)

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:

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

Change History (11)

#1 @westonruter
20 months ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


20 months ago

#3 @westonruter
20 months ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


19 months ago

#5 @chriscct7
19 months ago

  • Owner set to westonruter
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core by voldemortensen. View the logs.


18 months ago

#7 @voldemortensen
18 months ago

  • Milestone changed from 4.6 to Future Release

Punting for now, if a patch comes forth before the deadline it can definitely be moved back to the milestone.

#8 @westonruter
16 months ago

  • Milestone changed from Future Release to 4.7

This ticket was mentioned in Slack in #core by jorbin. View the logs.


15 months ago

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.


15 months ago

#11 @celloexpressions
15 months ago

  • Milestone changed from 4.7 to Future Release

Plugins such as customize posts can implement this in the meantime as needed.

Note: See TracTickets for help on using tickets.