Automattic\WooCommerce\Blocks\BlockTypes

MiniCartItemsBlock{}WC 1.0└─ AbstractInnerBlock

MiniCartItemsBlock class.

Хуков нет.

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

$MiniCartItemsBlock = new MiniCartItemsBlock();
// use class methods

Методы

  1. protected render( $attributes, $content, $block )

Код MiniCartItemsBlock{} WC 11.1.0

<?php
class MiniCartItemsBlock extends AbstractInnerBlock {
	/**
	 * Block name.
	 *
	 * @var string
	 */
	protected $block_name = 'mini-cart-items-block';

	/**
	 * Render the markup for the Mini-Cart Contents block.
	 *
	 * @param array     $attributes Block attributes.
	 * @param string    $content    Block content.
	 * @param \WP_Block $block      Block instance.
	 * @return string Rendered block type output.
	 */
	protected function render( $attributes, $content, $block ) {
		$wrapper_attributes = get_block_wrapper_attributes(
			array(
				'class'    => 'wc-block-mini-cart__items',
				'tabindex' => '-1',
			)
		);

		ob_start();
		?>
		<div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
			<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
		</div>
		<?php
		return (string) ob_get_clean();
	}
}