Class: WP_Customize_Manager

Customize Manager class.

Bootstraps the Customize experience on the server-side.

Sets up the theme-switching process if a theme other than the active one is being previewed and customized.

Serves as a factory for Customize Controls and Settings, and instantiates default Customize Controls and Settings.

Methods


Properties

Name Type(s) Default Value Summary
theme WP_Theme An instance of the theme being previewed.
original_stylesheet string The directory name of the previously active theme (within the theme_root).
previewing boolean Whether this is a Customizer pageload.
widgets WP_Customize_Widgets Methods and properties dealing with managing widgets in the Customizer.
nav_menus WP_Customize_Nav_Menus Methods and properties dealing with managing nav menus in the Customizer.
selective_refresh WP_Customize_Selective_Refresh Methods and properties dealing with selective refresh in the Customizer preview.
settings array Registered instances of WP_Customize_Setting.
containers array Sorted top-level instances of WP_Customize_Panel and WP_Customize_Section.
panels array Registered instances of WP_Customize_Panel.
components array List of core components.
sections array Registered instances of WP_Customize_Section.
controls array Registered instances of WP_Customize_Control.
registered_panel_types array Panel types that may be rendered from JS templates.
registered_section_types array Section types that may be rendered from JS templates.
registered_control_types array Control types that may be rendered from JS templates.
preview_url string Initial URL being previewed.
return_url string URL to link the user to when closing the Customizer.
autofocus array Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.
messenger_channel string Messenger channel.
autosaved boolean Whether the autosave revision of the changeset should be loaded.
branching boolean Whether the changeset branching is allowed.
settings_previewed boolean Whether settings should be previewed.
saved_starter_content_changeset boolean Whether a starter content changeset was saved.
_post_values array Unsanitized values for Customize Settings parsed from $_POST['customized'].
_changeset_uuid string Changeset UUID.
_changeset_post_id integer | false Changeset post ID.
_changeset_data array Changeset data loaded from a customize_changeset post.
pending_starter_content_settings_ids array Starter content setting IDs.
store_changeset_revision boolean Whether a changeset revision should be made.

Methods

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

Constructor. Since 3.4.0. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$args array

{ Args.

@type null|string|false $changeset_uuid     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.
@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.
@type bool              $settings_previewed If settings should be previewed. Defaults to true.
@type bool              $branching          If changeset branching is allowed; otherwise, changesets are linear. Defaults to true.
@type bool              $autosaved          If data from a changeset's autosaved revision should be loaded if it exists. Defaults to false.

}


WP_Customize_Manager:: _cmp_priority( WP_Customize_Panel | WP_Customize_Section | WP_Customize_Control $a, WP_Customize_Panel | WP_Customize_Section | WP_Customize_Control $b )

This method is deprecated.

Helper function to compare two objects by priority, ensuring sort stability via instance_number. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$a WP_Customize_Panel | WP_Customize_Section | WP_Customize_Control

Object A.

$b WP_Customize_Panel | WP_Customize_Section | WP_Customize_Control

Object B.

Returns

integer


WP_Customize_Manager:: _filter_revision_post_has_changed( boolean $post_has_changed, WP_Post $last_revision, WP_Post $post )

Filters whether a changeset has changed to create a new revision. Since 4.7.0.

Note that this will not be called while a changeset post remains in auto-draft status.

Arguments

Name Type(s) Default Value Description
$post_has_changed boolean

Whether the post has changed.

$last_revision WP_Post

The last revision post object.

$post WP_Post

The post object.

Returns

boolean

Whether a revision should be made.


WP_Customize_Manager:: _publish_changeset_values( integer $changeset_post_id )

Publish changeset values. Since 4.7.0.

This will the values contained in a changeset, even changesets that do not correspond to current manager instance. This is called by _wp_customize_publish_changeset() when a customize_changeset post is transitioned to the publish status. As such, this method should not be called directly and instead wp_publish_post() should be used.

Please note that if the settings in the changeset are for a non-activated theme, the theme must first be switched to (via switch_theme()) before invoking this method.

Arguments

Name Type(s) Default Value Description
$changeset_post_id integer

ID for customize_changeset post. Defaults to the changeset for the current manager instance.

Returns

true | WP_Error

True or error info.


WP_Customize_Manager:: _render_custom_logo_partial( )

Callback for rendering the custom logo, used in the custom_logo partial. Since 4.5.0.

This method exists because the partial object and context data are passed into a partial's render_callback so we cannot use get_custom_logo() as the render_callback directly since it expects a blog ID as the first argument. When WP no longer supports PHP 5.3, this method can be removed in favor of an anonymous function.

Returns

string

Custom logo.


WP_Customize_Manager:: _sanitize_background_setting( string $value, WP_Customize_Setting $setting )

Callback for validating a background setting value. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$value string

Repeat value.

$setting WP_Customize_Setting

Setting.

Returns

string | WP_Error

Background value or validation error.


WP_Customize_Manager:: _sanitize_external_header_video( string $value )

Callback for sanitizing the external_header_video value. Since 4.7.1.

Arguments

Name Type(s) Default Value Description
$value string

URL.

Returns

string

Sanitized URL.


WP_Customize_Manager:: _sanitize_header_textcolor( string $color )

Callback for validating the header_textcolor value. Since 3.4.0.

Accepts 'blank', and otherwise uses sanitize_hex_color_no_hash(). Returns default text color if hex color is empty.

Arguments

Name Type(s) Default Value Description
$color string

Returns

mixed


WP_Customize_Manager:: _save_starter_content_changeset( )

Save starter content changeset. Since 4.7.0.


WP_Customize_Manager:: _validate_external_header_video( WP_Error $validity, mixed $value )

Callback for validating the external_header_video value. Since 4.7.0.

Ensures that the provided URL is supported.

Arguments

Name Type(s) Default Value Description
$validity WP_Error
$value mixed

Returns

mixed


WP_Customize_Manager:: _validate_header_video( WP_Error $validity, mixed $value )

Callback for validating the header_video value. Since 4.7.0.

Ensures that the selected video is less than 8MB and provides an error message.

Arguments

Name Type(s) Default Value Description
$validity WP_Error
$value mixed

Returns

mixed


WP_Customize_Manager:: add_control( WP_Customize_Control | string $id, array $args = array() )

Add a customize control. Since 3.4.0. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id WP_Customize_Control | string

Customize Control object, or ID.

$args array

{ Optional. Array of properties for the new Control object. Default empty array.

@type array $settings All settings tied to the control. If undefined, defaults to $setting. IDs in the array correspond to the ID of a registered WP_Customize_Setting. @type string $setting The primary setting for the control (if there is one). Default is 'default'. @type string $capability Capability required to use this control. Normally derived from $settings. @type int $priority Order priority to load the control. Default 10. @type string $section The section this control belongs to. Default empty. @type string $label Label for the control. Default empty. @type string $description Description for the control. Default empty. @type array $choices List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values. Default empty array. @type array $input_attrs List of custom input attributes for control output, where attribute names are the keys and values are the values. Default empty array. @type bool $allow_addition Show UI for adding new content, currently only used for the dropdown-pages control. Default false. @type string $type The type of the control. Default 'text'. @type callback $active_callback Active callback. }

Returns

WP_Customize_Control

The instance of the control that was added.


WP_Customize_Manager:: add_customize_screen_to_heartbeat_settings( array $settings )

Filter heartbeat settings for the Customizer. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$settings array

Current settings to filter.

Returns

array

Heartbeat settings.


WP_Customize_Manager:: add_dynamic_settings( array $setting_ids )

Register any dynamically-created settings, such as those from $_POST['customized'] that have no corresponding setting created. Since 4.2.0.

This is a mechanism to "wake up" settings that have been dynamically created on the front end and have been sent to WordPress in $_POST['customized']. When WP loads, the dynamically-created settings then will get created and previewed even though they are not directly created statically with code.

Arguments

Name Type(s) Default Value Description
$setting_ids array

The setting IDs to add.

Returns

array

The WP_Customize_Setting objects added.


WP_Customize_Manager:: add_panel( WP_Customize_Panel | string $id, array $args = array() )

Add a customize panel. Since 4.0.0. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id WP_Customize_Panel | string

Customize Panel object, or Panel ID.

$args array

{ Optional. Array of properties for the new Panel object. Default empty array. @type int $priority Priority of the panel, defining the display order of panels and sections. Default 160. @type string $capability Capability required for the panel. Default edit_theme_options @type string|array $theme_supports Theme features required to support the panel. @type string $title Title of the panel to show in UI. @type string $description Description to show in the UI. @type string $type Type of the panel. @type callable $active_callback Active callback. }

Returns

WP_Customize_Panel

The instance of the panel that was added.


WP_Customize_Manager:: add_section( WP_Customize_Section | string $id, array $args = array() )

Add a customize section. Since 3.4.0. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id WP_Customize_Section | string

Customize Section object, or Section ID.

$args array

{ Optional. Array of properties for the new Section object. Default empty array. @type int $priority Priority of the section, defining the display order of panels and sections. Default 160. @type string $panel The panel this section belongs to (if any). Default empty. @type string $capability Capability required for the section. Default 'edit_theme_options' @type string|array $theme_supports Theme features required to support the section. @type string $title Title of the section to show in UI. @type string $description Description to show in the UI. @type string $type Type of the section. @type callable $active_callback Active callback. @type bool $description_hidden Hide the description behind a help icon, instead of inline above the first control. Default false. }

Returns

WP_Customize_Section

The instance of the section that was added.


WP_Customize_Manager:: add_setting( WP_Customize_Setting | string $id, array $args = array() )

Add a customize setting. Since 3.4.0. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id WP_Customize_Setting | string

Customize Setting object, or ID.

$args array

{ Optional. Array of properties for the new WP_Customize_Setting. Default empty array.

@type string $type Type of the setting. Default 'theme_mod'. @type string $capability Capability required for the setting. Default 'edit_theme_options' @type string|array $theme_supports Theme features required to support the panel. Default is none. @type string $default Default value for the setting. Default is empty string. @type string $transport Options for rendering the live preview of changes in Theme Customizer. Using 'refresh' makes the change visible by reloading the whole preview. Using 'postMessage' allows a custom JavaScript to handle live changes.

Returns

WP_Customize_Setting

The instance of the setting that was added.


WP_Customize_Manager:: add_state_query_params( string $url )

Add customize state query params to a given URL if preview is allowed. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$url string

URL.

Returns

string

URL.


WP_Customize_Manager:: after_setup_theme( )

Callback to validate a theme once it is loaded Since 3.4.0.


WP_Customize_Manager:: autosaved( )

Gets whether data from a changeset's autosaved revision should be loaded if it exists. Since 4.9.0.

Returns

boolean

Is using autosaved changeset revision.


WP_Customize_Manager:: branching( )

Whether the changeset branching is allowed. Since 4.9.0.

Returns

boolean

Is changeset branching.


WP_Customize_Manager:: changeset_data( )

Get changeset data. Since 4.7.0. Since 4.9.0.

Returns

array

Changeset data.


WP_Customize_Manager:: changeset_post_id( )

Get the changeset post id for the loaded changeset. Since 4.7.0.

Returns

integer | null

Post ID on success or null if there is no post yet saved.


WP_Customize_Manager:: changeset_uuid( )

Get the changeset UUID. Since 4.7.0.

Returns

string

UUID.


WP_Customize_Manager:: check_changeset_lock_with_heartbeat( array $response, array $data, string $screen_id )

Check locked changeset with heartbeat API. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$response array

The Heartbeat response.

$data array

The $_POST data sent.

$screen_id string

The screen id.

Returns

array

The Heartbeat response.


WP_Customize_Manager:: containers( )

Get the registered containers. Since 4.0.0.

Returns

array


WP_Customize_Manager:: controls( )

Get the registered controls. Since 3.4.0.

Returns

array


WP_Customize_Manager:: current_theme( $current_theme )

Filters the current theme and return the name of the previewed theme. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$current_theme

{@internal Parameter is not used}

Returns

string

Theme name.


WP_Customize_Manager:: customize_pane_settings( )

Print JavaScript settings for parent window. Since 4.4.0.


WP_Customize_Manager:: customize_preview_base( )

This method is deprecated.

Print base element for preview frame. Since 3.4.0.


WP_Customize_Manager:: customize_preview_html5( )

This method is deprecated.

Print a workaround to handle HTML5 tags in IE < 9. Since 3.4.0.


WP_Customize_Manager:: customize_preview_init( )

Print JavaScript settings. Since 3.4.0.


WP_Customize_Manager:: customize_preview_loading_style( )

Print CSS for loading indicators for the Customizer preview. Since 4.2.0.


WP_Customize_Manager:: customize_preview_override_404_status( )

This method is deprecated.

Prevent sending a 404 status when returning the response for the customize preview, since it causes the jQuery Ajax to fail. Send 200 instead. Since 4.0.0.


WP_Customize_Manager:: customize_preview_settings( )

Print JavaScript settings for preview frame. Since 3.4.0.


WP_Customize_Manager:: customize_preview_signature( )

This method is deprecated.

Prints a signature so we can ensure the Customizer was properly executed. Since 3.4.0.


WP_Customize_Manager:: dismiss_user_auto_draft_changesets( )

Dismiss all of the current user's auto-drafts (other than the present one). Since 4.9.0.

Returns

integer

The number of auto-drafts that were dismissed.


WP_Customize_Manager:: doing_ajax( string | null $action = null )

Return true if it's an Ajax request. Since 3.4.0. Since 4.2.0.

Arguments

Name Type(s) Default Value Description
$action string | null

Whether the supplied Ajax action is being run.

Returns

boolean

True if it's an Ajax request, false otherwise.


WP_Customize_Manager:: enqueue_control_scripts( )

Enqueue scripts for customize controls. Since 3.4.0.


WP_Customize_Manager:: establish_loaded_changeset( )

Establish the loaded changeset. Since 4.9.0.

This method runs right at after_setup_theme and applies the 'customize_changeset_branching' filter to determine whether concurrent changesets are allowed. Then if the Customizer is not initialized with a changeset_uuid param, this method will determine which UUID should be used. If changeset branching is disabled, then the most saved changeset will be loaded by default. Otherwise, if there are no existing saved changesets or if changeset branching is enabled, then a new UUID will be generated.


WP_Customize_Manager:: export_header_video_settings( array $response, WP_Customize_Selective_Refresh $selective_refresh, array $partials )

Export header video settings to facilitate selective refresh. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$response array

Response.

$selective_refresh WP_Customize_Selective_Refresh

Selective refresh component.

$partials array

Array of partials.

Returns

array


WP_Customize_Manager:: filter_iframe_security_headers( array $headers )

Filter the X-Frame-Options and Content-Security-Policy headers to ensure frontend can load in customizer. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$headers array

Headers.

Returns

array

Headers.


WP_Customize_Manager:: find_changeset_post_id( string $uuid )

Find the changeset post ID for a given changeset UUID. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$uuid string

Changeset UUID.

Returns

integer | null

Returns post ID on success and null on failure.


WP_Customize_Manager:: get_allowed_urls( )

Get URLs allowed to be previewed. Since 4.7.0.

If the front end and the admin are served from the same domain, load the preview over ssl if the Customizer is being loaded over ssl. This avoids insecure content warnings. This is not attempted if the admin and front end are on different domains to avoid the case where the front end doesn't have ssl certs. Domain mapping plugins can allow other urls in these conditions using the customize_allowed_urls filter.


WP_Customize_Manager:: get_autofocus( )

Get the autofocused constructs. Since 4.4.0.

Returns

array

{ Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.

@type string [$control]  ID for control to be autofocused.
@type string [$section]  ID for section to be autofocused.
@type string [$panel]    ID for panel to be autofocused.

}


WP_Customize_Manager:: get_changeset_post_data( integer $post_id )

Get the data stored in a changeset post. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$post_id integer

Changeset post ID.

Returns

array | WP_Error

Changeset data or WP_Error on error.


WP_Customize_Manager:: get_changeset_posts( array $args = array() )

Get changeset posts. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$args array

{ Args to pass into get_posts() to query changesets.

@type int    $posts_per_page             Number of posts to return. Defaults to -1 (all posts).
@type int    $author                     Post author. Defaults to current user.
@type string $post_status                Status of changeset. Defaults to 'auto-draft'.
@type bool   $exclude_restore_dismissed  Whether to exclude changeset auto-drafts that have been dismissed. Defaults to true.

}

Returns

array<mixed,WP_Post>

Auto-draft changesets.


WP_Customize_Manager:: get_control( string $id )

Retrieve a customize control. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

ID of the control.

Returns

WP_Customize_Control | void

The control object, if set.


WP_Customize_Manager:: get_document_title_template( )

Get the template string for the Customizer pane document title. Since 4.4.0.

Returns

string

The template string for the document title.


WP_Customize_Manager:: get_lock_user_data( integer $user_id )

Get lock user data. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$user_id integer

User ID.

Returns

array | null

User data formatted for client.


WP_Customize_Manager:: get_messenger_channel( )

Get messenger channel. Since 4.7.0.

Returns

string

Messenger channel.


WP_Customize_Manager:: get_nonces( )

Get nonces for the Customizer. Since 4.5.0.

Returns

array

Nonces.


WP_Customize_Manager:: get_panel( string $id )

Retrieve a customize panel. Since 4.0.0.

Arguments

Name Type(s) Default Value Description
$id string

Panel ID to get.

Returns

WP_Customize_Panel | void

Requested panel instance, if set.


WP_Customize_Manager:: get_preview_url( )

Get the initial URL to be previewed. Since 4.4.0.

Returns

string

URL being previewed.


WP_Customize_Manager:: get_previewable_devices( )

Returns a list of devices to allow previewing. Since 4.5.0.

Returns

array

List of devices with labels and default setting.


WP_Customize_Manager:: get_return_url( )

Get URL to link the user to when closing the Customizer. Since 4.4.0.

Returns

string

URL for link to close Customizer.


WP_Customize_Manager:: get_section( string $id )

Retrieve a customize section. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

Section ID.

Returns

WP_Customize_Section | void

The section, if set.


WP_Customize_Manager:: get_setting( string $id )

Retrieve a customize setting. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

Customize Setting ID.

Returns

WP_Customize_Setting | void

The setting, if set.


WP_Customize_Manager:: get_stylesheet( )

Retrieve the stylesheet name of the previewed theme. Since 3.4.0.

Returns

string

Stylesheet name.


WP_Customize_Manager:: get_stylesheet_root( )

Retrieve the stylesheet root of the previewed theme. Since 3.4.0.

Returns

string

Theme root.


WP_Customize_Manager:: get_template( )

Retrieve the template name of the previewed theme. Since 3.4.0.

Returns

string

Template name.


WP_Customize_Manager:: get_template_root( )

Retrieve the template root of the previewed theme. Since 3.4.0.

Returns

string

Theme root.


WP_Customize_Manager:: grant_edit_post_capability_for_changeset( array<mixed,string> $caps, string $cap, integer $user_id, array $args )

Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps. Since 4.9.0.

There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to the 'customize' meta cap which then maps to 'edit_theme_options'. This is currently required in core for wp_create_post_autosave() because it will call _wp_translate_postdata() which in turn will check if a user can 'edit_post', but the the caps for the customize_changeset post type are all mapping to the meta capability. This should be able to be removed once #40922 is addressed in core.

Arguments

Name Type(s) Default Value Description
$caps array<mixed,string>

Array of the user's capabilities.

$cap string

Capability name.

$user_id integer

The user ID.

$args array

Adds the context to the cap. Typically the object ID.

Returns

array

Capabilities.


WP_Customize_Manager:: handle_changeset_trash_request( )

Handle request to trash a changeset. Since 4.9.0.


WP_Customize_Manager:: handle_dismiss_autosave_or_lock_request( )

Delete a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock. Since 4.9.0.


WP_Customize_Manager:: handle_load_themes_request( )

Load themes into the theme browsing/installation UI. Since 4.9.0.


WP_Customize_Manager:: handle_override_changeset_lock_request( )

Removes changeset lock when take over request is sent via Ajax. Since 4.9.0.


WP_Customize_Manager:: has_published_pages( )

Return whether there are published pages. Since 4.7.0.

Used as active callback for static front page section and controls.


WP_Customize_Manager:: import_theme_starter_content( array $starter_content = array() )

Import theme starter content into the customized state. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$starter_content array

Starter content. Defaults to get_theme_starter_content().


WP_Customize_Manager:: is_cross_domain( )

Determines whether the admin and the frontend are on different domains. Since 4.7.0.

Returns

boolean

Whether cross-domain.


WP_Customize_Manager:: is_ios( )

Determine whether the user agent is iOS. Since 4.4.0.

Returns

boolean

Whether the user agent is iOS.


WP_Customize_Manager:: is_preview( )

Is it a theme preview? Since 3.4.0.

Returns

boolean

True if it's a preview, false if not.


WP_Customize_Manager:: is_theme_active( )

Checks if the current theme is active. Since 3.4.0.

Returns

boolean


WP_Customize_Manager:: panels( )

Get the registered panels. Since 4.0.0.

Returns

array

Panels.


WP_Customize_Manager:: post_value( WP_Customize_Setting $setting, mixed $default = null )

Returns the sanitized value for a given setting from the current customized state. Since 3.4.0. Since 4.1.1. Since 4.6.0.

The name "post_value" is a carry-over from when the customized state was exclusively sourced from $_POST['customized']. Nevertheless, the value returned will come from the current changeset post and from the incoming post data.

Arguments

Name Type(s) Default Value Description
$setting WP_Customize_Setting

A WP_Customize_Setting derived object.

$default mixed

Value returned $setting has no post value (added in 4.2.0) or the post value is invalid (added in 4.6.0).

Returns

string | mixed

$post_value Sanitized value or the $default provided.


WP_Customize_Manager:: prepare_controls( )

Prepare panels, sections, and controls. Since 3.4.0.

For each, check if required related components exist, whether the user has the necessary capabilities, and sort by priority.


WP_Customize_Manager:: prepare_setting_validity_for_js( true | WP_Error $validity )

Prepares setting validity for exporting to the client (JS). Since 4.6.0.

Converts WP_Error instance into array suitable for passing into the wp.customize.Notification JS model.

Arguments

Name Type(s) Default Value Description
$validity true | WP_Error

Setting validity.

Returns

true | array

If $validity was a WP_Error, the error codes will be array-mapped to their respective message and data to pass into the wp.customize.Notification JS model.


WP_Customize_Manager:: prepare_starter_content_attachments( array $attachments )

Prepare starter content attachments. Since 4.7.0.

Ensure that the attachments are valid and that they have slugs and file name/path.

Arguments

Name Type(s) Default Value Description
$attachments array

Attachments.

Returns

array

Prepared attachments.


WP_Customize_Manager:: refresh_changeset_lock( integer $changeset_post_id )

Refreshes changeset lock with the current time if current user edited the changeset before. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$changeset_post_id integer

Changeset post id.


WP_Customize_Manager:: refresh_nonces( )

Refresh nonces for the current preview. Since 4.2.0.


WP_Customize_Manager:: register_control_type( string $control )

Register a customize control type. Since 4.1.0.

Registered types are eligible to be rendered via JS and created dynamically.

Arguments

Name Type(s) Default Value Description
$control string

Name of a custom control which is a subclass of WP_Customize_Control.


WP_Customize_Manager:: register_controls( )

Register some default controls. Since 3.4.0.


WP_Customize_Manager:: register_dynamic_settings( )

Add settings from the POST data that were not added with code, e.g. dynamically-created settings for Widgets Since 4.2.0.


WP_Customize_Manager:: register_panel_type( string $panel )

Register a customize panel type. Since 4.3.0.

Registered types are eligible to be rendered via JS and created dynamically.

Arguments

Name Type(s) Default Value Description
$panel string

Name of a custom panel which is a subclass of WP_Customize_Panel.


WP_Customize_Manager:: register_section_type( string $section )

Register a customize section type. Since 4.3.0.

Registered types are eligible to be rendered via JS and created dynamically.

Arguments

Name Type(s) Default Value Description
$section string

Name of a custom section which is a subclass of WP_Customize_Section.


WP_Customize_Manager:: remove_control( string $id )

Remove a customize control. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

ID of the control.


WP_Customize_Manager:: remove_frameless_preview_messenger_channel( )

Remove customize_messenger_channel query parameter from the preview window when it is not in an iframe. Since 4.7.0.

This ensures that the admin bar will be shown. It also ensures that link navigation will work as expected since the parent frame is not being sent the URL to navigate to.


WP_Customize_Manager:: remove_panel( string $id )

Remove a customize panel. Since 4.0.0.

Arguments

Name Type(s) Default Value Description
$id string

Panel ID to remove.


WP_Customize_Manager:: remove_preview_signature( mixed $return = null )

This method is deprecated.

Removes the signature in case we experience a case where the Customizer was not properly executed. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$return mixed

Value passed through for {@see 'wp_die_handler'} filter.

Returns

mixed

Value passed through for {@see 'wp_die_handler'} filter.


WP_Customize_Manager:: remove_section( string $id )

Remove a customize section. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

Section ID.


WP_Customize_Manager:: remove_setting( string $id )

Remove a customize setting. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$id string

Customize Setting ID.


WP_Customize_Manager:: render_control_templates( )

Render JS templates for all registered control types. Since 4.1.0.


WP_Customize_Manager:: render_panel_templates( )

Render JS templates for all registered panel types. Since 4.3.0.


WP_Customize_Manager:: render_section_templates( )

Render JS templates for all registered section types. Since 4.3.0.


WP_Customize_Manager:: save( )

Handle customize_save WP Ajax request to save/update a changeset. Since 3.4.0. Since 4.7.0.


WP_Customize_Manager:: save_changeset_post( array $args = array() )

Save the post for the loaded changeset. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$args array

{ Args for changeset post.

@type array  $data            Optional additional changeset data. Values will be merged on top of any existing post values.
@type string $status          Post status. Optional. If supplied, the save will be transactional and a post revision will be allowed.
@type string $title           Post title. Optional.
@type string $date_gmt        Date in GMT. Optional.
@type int    $user_id         ID for user who is saving the changeset. Optional, defaults to the current user ID.
@type bool   $starter_content Whether the data is starter content. If false (default), then $starter_content will be cleared for any $data being saved.
@type bool   $autosave        Whether this is a request to create an autosave revision.

}

Returns

array | WP_Error

Returns array on success and WP_Error with array data on error.


WP_Customize_Manager:: sections( )

Get the registered sections. Since 3.4.0.

Returns

array


WP_Customize_Manager:: set_autofocus( array $autofocus )

Set the autofocused constructs. Since 4.4.0.

Arguments

Name Type(s) Default Value Description
$autofocus array

{ Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.

@type string [$control]  ID for control to be autofocused.
@type string [$section]  ID for section to be autofocused.
@type string [$panel]    ID for panel to be autofocused.

}


WP_Customize_Manager:: set_changeset_lock( integer $changeset_post_id, boolean $take_over = false )

Marks the changeset post as being currently edited by the current user. Since 4.9.0.

Arguments

Name Type(s) Default Value Description
$changeset_post_id integer

Changeset post id.

$take_over boolean

Take over the changeset, default is false.


WP_Customize_Manager:: set_post_value( string $setting_id, mixed $value )

Override a setting's value in the current customized state. Since 4.2.0.

The name "post_value" is a carry-over from when the customized state was exclusively sourced from $_POST['customized'].

Arguments

Name Type(s) Default Value Description
$setting_id string

ID for the WP_Customize_Setting instance.

$value mixed

Post value.


WP_Customize_Manager:: set_preview_url( string $preview_url )

Set the initial URL to be previewed. Since 4.4.0.

URL is validated.

Arguments

Name Type(s) Default Value Description
$preview_url string

URL to be previewed.


WP_Customize_Manager:: set_return_url( string $return_url )

Set URL to link the user to when closing the Customizer. Since 4.4.0.

URL is validated.

Arguments

Name Type(s) Default Value Description
$return_url string

URL for return link.


WP_Customize_Manager:: settings( )

Get the registered settings. Since 3.4.0.

Returns

array


WP_Customize_Manager:: settings_previewed( )

Gets whether settings are or will be previewed. Since 4.9.0.

Returns

boolean


WP_Customize_Manager:: setup_theme( )

Start preview and customize theme. Since 3.4.0.

Check if customize query variable exist. Init filters to filter the current theme.


WP_Customize_Manager:: start_previewing_theme( )

If the theme to be previewed isn't the active theme, add filter callbacks to swap it out at runtime. Since 3.4.0.


WP_Customize_Manager:: stop_previewing_theme( )

Stop previewing the selected theme. Since 3.4.0.

Removes filters to change the current theme.


WP_Customize_Manager:: theme( )

Get the theme being customized. Since 3.4.0.

Returns

WP_Theme


WP_Customize_Manager:: trash_changeset_post( integer | WP_Post $post )

Trash or delete a changeset post. Since 4.9.0.

The following re-formulates the logic from wp_trash_post() as done in wp_publish_post(). The reason for bypassing wp_trash_post() is that it will mutate the the post_content and the post_name when they should be untouched.

Arguments

Name Type(s) Default Value Description
$post integer | WP_Post

The changeset post.

Returns

mixed

A WP_Post object for the trashed post or an empty value on failure.


WP_Customize_Manager:: unsanitized_post_values( array $args = array() )

Get dirty pre-sanitized setting values in the current customized state. Since 4.1.1. Since 4.7.0.

The returned array consists of a merge of three sources:

  1. If the theme is not currently active, then the base array is any stashed theme mods that were modified previously but never published.
  2. The values from the current changeset, if it exists.
  3. If the user can customize, the values parsed from the incoming $_POST['customized'] JSON data.
  4. Any programmatically-set post values via WP_Customize_Manager::set_post_value().

The name "unsanitized_post_values" is a carry-over from when the customized state was exclusively sourced from $_POST['customized']. Nevertheless, the value returned will come from the current changeset post and from the incoming post data.

Arguments

Name Type(s) Default Value Description
$args array

{ Args.

@type bool $exclude_changeset Whether the changeset values should also be excluded. Defaults to false.
@type bool $exclude_post_data Whether the post input values should also be excluded. Defaults to false when lacking the customize capability.

}

Returns

array


WP_Customize_Manager:: update_stashed_theme_mod_settings( array $inactive_theme_mod_settings )

Update stashed theme mod settings. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$inactive_theme_mod_settings array

Mapping of stylesheet to arrays of theme mod settings.

Returns

array | false

Returns array of updated stashed theme mods or false if the update failed or there were no changes.


WP_Customize_Manager:: validate_setting_values( array $setting_values, array $options = array() )

Validates setting values. Since 4.6.0.

Validation is skipped for unregistered settings or for values that are already null since they will be skipped anyway. Sanitization is applied to values that pass validation, and values that become null or WP_Error after sanitizing are marked invalid.

Arguments

Name Type(s) Default Value Description
$setting_values array

Mapping of setting IDs to values to validate and sanitize.

$options array

{ Options.

@type bool $validate_existence  Whether a setting's existence will be checked.
@type bool $validate_capability Whether the setting capability will be checked.

}

Returns

array

Mapping of setting IDs to return value of validate method calls, either true or WP_Error.


WP_Customize_Manager:: wp_die( mixed $ajax_message, mixed $message = null )

Custom wp_die wrapper. Returns either the standard message for UI or the Ajax message. Since 3.4.0.

Arguments

Name Type(s) Default Value Description
$ajax_message mixed

Ajax return

$message mixed

UI message


WP_Customize_Manager:: wp_die_handler( )

This method is deprecated.

Return the Ajax wp_die() handler if it's a customized request. Since 3.4.0.

Returns

callable

Die handler.


WP_Customize_Manager:: wp_loaded( )

Register styles/scripts and initialize the preview of each setting Since 3.4.0.


WP_Customize_Manager:: wp_redirect_status( integer $status )

This method is deprecated.

Prevents Ajax requests from following redirects when previewing a theme by issuing a 200 response instead of a 30x. Since 3.4.0.

Instead, the JS will sniff out the location header.

Arguments

Name Type(s) Default Value Description
$status integer

Status.

Returns

integer


WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.