[wp-trac] [WordPress Trac] #27666: Set/Get the current URL in the Theme Customizer
WordPress Trac
noreply at wordpress.org
Sat Jun 14 07:05:44 UTC 2014
#27666: Set/Get the current URL in the Theme Customizer
-----------------------------+-----------------------------------------
Reporter: TJNowell | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Appearance | Version: 3.4
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: javascript, administration
-----------------------------+-----------------------------------------
Comment (by westonruter):
However, something that is currently not good in the Customizer is that
the `Previewer` instance is stored in a variable contained within a
closure. It gets exported when each `setting` is constructed, but outside
the context of the settings the variable is not available
([https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-admin/js
/customize-controls.js#L931 customize-controls.js]):
{{{
$( function() {
// ...
previewer = new api.Previewer({ /* ... */ })
}}}
In the Widget Customizer, this has necessitated doing something ugly in
[https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-admin/js
/customize-widgets.js#L1744 customize-widgets.js]:
{{{
/**
* Capture the instance of the Previewer since it is private
*/
OldPreviewer = api.Previewer;
api.Previewer = OldPreviewer.extend({
initialize: function( params, options ) {
api.Widgets.Previewer = this;
OldPreviewer.prototype.initialize.call( this,
params, options );
this.bind( 'refresh', this.refresh );
}
} );
}}}
This then allows the Widget Customizer to access the `Previewer` instance
irrespective outside the context of any settings.
Ideally, the instance of the previewer would be exported as a property of
`wp.customize`, e.g. `wp.cutomize.previewer`. This would then allow any JS
in the Customizer to directly access the URL of the current preview via:
{{{
url = wp.customize.previewer.previewUrl();
}}}
And to set it via:
{{{
wp.customize.previewer.previewUrl( url );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27666#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list