_wp_get_entity_view_config_posttype_wp_block( WP_View_Config_Data $data ): WP_View_Config_Data
- Since
- 7.1.0
- Source
wp-includes/view-config.php:330
wp_block 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_block() 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
- 48–58
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_terms().
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 74.
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_terms()called directly - hookthird-party callbacks
apply_filters()one call below _wp_get_entity_view_config_posttype_wp_block()
Further down the call graph this can also reach option, cache, 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 · 2 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_posttype_wp_block() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$categories | 48–53 | __(), __(), ::WP_Block_Pattern_Categories_Registry(), ->get_all_registered(), get_terms(), is_wp_error(), asort(), default_view() |
$categories | 53–58 | __(), __(), ::WP_Block_Pattern_Categories_Registry(), ->get_all_registered(), __(), get_terms(), is_wp_error(), asort(), default_view() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 74 | 48–58 | 8 | |
| 8.5 | 74 | 48–58 | 8 | |
| 8.4 | 74 | 48–58 | 8 | |
| 8.3 | 74 | 48–58 | 8 | |
| 8.2 | 74 | 48–58 | 8 | |
| 8.1 | 74 | 48–58 | 8 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 75 | 48–59 | 8 |
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_terms()Retrieves the terms in a given taxonomy or list of taxonomies.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- WP_Block_Pattern_Categories_Registry::get_instance()Utility method to retrieve the main instance of the class.
Source code
function _wp_get_entity_view_config_posttype_wp_block( $data ) { $default_layouts = array( 'table' => array( 'layout' => array( 'styles' => array( 'author' => array( 'width' => '1%', ), ), ), ), 'grid' => array( 'layout' => array( 'badgeFields' => array( 'sync-status' ), ), ), ); $default_view = array( 'type' => 'grid', 'perPage' => 20, 'titleField' => 'title', 'mediaField' => 'preview', 'fields' => array( 'sync-status' ), 'filters' => array(), 'layout' => $default_layouts['grid']['layout'], ); $view_list = array( array( 'title' => __( 'All patterns' ), 'slug' => 'all-patterns', ), array( 'title' => __( 'My patterns' ), 'slug' => 'my-patterns', ), ); // Gather categories from the block pattern categories registry. $registry = WP_Block_Pattern_Categories_Registry::get_instance(); $categories = array(); foreach ( $registry->get_all_registered() as $category ) { $categories[ $category['name'] ] = $category['label']; } // Ensure "Uncategorized" is always included for patterns // that have no category assigned. $categories['uncategorized'] ??= __( 'Uncategorized' ); // Also gather user-created pattern categories (wp_pattern_category taxonomy). $user_terms = get_terms( array( 'taxonomy' => 'wp_pattern_category', 'hide_empty' => false, ) ); if ( ! is_wp_error( $user_terms ) ) { foreach ( $user_terms as $term ) { $categories[ $term->slug ] = $term->name; } } // Sort categories alphabetically by label. asort( $categories, SORT_NATURAL | SORT_FLAG_CASE ); foreach ( $categories as $category_name => $label ) { $view_list[] = array( 'title' => $label, 'slug' => $category_name, ); } $form = array( 'layout' => array( 'type' => 'panel' ), 'fields' => array( array( 'id' => 'excerpt',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.