WordPress at a glance
function is not described

WP_Customize_Selective_Refresh::add_dynamic_partials() WP 4.5.0

Registers dynamically-created partials.

This is a method of the class: WP_Customize_Selective_Refresh

Return

WP_Customize_Partial[]. Array of added WP_Customize_Partial instances.

Usage

$WP_Customize_Selective_Refresh = new WP_Customize_Selective_Refresh();
$var = $WP_Customize_Selective_Refresh->add_dynamic_partials( $partial_ids );
$partial_ids(string[]) (required)
Array of the partial IDs to add.

Notes

  • See: WP_Customize_Manager::add_dynamic_settings()

Changelog

Since 4.5.0 Introduced.

Code of WP Customize Selective Refresh::add dynamic partials: wp-includes/customize/class-wp-customize-selective-refresh.php WP 5.4.2

<?php
public function add_dynamic_partials( $partial_ids ) {
	$new_partials = array();

	foreach ( $partial_ids as $partial_id ) {

		// Skip partials already created.
		$partial = $this->get_partial( $partial_id );
		if ( $partial ) {
			continue;
		}

		$partial_args  = false;
		$partial_class = 'WP_Customize_Partial';

		/**
		 * Filters a dynamic partial's constructor arguments.
		 *
		 * For a dynamic partial to be registered, this filter must be employed
		 * to override the default false value with an array of args to pass to
		 * the WP_Customize_Partial constructor.
		 *
		 * @since 4.5.0
		 *
		 * @param false|array $partial_args The arguments to the WP_Customize_Partial constructor.
		 * @param string      $partial_id   ID for dynamic partial.
		 */
		$partial_args = apply_filters( 'customize_dynamic_partial_args', $partial_args, $partial_id );
		if ( false === $partial_args ) {
			continue;
		}

		/**
		 * Filters the class used to construct partials.
		 *
		 * Allow non-statically created partials to be constructed with custom WP_Customize_Partial subclass.
		 *
		 * @since 4.5.0
		 *
		 * @param string $partial_class WP_Customize_Partial or a subclass.
		 * @param string $partial_id    ID for dynamic partial.
		 * @param array  $partial_args  The arguments to the WP_Customize_Partial constructor.
		 */
		$partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args );

		$partial = new $partial_class( $this, $partial_id, $partial_args );

		$this->add_partial( $partial );
		$new_partials[] = $partial;
	}
	return $new_partials;
}