WP_Block_Parser::add_block_from_stack

Advertisement

Summery Summery

Pushes the top block from the parsing stack to the output list.

Syntax Syntax

WP_Block_Parser::add_block_from_stack( int|null $end_offset = null )

Parameters Parameters

$end_offset

(int|null) (Optional) byte offset into document for where we should stop sending text output as HTML.

Default value: null

Source Source

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

	function add_block_from_stack( $end_offset = null ) {
		$stack_top   = array_pop( $this->stack );
		$prev_offset = $stack_top->prev_offset;

		$html = isset( $end_offset )
			? substr( $this->document, $prev_offset, $end_offset - $prev_offset )
			: substr( $this->document, $prev_offset );

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

		if ( isset( $stack_top->leading_html_start ) ) {
			$this->output[] = (array) self::freeform(
				substr(
					$this->document,
					$stack_top->leading_html_start,
					$stack_top->token_start - $stack_top->leading_html_start
				)
			);
		}

		$this->output[] = (array) $stack_top->block;
	}

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.