WP_Customize_Selective_Refresh::add_partial

Advertisement

Summery Summery

Adds a partial.

Syntax Syntax

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

Parameters Parameters

$id

(Required) Customize Partial object, or Panel ID.

$args

(Optional) Array of properties for the new Partials object.

  • 'type'
    (string) Type of the partial to be created.
  • 'selector'
    (string) The jQuery selector to find the container element for the partial, that is, a partial's placement.
  • 'settings'
    (array) IDs for settings tied to the partial.
  • 'primary_setting'
    (string) 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.
  • 'capability'
    (string) Capability required to edit this partial. Normally this is empty and the capability is derived from the capabilities of the associated $settings.
  • 'render_callback'
    (callable) 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.
  • 'container_inclusive'
    (bool) Whether the container element is included in the partial, or if only the contents are rendered.
  • 'fallback_refresh'
    (bool) 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.

Default value: array()

Return Return

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

Source Source

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

		return $partial;
	}

	/**
	 * Retrieves a partial.
	 *
	 * @since 4.5.0
	 *
	 * @param string $id Customize Partial ID.
	 * @return WP_Customize_Partial|null The partial, if set. Otherwise null.
	 */
	public function get_partial( $id ) {
		if ( isset( $this->partials[ $id ] ) ) {
			return $this->partials[ $id ];
		} else {
			return null;
		}
	}

Advertisement

Changelog Changelog

Changelog
Version Description
4.5.0 Introduced.

Advertisement

Leave a Reply