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

Constructor.


Description Description

Supplied $args override class property defaults.

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


Parameters Parameters

$component

(WP_Customize_Selective_Refresh) (Required) Customize Partial Refresh plugin instance.

$id

(string) (Required) Control ID.

$args

(array) (Optional) Arguments to override class property defaults.

  • 'settings'
    (array|string) All settings IDs tied to the partial. If undefined, $id will be used.

Default value: array()


Top ↑

Source Source

File: wp-includes/customize/class-wp-customize-partial.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 );
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.