Class: WP_Customize_Selective_Refresh

Core Customizer class for implementing selective refresh.


Properties

Name Type(s) Default Value Summary
manager WP_Customize_Manager Customize manager.
partials array<mixed,WP_Customize_Partial> Registered instances of WP_Customize_Partial.
triggered_errors array Log of errors triggered when partials are rendered.
current_partial_id string Keep track of the current partial being rendered.

Methods

WP_Customize_Selective_Refresh:: __construct( WP_Customize_Manager $manager )

Plugin bootstrap for Partial Refresh functionality. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$manager WP_Customize_Manager

Manager instance.


WP_Customize_Selective_Refresh:: add_dynamic_partials( array<mixed,string> $partial_ids )

Registers dynamically-created partials. Since 4.5.0.

Arguments

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

Array of the partial IDs to add.

Returns

array<mixed,WP_Customize_Partial>

Array of added WP_Customize_Partial instances.


WP_Customize_Selective_Refresh:: add_partial( WP_Customize_Partial | string $id, array $args = array() )

Adds a partial. Since 4.5.0.

Arguments

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

Customize Partial object, or Panel ID.

$args array

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

@type string $type Type of the partial to be created. @type string $selector The jQuery selector to find the container element for the partial, that is, a partial's placement. @type array $settings IDs for settings tied to the partial. @type string $primary_setting The ID for the setting that this partial is primarily responsible for rendering. If not supplied, it will default to the ID of the first setting. @type string $capability Capability required to edit this partial. Normally this is empty and the capability is derived from the capabilities of the associated $settings. @type callable $render_callback Render callback. Callback is called with one argument, the instance of WP_Customize_Partial. The callback can either echo the partial or return the partial as a string, or return false if error. @type bool $container_inclusive Whether the container element is included in the partial, or if only the contents are rendered. @type bool $fallback_refresh Whether to refresh the entire preview in case a partial cannot be refreshed. A partial render is considered a failure if the render_callback returns false. }

Returns

WP_Customize_Partial

The instance of the panel that was added.


WP_Customize_Selective_Refresh:: enqueue_preview_scripts( )

Enqueues preview scripts. Since 4.5.0.


WP_Customize_Selective_Refresh:: export_preview_data( )

Exports data in preview after it has finished rendering so that partials can be added at runtime. Since 4.5.0.


WP_Customize_Selective_Refresh:: get_partial( string $id )

Retrieves a partial. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id string

Customize Partial ID.

Returns

WP_Customize_Partial | null

The partial, if set. Otherwise null.


WP_Customize_Selective_Refresh:: handle_error( integer $errno, string $errstr, string $errfile = null, string $errline = null )

Handles PHP errors triggered during rendering the partials. Since 4.5.0.

These errors will be relayed back to the client in the Ajax response.

Arguments

Name Type(s) Default Value Description
$errno integer

Error number.

$errstr string

Error string.

$errfile string

Error file.

$errline string

Error line.

Returns

true

Always true.


WP_Customize_Selective_Refresh:: handle_render_partials_request( )

Handles the Ajax request to return the rendered partials for the requested placements. Since 4.5.0.


WP_Customize_Selective_Refresh:: init_preview( )

Initializes the Customizer preview. Since 4.5.0.


WP_Customize_Selective_Refresh:: is_render_partials_request( )

Checks whether the request is for rendering partials. Since 4.5.0.

Note that this will not consider whether the request is authorized or valid, just that essentially the route is a match.

Returns

boolean

Whether the request is for rendering partials.


WP_Customize_Selective_Refresh:: partials( )

Retrieves the registered partials. Since 4.5.0.

Returns

array

Partials.


WP_Customize_Selective_Refresh:: remove_partial( string $id )

Removes a partial. Since 4.5.0.

Arguments

Name Type(s) Default Value Description
$id string

Customize Partial ID.


WordPress Developer Newsletter

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