wp-includes/class-wp-block.php:529Generates the render output for the block.
$optionsarrayoptionalarray()$dynamicbool
string7 hooks fire while WP_Block::render() runs, in this order:
Filters whether Interactivity API should process directives.
Allows render_block() to be short-circuited, by returning a non-null value.
Filters the block being rendered in render_block(), before it's processed.
Filters the default context provided to a rendered block.
Filters the content of a single block.
Filters the content of a single block.
Filters whether to enqueue assets for a block which has no rendered content.
public function render( $options = array() ) { global $post; $before_wp_enqueue_scripts_count = did_action( 'wp_enqueue_scripts' ); // Capture the current assets queues. $before_styles_queue = wp_styles()->queue; $before_scripts_queue = wp_scripts()->queue; $before_script_modules_queue = wp_script_modules()->get_queue(); /* * There can be only one root interactive block at a time because the rendered HTML of that block contains * the rendered HTML of all its inner blocks, including any interactive block. */ static $root_interactive_block = null; /** * Filters whether Interactivity API should process directives. * * @since 6.6.0 * * @param bool $enabled Whether the directives processing is enabled. */ $interactivity_process_directives_enabled = apply_filters( 'interactivity_process_directives', true ); if ( $interactivity_process_directives_enabled && null === $root_interactive_block && ( ( isset( $this->block_type->supports['interactivity'] ) && true === $this->block_type->supports['interactivity'] ) || ! empty( $this->block_type->supports['interactivity']['interactive'] ) ) ) { $root_interactive_block = $this; } $options = wp_parse_args( $options, array( 'dynamic' => true, ) ); // Process the block bindings and get attributes updated with the values from the sources. $computed_attributes = $this->process_block_bindings(); if ( ! empty( $computed_attributes ) ) { // Merge the computed attributes with the original attributes. $this->attributes = array_merge( $this->attributes, $computed_attributes ); } $is_dynamic = $options['dynamic'] && $this->name && null !== $this->block_type && $this->block_type->is_dynamic(); $block_content = ''; /* * Byte offsets in $block_content where each inner block's rendered output * begins. Block bindings rich-text replacement uses these to stop at the * first inner block inside a selector, so it replaces only the block's own * rich text and never the markup produced by nested inner blocks. * * They are only collected when the block has bound attributes to resolve; * otherwise they are never read, so recording them would add work to every * block render for no benefit. */ $inner_block_offsets = array(); $collect_offsets = ! empty( $computed_attributes ); if ( ! $options['dynamic'] || empty( $this->block_type->skip_inner_blocks ) ) { $index = 0; foreach ( $this->inner_content as $chunk ) { if ( is_string( $chunk ) ) { $block_content .= $chunk; } else { if ( $collect_offsets ) { $inner_block_offsets[] = strlen( $block_content ); } $inner_block = $this->inner_blocks[ $index ]; $parent_block = $this; /** This filter is documented in wp-includes/blocks.php */ $pre_render = apply_filters( 'pre_render_block', null, $inner_block->parsed_block, $parent_block ); if ( ! is_null( $pre_render ) ) { $block_content .= $pre_render;Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-block.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.