Title: WP_View_Config_Data::apply
Published: August 20, 2026

---

# WP_View_Config_Data::apply( array $patch, int $version, string $method, string $mode ): 󠀁[WP_View_Config_Data](https://developer.wordpress.org/reference/classes/wp_view_config_data/)󠁿

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Applies a patch to the configuration, top-level key by top-level key.

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

Shared by merge(), replace(), and set(); the three differ only in how the value 
of a named key is applied, which is carried by $mode:

 * `merge` merges the value into the current one, lists by member identity;
 * `replace` merges the value in the same way but swaps lists wholesale;
 * `set` swaps the whole value in wholesale, without merging.

In every mode a top-level `null` resets the key it names to its default, a nested`
null` drops the property it names, and an omitted key is left untouched, so all 
three treat nulls the same way at every depth.

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

 `$patch`arrayrequired

The partial configuration to apply.

`$version`intrequired

The schema version the patch was authored against.

`$method`stringrequired

The public method the patch was passed to, for misuse reporting.

`$mode`stringrequired

How to apply each named key’s value: `merge`, `replace`, or `set`.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#return)󠁿

 [WP_View_Config_Data](https://developer.wordpress.org/reference/classes/wp_view_config_data/)
The instance, for chaining.

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

    ```php
    private function apply( array $patch, int $version, $method, $mode ) {
    	if ( $version <= 0 || $version > self::LATEST_VERSION ) {
    		_doing_it_wrong(
    			esc_html( $method ),
    			esc_html__( 'A view configuration patch must declare a supported schema version.' ),
    			'7.1.0'
    		);

    		return $this;
    	}

    	foreach ( $patch as $key => $value ) {
    		if ( ! in_array( $key, self::CONFIG_KEYS, true ) ) {
    			_doing_it_wrong(
    				esc_html( $method ),
    				sprintf(
    					/* translators: %s: the configuration key. */
    					esc_html__( '"%s" is not a documented view configuration key.' ),
    					esc_html( $key )
    				),
    				'7.1.0'
    			);
    			continue;
    		}

    		// A null patch value makes the top-level property reset to defaults.
    		if ( null === $value ) {
    			$this->config[ $key ] = $this->defaults[ $key ] ?? array();
    			continue;
    		}

    		// set() swaps the whole value in; merge()/replace() merge it into the
    		// current one, differing only in how they treat lists. In every mode a
    		// nested null still drops the property it names.
    		$this->config[ $key ] = 'set' === $mode
    			? $this->strip_nulls( $value )
    			: $this->merge_properties( $this->config[ $key ] ?? array(), $value, 'replace' === $mode );
    	}

    	return $this;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-view-config-data.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-view-config-data.php#L410)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-view-config-data.php#L410-L450)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_View_Config_Data::strip_nulls()](https://developer.wordpress.org/reference/classes/wp_view_config_data/strip_nulls/)`wp-includes/class-wp-view-config-data.php` |

Recursively drops every property whose value is `null` from a value.

  | 
| [WP_View_Config_Data::merge_properties()](https://developer.wordpress.org/reference/classes/wp_view_config_data/merge_properties/)`wp-includes/class-wp-view-config-data.php` |

Merges an incoming value into the current one, recursing by value shape.

  | 
| [esc_html__()](https://developer.wordpress.org/reference/functions/esc_html__/)`wp-includes/l10n.php` |

Retrieves the translation of $text and escapes it for safe use in HTML output.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/?output_format=md#)

| Used by | Description | 
| [WP_View_Config_Data::set()](https://developer.wordpress.org/reference/classes/wp_view_config_data/set/)`wp-includes/class-wp-view-config-data.php` |

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

  | 
| [WP_View_Config_Data::replace()](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/)`wp-includes/class-wp-view-config-data.php` |

Replaces list values while merging the rest of a partial configuration.

  | 
| [WP_View_Config_Data::merge()](https://developer.wordpress.org/reference/classes/wp_view_config_data/merge/)`wp-includes/class-wp-view-config-data.php` |

Merges a partial configuration into the existing one.

  |

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

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

## User Contributed Notes

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