wp_get_entity_view_config( string $kind, string $name ): array
- Since
- 7.1.0
- Source
wp-includes/view-config.php:139
Description
Builds the default configuration shared by all entities and then exposes it through the dynamic get_entity_view_config_{$kind}_{$name} filter — with the dynamic portions lowercased, see wp_get_entity_view_config_hook_name() — so that core and third parties can provide the configuration for a specific entity.
Compatibility
- WordPress
- since 7.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 1 of the 5 tracked releases, added in 7.1.0, and compiles on PHP 7.4 through 8.6-dev.
Parameters
$kindstring- The entity kind (e.g.
postType). $namestring- The entity name (e.g.
page).
Return value
array- The view configuration for the entity.
$default_viewarrayDefault view configuration.$default_layoutsarrayDefault layouts configuration.$view_listarrayList of available views.$formarrayForm configuration.
Performance profile
How much work a call to wp_get_entity_view_config() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 28–42
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 43.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_get_entity_view_config() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$kind !== "postType" | 28 | __(), default_view(), ->apply_filters() |
| always | 31 | __(), _wp_get_default_posttype_form(), default_view(), ->apply_filters() |
| always | 33–39 | __(), get_post_type_object(), default_view(), ->apply_filters() |
$kind === "postType" | 36–42 | __(), get_post_type_object(), _wp_get_default_posttype_form(), default_view(), ->apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 42 | 28–41 | 4 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 43 | 28–42 | 4 | |
| 8.4 | 43 | 28–42 | 4 | |
| 8.3 | 43 | 28–42 | 4 | |
| 8.2 | 43 | 28–42 | 4 | |
| 8.1 | 43 | 28–42 | 4 | |
| 7.4 | 43 | 28–42 | 4 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 4
- __()Retrieves the translation of $text.
- get_post_type_object()Retrieves a post type object by name.
- _wp_get_default_posttype_form()Builds the default `form` configuration for post types that don't provide their own.
- WP_View_Config_Data::__construct()Constructor.
Used by · 1
- WP_REST_View_Config_Controller::get_items()Returns the default view configuration for the given entity type.
Source code
function wp_get_entity_view_config( $kind, $name ) { $default_view = array( 'type' => 'table', 'filters' => array(), 'sort' => array( 'field' => 'title', 'direction' => 'asc', ), 'perPage' => 20, 'fields' => array( 'author', 'status' ), 'titleField' => 'title', ); $default_layouts = array( 'table' => array(), 'grid' => array(), 'list' => array(), ); $all_items_title = __( 'All items' ); if ( 'postType' === $kind ) { $post_type_object = get_post_type_object( $name ); if ( $post_type_object && ! empty( $post_type_object->labels->all_items ) ) { $all_items_title = $post_type_object->labels->all_items; } } $view_list = array( array( 'title' => $all_items_title, 'slug' => 'all', ), ); $config = array( 'default_view' => $default_view, 'default_layouts' => $default_layouts, 'view_list' => $view_list, 'form' => 'postType' === $kind ? _wp_get_default_posttype_form() : array(), ); $data = new WP_View_Config_Data( $config ); return $data->apply_filters( $kind, $name );}Changelog
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/view-config.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.