Holds an entity's view configuration while it is being built.
Description
An instance of this class is what get_entity_view_config_{$kind}_{$name} filter callbacks receive: a callback changes the configuration by calling methods on the instance and returning it. The configuration has four top-level keys — default_view, default_layouts, view_list, and form — and there are three ways to contribute. They form a gradient of how deep the replacement reaches: <ul> <li>The merge() method merges partial changes (patches) into what is already there: default_view, default_layouts, and the form settings by key, and the view_list entries by view slug identity. This is what plugins should use: patches compose with core's configuration and with other plugins'.</li> <li>replace() applies a patch the same way merge() does, with one difference: a list in the patch replaces the current list wholesale instead of merging into it by member identity. 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.</li> <li>set() goes one step further: it replaces each top-level key the patch names wholesale, dropping whatever that key held instead of merging into it. It's for a callback that owns a key outright and wants to pin it to an exact shape without the inherited default leaking through a key-by-key merge.</li> </ul> All three touch only the top-level keys the patch names — an omitted key keeps whatever it had, and a top-level null value drops the key it names, which resets it to its default. They differ only in how deep the replacement reaches once a key is named: merge() and replace() merge the value in key by key (an associative array merges member by member, a nested null deletes just that leaf, a scalar replaces just that value), while set() swaps the whole value. A nested null deletes just the leaf it names in every case. A patch value whose shape does not match the current value — an associative array where a list lives, or the reverse — is rejected with a notice rather than merged, and an empty array under merge() is a no-op. Each patch also declares the configuration schema version it was written against (currently 1), so a future WordPress release that changes the configuration shape can migrate existing patches forward instead of breaking them. Where those three write values, remove() deletes them: it takes a spec of names — a list to delete entries at a level, or a nested map to reach deeper — and prunes just what it names, mirroring the configuration's shape all the way down to individual list members.
Hooks fired · 1
Every hook that fires from inside WP_View_Config_Data, in the order it appears in the class, grouped by the method that fires it.
58classWP_View_Config_Data{5960/**61 * The latest supported configuration schema version.62 *63 * @since 7.1.064 * @var int65 */66constLATEST_VERSION=1;6768/**69 * The documented top-level configuration keys.70 *71 * @since 7.1.072 * @var string[]73 */74constCONFIG_KEYS=array('default_view','default_layouts','view_list','form');7576/**77 * The configuration being contributed to.78 *79 * @since 7.1.080 * @var array81 */82private$config;8384/**85 * The default configuration.86 *87 * @since 7.1.088 * @var array89 */90private$defaults;9192/**93 * Constructor.94 *95 * @since 7.1.096 *97 * @param array $config The base configuration to contribute to.98 */99publicfunction__construct(array$config){100$this->config=$config;101$this->defaults=$config;102}103104/**105 * Returns the current configuration array.106 *107 * Deliberately private: filter callbacks receive the container, not the108 * materialized configuration, so they cannot read the built result and109 * become coupled to a specific configuration shape or schema version. Only110 * the class itself reconciles the container back into an array.111 *112 * @since 7.1.0113 *114 * @return array The configuration.115 */116privatefunctionget_data(){117return$this->config;118}119120/**121 * Applies the entity view configuration filter and returns the result.122 *123 * Exposes the container through the dynamic124 * `get_entity_view_config_{$kind}_{$name}` filter (with the dynamic portions125 * lowercased), so that core and third parties can provide the configuration for a specific entity,126 * then reconciles the filtered container back into a plain configuration array,127 * limited to the documented configuration keys.128 *129 * @since 7.1.0130 *131 * @param string $kind The entity kind (e.g. `postType`).132 * @param string $name The entity name (e.g. `page`).133 * @return array The filtered configuration, limited to the documented keys.134 */135publicfunctionapply_filters($kind,$name){136/**137* Filters the view configuration for a given entity.
History
Introduced in 7.1.0.
Signature, return type and hooks compared across 1 parsed release.
About this page
Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/class-wp-view-config-data.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.