get_the_block_template_html(): string
- Since
- 5.8.0
- Source
wp-includes/block-template.php:249
Compatibility
- WordPress
- since 5.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
string- Block template markup.
Performance profile
How much work a call to get_the_block_template_html() 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
- 9–73
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 94.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below get_the_block_template_html() - optionoption read or write
get_option()one call below get_the_block_template_html()
Further down the call graph this can also reach cache, serialize, query 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 · 17 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_the_block_template_html() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_user_logged_in() | 9 | is_user_logged_in() |
is_user_logged_in() | 14 | is_user_logged_in(), esc_html__() |
!has_action() | 50 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action() |
| always | 55 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action() |
!$_wp_current_template_id && !has_action() | 55 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action() |
has_action() | 58 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action(), _block_template_add_skip_link() |
$_wp_current_template_id && !has_action() | 58–61 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action() |
!$_wp_current_template_id | 60 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action() |
!$_wp_current_template_id && has_action() | 63 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action(), _block_template_add_skip_link() |
$_wp_current_template_id | 63–66 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action() |
$_wp_current_template_id && is_singular() && !have_posts() && !has_action() | 64 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action() |
$_wp_current_template_id && is_singular() && !has_action() | 65 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), have_posts(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action() |
5 further outcomes, up to 73 instructions
$_wp_current_template_id && has_action() | 66–69 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action(), _block_template_add_skip_link() |
$_wp_current_template_id && is_singular() && !have_posts() | 69 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action() |
$_wp_current_template_id && is_singular() | 70 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), have_posts(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action() |
$_wp_current_template_id && is_singular() && !have_posts() && has_action() | 72 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), do_blocks(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action(), _block_template_add_skip_link() |
$_wp_current_template_id && is_singular() && has_action() | 73 | ->run_shortcode(), ->autoembed(), shortcode_unautop(), do_shortcode(), get_stylesheet(), is_singular(), have_posts(), have_posts(), wptexturize(), convert_smilies(), wp_filter_content_tags(), has_action(), has_action(), _block_template_add_skip_link() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 94 | 9–73 | 10 | |
| 8.5 | 94 | 9–73 | 10 | |
| 8.4 | 94 | 9–73 | 10 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 100 | 9–79 | 10 | |
| 8.2 | 100 | 9–79 | 10 | 2 more instructions than PHP 8.1 |
| 8.1 | 98 | 9–87 | 10 | |
| 7.4 | 98 | 9–87 | 10 |
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 · 15
- is_user_logged_in()Determines whether the current visitor is a logged in user.
- esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
- shortcode_unautop()Don't auto-p wrap shortcodes that stand alone.
- do_shortcode()Searches content for shortcodes and filter shortcodes through their hooks.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- get_stylesheet()Retrieves name of the current stylesheet.
- is_singular()Determines whether the query is for an existing single post of any post type (post, attachment, page, custom post types).
- have_posts()Determines whether current WordPress query has posts to loop over.
- the_post()Iterate the post index in the loop.
- do_blocks()Parses dynamic blocks out of `post_content` and re-renders them.
- wptexturize()Replaces common plain text characters with formatted entities.
- convert_smilies()Converts text equivalent of smilies to images.
Show all 15
- wp_filter_content_tags()Filters specific tags in post content and modifies their markup.
- has_action()Checks if any action has been registered for a hook.
- _block_template_add_skip_link()Inserts the block template skip-link into the template HTML.
Changelog
Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/block-template.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.