Skip to content

Instantly share code, notes, and snippets.

@pagelab
Forked from slushman/customizer-links.php
Created January 4, 2018 16:24
Show Gist options
  • Select an option

  • Save pagelab/d238dd40972314f63ccaf7e5bd8944ae to your computer and use it in GitHub Desktop.

Select an option

Save pagelab/d238dd40972314f63ccaf7e5bd8944ae to your computer and use it in GitHub Desktop.
How to link into the WordPress Customizer
@pagelab
Copy link
Author

pagelab commented May 10, 2018

From https://www.slushman.com/how-to-link-to-the-customizer/

These do not work if the Customizer is active, giving the link a .customize-unpreviewable class and therefore gets this CSS applied: cursor: not-allowed !important;

You can use https://developer.wordpress.org/reference/functions/is_customize_preview/ to detect if in the customizer.

And https://developer.wordpress.org/themes/customize-api/tools-for-improved-user-experience/#selective-refresh-fast-accurate-updates may be a handy alternative or supplement, too.

TIP: if you want to add links inside the customizer, you can use the customizer API:
<a href="javascript:wp.customize.panel( 'widgets' ).focus();">Widgets Panel</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment