Title: WP_Customize_Manager::__construct
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Customize_Manager::__construct( array $args = array() )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#wp--skip-link--target)

Constructor.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#parameters)󠁿

 `$args`arrayoptional

Args.

 * `changeset_uuid` null|string|false
 * Changeset UUID, the `post_name` for the customize_changeset post containing the
   customized state.
    Defaults to `null` resulting in a UUID to be immediately generated.
   If `false` is provided, then then the changeset UUID will be determined during`
   after_setup_theme`: when the `customize_changeset_branching` filter returns false,
   then the default UUID will be that of the most recent `customize_changeset` post
   that has a status other than `'auto-draft'`, `'publish'`, or `'trash'`. Otherwise,
   if changeset branching is enabled, then a random UUID will be used.
 * `theme` string
 * Theme to be previewed (for theme switch). Defaults to customize_theme or theme
   query params.
 * `messenger_channel` string
 * Messenger channel. Defaults to customize_messenger_channel query param.
 * `settings_previewed` bool
 * If settings should be previewed. Defaults to true.
 * `branching` bool
 * If changeset branching is allowed; otherwise, changesets are linear. Defaults
   to true.
 * `autosaved` bool
 * If data from a changeset’s autosaved revision should be loaded if it exists. 
   Defaults to false.

Default:`array()`

## 󠀁[Source](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct( $args = array() ) {

    	$args = array_merge(
    		array_fill_keys( array( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ), null ),
    		$args
    	);

    	// Note that the UUID format will be validated in the setup_theme() method.
    	if ( ! isset( $args['changeset_uuid'] ) ) {
    		$args['changeset_uuid'] = wp_generate_uuid4();
    	}

    	/*
    	 * The theme and messenger_channel should be supplied via $args,
    	 * but they are also looked at in the $_REQUEST global here for back-compat.
    	 */
    	if ( ! isset( $args['theme'] ) ) {
    		if ( isset( $_REQUEST['customize_theme'] ) ) {
    			$args['theme'] = wp_unslash( $_REQUEST['customize_theme'] );
    		} elseif ( isset( $_REQUEST['theme'] ) ) { // Deprecated.
    			$args['theme'] = wp_unslash( $_REQUEST['theme'] );
    		}
    	}
    	if ( ! isset( $args['messenger_channel'] ) && isset( $_REQUEST['customize_messenger_channel'] ) ) {
    		$args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) );
    	}

    	// Do not load 'widgets' component if a block theme is activated.
    	if ( ! wp_is_block_theme() ) {
    		$this->components[] = 'widgets';
    	}

    	$this->original_stylesheet = get_stylesheet();
    	$this->theme               = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null );
    	$this->messenger_channel   = $args['messenger_channel'];
    	$this->_changeset_uuid     = $args['changeset_uuid'];

    	foreach ( array( 'settings_previewed', 'autosaved', 'branching' ) as $key ) {
    		if ( isset( $args[ $key ] ) ) {
    			$this->$key = (bool) $args[ $key ];
    		}
    	}

    	require_once ABSPATH . WPINC . '/class-wp-customize-setting.php';
    	require_once ABSPATH . WPINC . '/class-wp-customize-panel.php';
    	require_once ABSPATH . WPINC . '/class-wp-customize-section.php';
    	require_once ABSPATH . WPINC . '/class-wp-customize-control.php';

    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-code-editor-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php';

    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php';

    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-themes-panel.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php';

    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-custom-css-setting.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php';
    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-setting.php';

    	/**
    	 * Filters the core Customizer components to load.
    	 *
    	 * This allows Core components to be excluded from being instantiated by
    	 * filtering them out of the array. Note that this filter generally runs
    	 * during the 'plugins_loaded' action, so it cannot be added
    	 * in a theme.
    	 *
    	 * @since 4.4.0
    	 *
    	 * @see WP_Customize_Manager::__construct()
    	 *
    	 * @param string[]             $components Array of core components to load.
    	 * @param WP_Customize_Manager $manager    WP_Customize_Manager instance.
    	 */
    	$components = apply_filters( 'customize_loaded_components', $this->components, $this );

    	require_once ABSPATH . WPINC . '/customize/class-wp-customize-selective-refresh.php';
    	$this->selective_refresh = new WP_Customize_Selective_Refresh( $this );

    	if ( in_array( 'widgets', $components, true ) ) {
    		require_once ABSPATH . WPINC . '/class-wp-customize-widgets.php';
    		$this->widgets = new WP_Customize_Widgets( $this );
    	}

    	if ( in_array( 'nav_menus', $components, true ) ) {
    		require_once ABSPATH . WPINC . '/class-wp-customize-nav-menus.php';
    		$this->nav_menus = new WP_Customize_Nav_Menus( $this );
    	}

    	add_action( 'setup_theme', array( $this, 'setup_theme' ) );
    	add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );

    	// Do not spawn cron (especially the alternate cron) while running the Customizer.
    	remove_action( 'init', 'wp_cron' );

    	// Do not run update checks when rendering the controls.
    	remove_action( 'admin_init', '_maybe_update_core' );
    	remove_action( 'admin_init', '_maybe_update_plugins' );
    	remove_action( 'admin_init', '_maybe_update_themes' );

    	add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
    	add_action( 'wp_ajax_customize_trash', array( $this, 'handle_changeset_trash_request' ) );
    	add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) );
    	add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) );
    	add_filter( 'heartbeat_settings', array( $this, 'add_customize_screen_to_heartbeat_settings' ) );
    	add_filter( 'heartbeat_received', array( $this, 'check_changeset_lock_with_heartbeat' ), 10, 3 );
    	add_action( 'wp_ajax_customize_override_changeset_lock', array( $this, 'handle_override_changeset_lock_request' ) );
    	add_action( 'wp_ajax_customize_dismiss_autosave_or_lock', array( $this, 'handle_dismiss_autosave_or_lock_request' ) );

    	add_action( 'customize_register', array( $this, 'register_controls' ) );
    	add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // Allow code to create settings first.
    	add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) );
    	add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );

    	// Render Common, Panel, Section, and Control templates.
    	add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_panel_templates' ), 1 );
    	add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_section_templates' ), 1 );
    	add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_control_templates' ), 1 );

    	// Export header video settings with the partial response.
    	add_filter( 'customize_render_partials_response', array( $this, 'export_header_video_settings' ), 10, 3 );

    	// Export the settings to JS via the _wpCustomizeSettings variable.
    	add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_pane_settings' ), 1000 );

    	// Add theme update notices.
    	if ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) ) {
    		require_once ABSPATH . 'wp-admin/includes/update.php';
    		add_action( 'customize_controls_print_footer_scripts', 'wp_print_admin_notice_templates' );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-manager.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-customize-manager.php#L262)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-customize-manager.php#L262-L415)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#hooks)󠁿

 [apply_filters( ‘customize_loaded_components’, string[] $components, WP_Customize_Manager $manager )](https://developer.wordpress.org/reference/hooks/customize_loaded_components/)

Filters the core Customizer components to load.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_block_theme()](https://developer.wordpress.org/reference/functions/wp_is_block_theme/)`wp-includes/theme.php` |

Returns whether the active theme is a block-based theme or not.

  | 
| [wp_generate_uuid4()](https://developer.wordpress.org/reference/functions/wp_generate_uuid4/)`wp-includes/functions.php` |

Generates a random UUID (version 4).

  | 
| [WP_Customize_Selective_Refresh::__construct()](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/__construct/)`wp-includes/customize/class-wp-customize-selective-refresh.php` |

Plugin bootstrap for Partial Refresh functionality.

  | 
| [WP_Customize_Nav_Menus::__construct()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus/__construct/)`wp-includes/class-wp-customize-nav-menus.php` |

Constructor.

  | 
| [get_stylesheet()](https://developer.wordpress.org/reference/functions/get_stylesheet/)`wp-includes/theme.php` |

Retrieves name of the current stylesheet.

  | 
| [validate_file()](https://developer.wordpress.org/reference/functions/validate_file/)`wp-includes/functions.php` |

Validates a file name and path against an allowed set of rules.

  | 
| [remove_action()](https://developer.wordpress.org/reference/functions/remove_action/)`wp-includes/plugin.php` |

Removes a callback function from an action hook.

  | 
| [WP_Customize_Widgets::__construct()](https://developer.wordpress.org/reference/classes/wp_customize_widgets/__construct/)`wp-includes/class-wp-customize-widgets.php` |

Initial loader.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [wp_get_theme()](https://developer.wordpress.org/reference/functions/wp_get_theme/)`wp-includes/theme.php` |

Gets a [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/) object for a theme.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  | 
| [sanitize_key()](https://developer.wordpress.org/reference/functions/sanitize_key/)`wp-includes/formatting.php` |

Sanitizes a string key.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [add_action()](https://developer.wordpress.org/reference/functions/add_action/)`wp-includes/plugin.php` |

Adds a callback function to an action hook.

  | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  |

[Show 10 more](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#)

| Used by | Description | 
| [_wp_customize_publish_changeset()](https://developer.wordpress.org/reference/functions/_wp_customize_publish_changeset/)`wp-includes/theme.php` |

Publishes a snapshot’s changes.

  | 
| [_wp_customize_include()](https://developer.wordpress.org/reference/functions/_wp_customize_include/)`wp-includes/theme.php` |

Includes and instantiates the [WP_Customize_Manager](https://developer.wordpress.org/reference/classes/wp_customize_manager/) class.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/WP_Customize_Manager/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Added `$args` parameter. | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_manager%2F__construct%2F)
before being able to contribute a note or feedback.