WP_View_Config_Data::set( array $patch, int $version ): WP_View_Config_Data

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

Description

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.

Parameters

$patcharrayrequired
The partial configuration whose named keys to replace.
$versionintrequired
The schema version the patch was authored against.

Return

WP_View_Config_Data The instance, for chaining.

Source

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

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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