wppaste
WordPress

get_the_block_template_html(): string

Since
5.8.0
Source
wp-includes/block-template.php:249
Returns the markup for the current template.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
9–73

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()one call below get_the_block_template_html()
  • optionoption read or writeget_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.

WhenInstructionsCalls it makes
!is_user_logged_in()9is_user_logged_in()
is_user_logged_in()14is_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()
always55->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_id60->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_id63–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

PHPCompiledExecutedBranchesNotes
8.6-dev949–7310
8.5949–7310
8.4949–73106 fewer instructions than PHP 8.3
8.31009–7910
8.21009–79102 more instructions than PHP 8.1
8.1989–8710
7.4989–8710

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

Changelog

Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.