[wp-trac] [WordPress Trac] #27666: Set/Get the current URL in the Theme Customizer
WordPress Trac
noreply at wordpress.org
Sat Jun 14 06:54:45 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):
I think what is being requested here is actually already possible. In the
context of a control, you can access the preview's current URL and update
the preview's URL via the associated `setting`, and the setting's
`preview` value:
{{{
wp.customize.controlConstructor.foo = wp.customize.Control.extend( {
ready: function() {
var url, control = this;
// Example: get the current URL
url = control.getPreviewUrl();
// Example: set URL of preview to homepage
control.setPreviewUrl( location.protocol + '//' +
location.host );
},
getPreviewUrl: function () {
return this.setting.previewer.previewUrl();
},
setPreviewUrl: function ( url ) {
this.setting.previewer.previewUrl( url );
}
} );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27666#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list