WP_Block_Parser::add_inner_block

Advertisement

Summery Summery

Given a block structure from memory pushes a new block to the output list.

Syntax Syntax

WP_Block_Parser::add_inner_block( WP_Block_Parser_Block $block, int $token_start, int $token_length, int|null $last_offset = null )

Parameters Parameters

$block

(WP_Block_Parser_Block) (Required) The block to add to the output.

$token_start

(int) (Required) Byte offset into the document where the first token for the block starts.

$token_length

(int) (Required) Byte length of entire block from start of opening token to end of closing token.

$last_offset

(int|null) (Optional) Last byte offset into document if continuing form earlier output.

Default value: null

Source Source

File: wp-includes/class-wp-block-parser.php

	function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
		$parent                       = $this->stack[ count( $this->stack ) - 1 ];
		$parent->block->innerBlocks[] = (array) $block;
		$html                         = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );

		if ( ! empty( $html ) ) {
			$parent->block->innerHTML     .= $html;
			$parent->block->innerContent[] = $html;
		}

		$parent->block->innerContent[] = null;
		$parent->prev_offset           = $last_offset ? $last_offset : $token_start + $token_length;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
3.8.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.