_wp_get_entity_view_config_posttype_wp_template( WP_View_Config_Data $data ): WP_View_Config_Data
- Since
- 7.1.0
- Source
wp-includes/view-config.php:550
wp_template post type.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
$dataWP_View_Config_Data- The view configuration container for the entity.
Return value
WP_View_Config_Data- The updated view configuration container.
Performance profile
How much work a call to _wp_get_entity_view_config_posttype_wp_template() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 35–36
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_user_by().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 208.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_user_by()called directly - hookthird-party callbacks
apply_filters()one call below _wp_get_entity_view_config_posttype_wp_template() - optionoption read or write
get_option()one call below _wp_get_entity_view_config_posttype_wp_template() - cacheobject cache
wp_cache_get()one call below _wp_get_entity_view_config_posttype_wp_template()
Further down the call graph this can also reach serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost _wp_get_entity_view_config_posttype_wp_template() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 35–36 | __(), get_block_templates(), array_merge(), default_view() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 208 | 35–36 | 32 | |
| 8.5 | 208 | 35–36 | 32 | |
| 8.4 | 208 | 35–36 | 32 | |
| 8.3 | 208 | 35–36 | 32 | |
| 8.2 | 208 | 35–36 | 32 | 1 more instruction than PHP 8.1 |
| 8.1 | 207 | 35–36 | 32 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 209 | 35–36 | 32 |
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 · 11
- __()Retrieves the translation of $text.
- get_block_templates()Retrieves a list of unified template objects based on a query.
- wp_get_theme()Gets a WP_Theme object for a theme.
- wp_get_active_and_valid_plugins()Retrieves an array of active and valid plugin files.
- plugin_basename()Gets the basename of a plugin.
- get_plugin_data()Parses the plugin contents to retrieve plugin's metadata.
- get_plugins()Checks the plugins directory and retrieve all plugin files with plugin data.
- sanitize_text_field()Sanitizes a string from user input or from the database.
- get_bloginfo()Retrieves information about the current site.
- get_user_by()Retrieves user info by a given field.
- wp_get_theme($template->theme)::get()
Source code
function _wp_get_entity_view_config_posttype_wp_template( $data ) { $default_view = array( 'type' => 'grid', 'perPage' => 20, 'sort' => array( 'field' => 'title', 'direction' => 'asc', ), 'titleField' => 'title', 'descriptionField' => 'description', 'mediaField' => 'preview', 'fields' => array( 'author', 'active', 'slug', 'theme' ), 'filters' => array(), 'showMedia' => true, ); $default_layouts = array( 'table' => array( 'showMedia' => false ), 'grid' => array( 'showMedia' => true ), 'list' => array( 'showMedia' => false ), ); $view_list = array( array( 'title' => __( 'All templates' ), 'slug' => 'all', ), ); $templates = get_block_templates( array(), 'wp_template' ); // Collect unique authors, tracking whether they come from a registered // source (theme, plugin, site) so we can sort those before user ones. $seen_authors = array(); $registered_authors = array(); $user_authors = array(); foreach ( $templates as $template ) { /* * Determine the original source of the template ('theme', 'plugin', * 'site', or 'user'). */ $original_source = 'user'; if ( 'wp_template' === $template->type || 'wp_template_part' === $template->type ) { if ( $template->has_theme_file && ( 'theme' === $template->origin || ( empty( $template->origin ) && in_array( $template->source, array( 'theme', 'custom', ), true ) ) ) ) { /* * Added by theme. * Template originally provided by a theme, but customized by a user. * Templates originally didn't have the 'origin' field so identify * older customized templates by checking for no origin and a 'theme' * or 'custom' source. */ $original_source = 'theme'; } elseif ( 'plugin' === $template->origin ) { // Added by plugin. $original_source = 'plugin'; } elseif ( empty( $template->has_theme_file ) && 'custom' === $template->source && empty( $template->author ) ) { /* * Added by site. * Template was created from scratch, but has no author. Author support * was only added to templates in WordPress 5.9. Fallback to showing the * site logo and title. */ $original_source = 'site'; } } // Determine a human readable text for the author of the template. $author_text = ''; switch ( $original_source ) {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.