WP_Block_Parser::add_block_from_stack()publicWP 5.0.0

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

Метод класса: WP_Block_Parser{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Block_Parser = new WP_Block_Parser();
$WP_Block_Parser->add_block_from_stack( $end_offset );
$end_offset(int|null)
byte offset into document for where we should stop sending text output as HTML.
По умолчанию: null

Список изменений

С версии 5.0.0 Введена.

Код WP_Block_Parser::add_block_from_stack() WP 6.5.2

public 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) $this->freeform(
			substr(
				$this->document,
				$stack_top->leading_html_start,
				$stack_top->token_start - $stack_top->leading_html_start
			)
		);
	}

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