WP_Customize_Selective_Refresh::add_partial() WordPress Method

The WP_Customize_Selective_Refresh::add_partial() method allows customizer controls to selectively refresh partial contents on a page. This is useful for updating a portion of a page without refreshing the entire page. The selective refresh feature was introduced in WordPress 4.5.

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

Adds a partial.


Description

Top ↑

See also


Top ↑

Parameters

$id

(WP_Customize_Partial|string)(Required)Customize Partial object, or Partial ID.

$args

(array)(Optional) Array of properties for the new Partials object. See WP_Customize_Partial::__construct() for information on accepted arguments.

Default value: array()


Top ↑

Return

(WP_Customize_Partial) The instance of the partial that was added.


Top ↑

Source

File: wp-includes/customize/class-wp-customize-selective-refresh.php

	public function add_partial( $id, $args = array() ) {
		if ( $id instanceof WP_Customize_Partial ) {
			$partial = $id;
		} else {
			$class = 'WP_Customize_Partial';

			/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
			$args = apply_filters( 'customize_dynamic_partial_args', $args, $id );

			/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
			$class = apply_filters( 'customize_dynamic_partial_class', $class, $id, $args );

			$partial = new $class( $this, $id, $args );
		}

		$this->partials[ $partial->id ] = $partial;
		return $partial;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.