_wp_customize_include

Includes and instantiates the WP_Customize_Manager class.

Description

_wp_customize_include(); 

Loads the Customizer at plugins_loaded when accessing the customize.php admin page or when any request includes a wp_customize=on param or a customize_changeset param (a UUID). This param is a signal for whether to bootstrap the Customizer when WordPress is loading, especially in the Customizer preview or when making Customizer Ajax requests for widgets or menus.


Usage

  1. if ( !function_exists( '_wp_customize_include' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = _wp_customize_include(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function _wp_customize_include() { 
  2.  
  3. $is_customize_admin_page = ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) ); 
  4. $should_include = ( 
  5. $is_customize_admin_page 
  6. || 
  7. ( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] ) 
  8. || 
  9. ( ! empty( $_GET['customize_changeset_uuid'] ) || ! empty( $_POST['customize_changeset_uuid'] ) ) 
  10. ); 
  11.  
  12. if ( ! $should_include ) { 
  13. return; 
  14.  
  15. /** 
  16. * Note that wp_unslash() is not being used on the input vars because it is 
  17. * called before wp_magic_quotes() gets called. Besides this fact, none of 
  18. * the values should contain any characters needing slashes anyway. 
  19. */ 
  20. $keys = array( 'changeset_uuid', 'customize_changeset_uuid', 'customize_theme', 'theme', 'customize_messenger_channel' ); 
  21. $input_vars = array_merge( 
  22. wp_array_slice_assoc( $_GET, $keys ),  
  23. wp_array_slice_assoc( $_POST, $keys ) 
  24. ); 
  25.  
  26. $theme = null; 
  27. $changeset_uuid = null; 
  28. $messenger_channel = null; 
  29.  
  30. if ( $is_customize_admin_page && isset( $input_vars['changeset_uuid'] ) ) { 
  31. $changeset_uuid = sanitize_key( $input_vars['changeset_uuid'] ); 
  32. } elseif ( ! empty( $input_vars['customize_changeset_uuid'] ) ) { 
  33. $changeset_uuid = sanitize_key( $input_vars['customize_changeset_uuid'] ); 
  34.  
  35. // Note that theme will be sanitized via WP_Theme. 
  36. if ( $is_customize_admin_page && isset( $input_vars['theme'] ) ) { 
  37. $theme = $input_vars['theme']; 
  38. } elseif ( isset( $input_vars['customize_theme'] ) ) { 
  39. $theme = $input_vars['customize_theme']; 
  40. if ( isset( $input_vars['customize_messenger_channel'] ) ) { 
  41. $messenger_channel = sanitize_key( $input_vars['customize_messenger_channel'] ); 
  42.  
  43. require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 
  44. $GLOBALS['wp_customize'] = new WP_Customize_Manager( compact( 'changeset_uuid', 'theme', 'messenger_channel' ) );