Opened 3 months ago
Last modified 4 weeks ago
#23509 new enhancement
Conditional function that lets you know if your site is being viewed through the Customizer
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Appearance | Version: | |
| Severity: | normal | Keywords: | 2nd-opinion has-patch needs-testing |
| Cc: | sammybeats, erick@…, philip@… |
Description
I can provide a use case if necessary, but this should be relatively simple.
If I need to do something special with my theme when my site is being viewed through the customizer, there's no easy way determine if it is.
A simple is_customizer() (or similar) function would be incredibly useful in this scenario.
I'd write up a patch, but I don't know where to put the new function.
Attachments (1)
Change History (5)
comment:1
SergeyBiryukov — 3 months ago
- Component changed from Themes to Appearance
sammybeats — 3 months ago
comment:2
sammybeats — 3 months ago
- Cc sammybeats added
- Keywords has-patch needs-testing added
Submitted a patch that creates a function is_customizer() that checks to make sure $wp_customize is of type WP_Customize_Manager and returns the value of $wp_customize->is_preview();
- Cc philip@… added
Note: See
TracTickets for help on using
tickets.

This seems to work for me:
global $wp_customize; if ( isset( $wp_customize ) ) { // ... }