Automattic\WooCommerce\Blocks\BlockTypes

MiniCart::build_mini_cart_overlay │ private │ WC 1.0

Build the Interactivity API Mini Cart overlay markup.

Called while the block itself renders (before the head is printed on block themes), so script modules that inner blocks enqueue during this render still reach the import map.

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

Хуков нет.

Возвращает

string. The overlay markup.

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

// private - только в коде основоного (родительского) класса
$result = $this->build_mini_cart_overlay();

Код MiniCart::build_mini_cart_overlay() WC 11.3.0

<?php
private function build_mini_cart_overlay() {
	$template_part_contents = $this->get_template_part_contents( false );

	$this->is_providing_reference_context = true;
	try {
		$template_part_contents = $this->render_template_part_contents( $template_part_contents );
	} finally {
		$this->is_providing_reference_context = false;
	}
	ob_start();
	?>
	<div
		data-wp-interactive="woocommerce/mini-cart"
		data-wp-router-region='{ "id": "woocommerce/mini-cart-overlay", "attachTo": "body" }'
		data-wp-key="wc-mini-cart-overlay"
		data-wp-on--click="actions.overlayCloseDrawer"
		data-wp-on--keydown="actions.handleOverlayKeydown"
		data-wp-watch="callbacks.focusFirstElement"
		data-wp-class--wc-block-components-drawer__screen-overlay--with-slide-in="state.isOpen"
		data-wp-class--wc-block-components-drawer__screen-overlay--is-hidden="!state.isOpen"
		class="wc-block-components-drawer__screen-overlay wc-block-components-drawer__screen-overlay--with-slide-out"
	>
		<div
			data-wp-bind--role="state.drawerRole"
			data-wp-bind--aria-modal="state.isOpen"
			data-wp-bind--aria-hidden="!state.isOpen"
			data-wp-bind--tabindex="state.drawerTabIndex"
			class="wc-block-mini-cart__drawer wc-block-components-drawer is-mobile"
		>
			<div class="wc-block-components-drawer__content">
				<div class="wc-block-mini-cart__template-part">
					<?php
						// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
						echo $template_part_contents;
					?>
				</div>
			</div>
		</div>
	</div>
	<?php
	return wp_interactivity_process_directives( (string) ob_get_clean() );
}