Automattic\WooCommerce\Blocks\BlockTypes

EmptyMiniCartContentsBlock::render │ protected │ WC 1.0

Render the markup for the Empty Mini-Cart Contents block.

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

Хуков нет.

Возвращает

string. Rendered block type output.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render( $attributes, $content, $block );
$attributes(массив) (обязательный)
Block attributes.
$content(строка) (обязательный)
Block content.
$block(WP_Block) (обязательный)
Block instance.

Код EmptyMiniCartContentsBlock::render() WC 11.2.2

<?php
protected function render( $attributes, $content, $block ) {
	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'data-wp-bind--aria-hidden' => '!state.cartIsEmpty',
			'data-wp-bind--hidden'      => '!state.cartIsEmpty',
			'data-wp-interactive'       => 'woocommerce/mini-cart',
		)
	);

	ob_start();
	?>
	<div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
		<div class="wc-block-mini-cart__empty-cart-wrapper">
			<?php
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
				echo $content;
			?>
		</div>
	</div>
	<?php
	return (string) ob_get_clean();
}