Automattic\WooCommerce\Blocks\BlockTypes
CartLink::render
Render the block.
Метод класса: CartLink{}
Хуков нет.
Возвращает
Строку. | void Rendered block output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
- $content(строка) (обязательный)
- Block content.
- $block(WP_Block) (обязательный)
- Block instance.
Код CartLink::render() CartLink::render WC 10.4.0
protected function render( $attributes, $content, $block ) {
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
$icon = MiniCartUtils::get_svg_icon( $attributes['cartIcon'] ?? '' );
$text = array_key_exists( 'content', $attributes ) ? esc_html( $attributes['content'] ) : esc_html__( 'Cart', 'woocommerce' );
return sprintf(
'<div %1$s><a class="wc-block-cart-link" href="%2$s">%3$s<span class="wc-block-cart-link__text">%4$s</span></a></div>',
get_block_wrapper_attributes(
array(
'class' => esc_attr( $classes_and_styles['classes'] ),
'style' => $classes_and_styles['styles'],
)
),
esc_url( wc_get_cart_url() ),
$icon,
$text
);
}