Automattic\WooCommerce\Blocks\BlockTypes

CustomerAccount::renderprotectedWC 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 10.9.4

protected function render( $attributes, $content, $block ) {
	$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
	$has_myaccount_page = get_option( 'woocommerce_myaccount_page_id' );
	$account_link       = $has_myaccount_page ? wc_get_account_endpoint_url( 'dashboard' ) : wp_login_url();
	$has_dropdown       = ! empty( $attributes['hasDropdownNavigation'] ) && is_user_logged_in() && $has_myaccount_page;

	$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>';

	if ( ! $has_dropdown ) {
		return $this->render_link( $attributes, $classes_and_styles, $account_link, $aria_label, $label_markup );
	}

	return $this->render_dropdown( $attributes, $classes_and_styles, $aria_label, $label_markup );
}