wppaste
WordPress

wp_get_entity_view_config( string $kind, string $name ): array

Since
7.1.0
Source
wp-includes/view-config.php:139
Returns the view configuration for the given entity.

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_viewarray

    Default view configuration.
  • $default_layoutsarray

    Default layouts configuration.
  • $view_listarray

    List of available views.
  • $formarray

    Form 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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
28–42

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 43.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

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.

WhenInstructionsCalls it makes
$kind !== "postType"28__(), default_view(), ->apply_filters()
always31__(), _wp_get_default_posttype_form(), default_view(), ->apply_filters()
always33–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

PHPCompiledExecutedBranchesNotes
8.6-dev4228–4141 fewer instruction than PHP 8.5
8.54328–424
8.44328–424
8.34328–424
8.24328–424
8.14328–424
7.44328–424

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

Used by · 1

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.