Automattic\WooCommerce\Blocks\BlockTypes

CustomerAccount::render()protectedWC 1.0

Render the block.

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

Хуков нет.

Возвращает

Строку. Rendered block output.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render( $attributes, $content, $block );
$attributes(массив) (обязательный)
Block attributes.
$content(строка) (обязательный)
Block content.
$block(WP_Block) (обязательный)
Block instance.

Код CustomerAccount::render() WC 9.0.2

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,
		),
	);

	// 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>';
}