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>.
Method of the class: SavedForLater{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->render_header_markup( $content, $is_empty ): string;
- $content(string) (required)
- Rendered inner-block content (typically the heading HTML).
- $is_empty(true|false) (required)
- Whether the saved-for-later list is empty on initial paint.
SavedForLater::render_header_markup() SavedForLater::render header markup code WC 10.9.4
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
);
}