WP_View_Config_Data::replace
Replaces list values while merging the rest of a partial configuration.
Takes the same arguments as merge() and applies the patch the same way, with one difference: a list in the patch replaces the current list wholesale instead of merging into it by member identity. Associative arrays still merge key by key, null still drops what it names, and a scalar still replaces the current value.
It shouldn't be the default choice — a callback that replaces a list stops inheriting core's future additions to it — but it's useful when a contributor needs to pin a list to an exact set of members.
The shape rule applies here too: a patch value whose shape does not match the current value — an associative array where a list lives, or a non-empty list where an associative value lives — is rejected with a notice and leaves the current value unchanged. An empty array is exempt, so replacing a list with an empty list still clears it.
A patch that declares an unsupported schema version is rejected and does not change anything.
Метод класса: WP_View_Config_Data{}
Хуков нет.
Возвращает
WP_View_Config_Data. The instance, for chaining.
Использование
$WP_View_Config_Data = new WP_View_Config_Data(); $WP_View_Config_Data->replace( $patch, $version );
- $patch(массив) (обязательный)
- The partial configuration to apply.
- $version(int) (обязательный)
- The schema version the patch was authored against.
Список изменений
| С версии 7.1.0 | Введена. |
Код WP_View_Config_Data::replace() WP View Config Data::replace WP 7.1.4
public function replace( array $patch, int $version ) {
return $this->apply( $patch, $version, __METHOD__, 'replace' );
}