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: nathanrice 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)

23509.diff (561 bytes) - added by sammybeats 3 months ago.

Download all attachments as: .zip

Change History (5)

  • Component changed from Themes to Appearance

This seems to work for me:

global $wp_customize;
if ( isset( $wp_customize ) ) {
	// ...
}
  • 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 erick@… added
  • Cc philip@… added
Note: See TracTickets for help on using tickets.