Automattic\WooCommerce\Blocks\BlockTypes
SavedForLater::render_header_markup
Wrap the inner-block content (heading + any future siblings) in an element whose visibility mirrors the empty-state gating: hidden when the shopper has never seen items in this session, revealed once context.hasShownItems flips to true. Returns an empty string when there's no content to wrap (e.g. merchant deleted the heading and saved), so we don't emit an empty <div>.
Метод класса: SavedForLater{}
Хуков нет.
Возвращает
Строку.
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_header_markup( $content, $is_empty ): string;
- $content(строка) (обязательный)
- Rendered inner-block content (typically the heading HTML).
- $is_empty(true|false) (обязательный)
- Whether the saved-for-later list is empty on initial paint.
Код SavedForLater::render_header_markup() SavedForLater::render header markup WC 11.0.1
private function render_header_markup( string $content, bool $is_empty ): string {
if ( '' === $content ) {
return '';
}
$hidden_attr = $is_empty ? ' hidden' : '';
return sprintf(
'<div class="wc-block-saved-for-later__header" data-wp-bind--hidden="!context.hasShownItems"%s>%s</div>',
$hidden_attr,
$content
);
}