Automattic\WooCommerce\Blocks\BlockTypes

CustomerAccount::renderprotectedWC 1.0

Render the block.

Method of the class: CustomerAccount{}

No Hooks.

Returns

String. Rendered block output.

Usage

// protected - for code of main (parent) or child class
$result = $this->render( $attributes, $content, $block );
$attributes(array) (required)
Block attributes.
$content(string) (required)
Block content.
$block(WP_Block) (required)
Block instance.

CustomerAccount::render() code WC 9.9.4

protected function render( $attributes, $content, $block ) {
	$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );

	$account_link = get_option( 'woocommerce_myaccount_page_id' ) ? wc_get_account_endpoint_url( 'dashboard' ) : wp_login_url();

	$allowed_svg = array(
		'svg'    => array(
			'class'   => true,
			'xmlns'   => true,
			'width'   => true,
			'height'  => true,
			'viewbox' => true,
		),
		'path'   => array(
			'd'         => true,
			'fill'      => true,
			'fill-rule' => true,
			'clip-rule' => true,
		),
		'circle' => array(
			'cx'           => true,
			'cy'           => true,
			'r'            => true,
			'stroke'       => true,
			'stroke-width' => true,
			'fill'         => true,
		),
	);

	// Only provide aria-label if the display style is icon only.
	$aria_label = self::ICON_ONLY === $attributes['displayStyle'] ? 'aria-label="' . esc_attr( $this->render_label() ) . '"' : '';

	$label_markup = self::ICON_ONLY === $attributes['displayStyle'] ? '' : '<span class="label">' . wp_kses( $this->render_label(), array() ) . '</span>';

	return "<div class='wp-block-woocommerce-customer-account " . esc_attr( $classes_and_styles['classes'] ) . "' style='" . esc_attr( $classes_and_styles['styles'] ) . "'>
		<a " . $aria_label . " href='" . esc_attr( $account_link ) . "'>
			" . wp_kses( $this->render_icon( $attributes ), $allowed_svg ) . $label_markup . '
		</a>
	</div>';
}