WP_View_Config_Data::setpublicWP 7.1.0

Replaces whole top-level keys, leaving the rest of the configuration alone.

Like merge() and replace(), set() applies a patch of top-level keys and touches only the keys the patch names: a key the patch omits keeps whatever it had, and a null value drops the key it names (which resets it to its default). The difference is depth — where merge() and replace() merge a named key's value into the current one key by key, set() swaps the whole value in wholesale, dropping whatever the key held before. A null nested within that value still drops the property it names, so set() honours nulls at every depth just as merge() and replace() do.

Use it when a callback owns a key outright and wants to pin it to an exact shape, without the inherited default leaking through a key-by-key merge.

A patch that declares an unsupported schema version is rejected and does not change anything.

Method of the class: WP_View_Config_Data{}

No Hooks.

Returns

WP_View_Config_Data. The instance, for chaining.

Usage

$WP_View_Config_Data = new WP_View_Config_Data();
$WP_View_Config_Data->set( $patch, $version );
$patch(array) (required)
The partial configuration whose named keys to replace.
$version(int) (required)
The schema version the patch was authored against.

Changelog

Since 7.1.0 Introduced.

WP_View_Config_Data::set() code WP 7.1

public function set( array $patch, int $version ) {
	return $this->apply( $patch, $version, __METHOD__, 'set' );
}