WordPress.org

Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Customizer Browser History

Sync browser URL in Customizer with current preview URL and focused panels, sections, and controls.

This is a feature plugin intended to implement #28536: Add browser history and deep linking for navigation in Customizer preview

This plugin keeps the Customizer URL in the browser updated with current previewed URL as the url query param and current expanded panel/section/control as autofocus params. This allows for bookmarking and also the ability to reload and return go the same view (which is great for developers), including which device you are previewing (desktop, tablet, or mobile). Not only will the URL be kept in sync with the current customizer UI, but new browser history entries will be added as you navigate around the site in the preview (via history.pushState()), allowing you to use the back/forward buttons as you would normally when browsing the site outside the customizer. The scroll position for each previewed URL is tracked as well, so that when you navigate back/forward the scroll position will be restored, just as happens when browsing the site outside the customizer preview. Restoring the scroll position also works when reloading the customizer, as the position is persisted in a scroll query parameter: again, this is extremely useful during development.

This plugin complements well the Customize Snapshots plugin which allows you to save your Customizer state in a shapshot/changeset with an associated UUID that also gets added to the browser URL in the Customizer.

For example, if you load the Customizer and then click the “Site Identity” section, the URL will be replaced to add autofocus[section]=title_tagline.

If you navigate into the nav menus panel, open a menu section, and then expand a nav menu item control, then the URL will have these autofocus params added:

autofocus[panel]=nav_menus&autofocus[section]=nav_menu[87]&autofocus[control]=nav_menu_item[5123]

And while these changes to the autofocus params are being made in the browser's URL as the Customizer UI is interacted with, if you navigate to another page in the preview the url parameter will also be replaced to reflect the new preview URL.

Note that the url param will be URL-encoded. So a typical Customizer URL would get updated to look like:

http://example.com/wp-admin/customize.php?url=http%3A%2F%2Fexample.com%2Fsample-page%2F&autofocuspanel=widgets&autofocussection=sidebar-widgets-sidebar-1&autofocuscontrol=widget_text10&device=mobile&scroll=200

Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum.

Requires: 4.6.0 or higher
Compatible up to: 4.7.3
Last Updated: 2 months ago
Active Installs: 20+

Ratings

5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.