wp_render_typography_support( string $block_content, array $block ): string
- Since
- 6.1.0
- Source
wp-includes/block-supports/typography.php:306
Compatibility
- WordPress
- since 6.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 every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$block_contentstring- Rendered block content.
$blockarray- Block object.
Return value
string- Filtered block content.
Performance profile
How much work a call to wp_render_typography_support() 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
- Scaling
- Constant
- Instructions
- 11–47
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 85.
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 wp_render_typography_support()
Further down the call graph this can also reach cache, option, 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 · 10 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_render_typography_support() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) | 11–14 | none |
!empty($value) && is_admin() && !isset($value) | 17 | is_admin() |
!empty($value) && !is_admin() && empty($block_content) | 17 | is_admin(), wp_enqueue_script_module() |
isset($value) | 22–27 | size() |
!empty($value) && !is_admin() && !empty($block_content) && !->next_tag() | 24 | is_admin(), wp_enqueue_script_module(), ->next_tag() |
!empty($value) && is_admin() && isset($value) | 28–30 | is_admin(), size() |
isset($value) && !empty($fluid_font_size) && $fluid_font_size !== false | 41–44 | size(), preg_quote(), esc_attr(), preg_replace() |
!empty($value) && !is_admin() && !empty($block_content) && ->next_tag() && ->get_attribute() | 43 | is_admin(), wp_enqueue_script_module(), ->next_tag(), ->get_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->get_updated_html() |
!empty($value) && is_admin() && isset($value) && !empty($fluid_font_size) && $fluid_font_size !== false | 47 | is_admin(), size(), preg_quote(), esc_attr(), preg_replace() |
!empty($value) && !is_admin() && !empty($block_content) && ->next_tag() && !->get_attribute() | 47 | is_admin(), wp_enqueue_script_module(), ->next_tag(), ->get_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->get_updated_html() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 85 instructions, 11–47 executed per call, 9 branches. The work does not change between versions.
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 · 5
- is_admin()Determines whether the current request is for an administrative interface page.
- wp_enqueue_script_module()Marks the script module to be enqueued in the page.
- wp_get_typography_font_size_value()Returns a font-size value based on a given font-size preset.
- esc_attr()Escaping for HTML attributes.
- WP_HTML_Tag_Processor::__construct()Constructor.
Source code
function wp_render_typography_support( $block_content, $block ) { if ( ! empty( $block['attrs']['fitText'] ) && $block['attrs']['fitText'] && ! is_admin() ) { wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' ); // Add Interactivity API directives for fit text to work with client-side navigation. if ( ! empty( $block_content ) ) { $processor = new WP_HTML_Tag_Processor( $block_content ); if ( $processor->next_tag() ) { if ( ! $processor->get_attribute( 'data-wp-interactive' ) ) { $processor->set_attribute( 'data-wp-interactive', true ); } $processor->set_attribute( 'data-wp-context---core-fit-text', 'core/fit-text::{"fontSize":""}' ); $processor->set_attribute( 'data-wp-init---core-fit-text', 'core/fit-text::callbacks.init' ); $processor->set_attribute( 'data-wp-style--font-size', 'core/fit-text::context.fontSize' ); $block_content = $processor->get_updated_html(); } } // fitText supersedes any other typography features return $block_content; } if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) { return $block_content; } $custom_font_size = $block['attrs']['style']['typography']['fontSize']; $fluid_font_size = wp_get_typography_font_size_value( array( 'size' => $custom_font_size ) ); /* * Checks that $fluid_font_size does not match $custom_font_size, * which means it's been mutated by the fluid font size functions. */ if ( ! empty( $fluid_font_size ) && $fluid_font_size !== $custom_font_size ) { // Replaces the first instance of `font-size:$custom_font_size` with `font-size:$fluid_font_size`. return preg_replace( '/font-size\s*:\s*' . preg_quote( $custom_font_size, '/' ) . '\s*;?/', 'font-size:' . esc_attr( $fluid_font_size ) . ';', $block_content, 1 ); } return $block_content;}Changelog
Introduced in 6.1.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-supports/typography.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.