WP_Customize_Manager::__construct PHP Method

__construct() public method

Constructor.
Since: 3.4.0
Since: 4.7.0 Added $args param.
public __construct ( array $args = [] )
$args array { Args. @type string $changeset_uuid Changeset UUID, the post_name for the customize_changeset post containing the customized state. Defaults to new UUID. @type string $theme Theme to be previewed (for theme switch). Defaults to customize_theme or theme query params. @type string $messenger_channel Messenger channel. Defaults to customize_messenger_channel query param. }
    public function __construct($args = array())
    {
        $args = array_merge(array_fill_keys(array('changeset_uuid', 'theme', 'messenger_channel'), 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']));
        }
        $this->original_stylesheet = get_stylesheet();
        $this->theme = wp_get_theme($args['theme']);
        $this->messenger_channel = $args['messenger_channel'];
        $this->_changeset_uuid = $args['changeset_uuid'];
        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-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-auto-add-control.php';
        require_once ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php';
        require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-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-new-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 {@see 'plugins_loaded'} action, so it cannot be added
         * in a theme.
         *
         * @since 4.4.0
         *
         * @see WP_Customize_Manager::__construct()
         *
         * @param array                $components List of core components to load.
         * @param WP_Customize_Manager $this       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_refresh_nonces', array($this, 'refresh_nonces'));
        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 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);
    }
WP_Customize_Manager