Title: WP_Customize_Partial::__construct
Published: April 12, 2016
Last modified: April 28, 2025

---

# WP_Customize_Partial::__construct( WP_Customize_Selective_Refresh $component, string $id, array $args = array() )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#wp--skip-link--target)

Constructor.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#description)󠁿

Supplied `$args` override class property defaults.

If `$args['settings']` is not defined, use the $id as the setting ID.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#parameters)󠁿

 `$component`[WP_Customize_Selective_Refresh](https://developer.wordpress.org/reference/classes/wp_customize_selective_refresh/)
required

Customize Partial Refresh plugin instance.

`$id`stringrequired

Control ID.

`$args`arrayoptional

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` string[]
 * IDs for settings tied to the partial. If undefined, `$id` will be used.
 * `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](https://developer.wordpress.org/reference/classes/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:`array()`

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct( WP_Customize_Selective_Refresh $component, $id, $args = array() ) {
    	$keys = array_keys( get_object_vars( $this ) );
    	foreach ( $keys as $key ) {
    		if ( isset( $args[ $key ] ) ) {
    			$this->$key = $args[ $key ];
    		}
    	}

    	$this->component       = $component;
    	$this->id              = $id;
    	$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
    	$this->id_data['base'] = array_shift( $this->id_data['keys'] );

    	if ( empty( $this->render_callback ) ) {
    		$this->render_callback = array( $this, 'render_callback' );
    	}

    	// Process settings.
    	if ( ! isset( $this->settings ) ) {
    		$this->settings = array( $id );
    	} elseif ( is_string( $this->settings ) ) {
    		$this->settings = array( $this->settings );
    	}

    	if ( empty( $this->primary_setting ) ) {
    		$this->primary_setting = current( $this->settings );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-partial.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/customize/class-wp-customize-partial.php#L161)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/customize/class-wp-customize-partial.php#L161-L188)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_partial/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_partial%2F__construct%2F)
before being able to contribute a note or feedback.