renderButton($atts);
}
protected function renderButton($atts = []): void
{
$displayType = Arr::get($atts, 'display_type', 'button');
$buttonText = Arr::get($atts, 'button_text', '');
$isShortcode = Helper::toBool(Arr::get($atts, 'is_shortcode', false));
$linkTarget = Arr::get($atts, 'link_target', '_self');
$showIcon = Helper::toBool(Arr::get($atts, 'show_icon', true), true);
$customClass = trim(Arr::get($atts, 'class', ''));
$extraClass = trim(Arr::get($atts, 'extra_class', ''));
if (empty($buttonText)) {
$buttonText = __('My Account', 'fluent-cart');
}
$class = $customClass ?: ($displayType === 'button'
? 'wp-block-button__link wp-element-button fct-customer-dashboard-btn'
: 'fct-customer-dashboard-link');
$linkAtts = [
'href' => TemplateService::getCustomerProfileUrl(),
'class' => $class,
'aria-label' => $buttonText,
'target' => $linkTarget,
];
if ($linkTarget === '_blank') {
$linkAtts['rel'] = 'noopener noreferrer';
}
if ($extraClass) {
$linkAtts['class'] .= ' ' . $extraClass;
}
if ($isShortcode) {
ob_start();
$this->renderAttributes($linkAtts);
$wrapperAttributes = ob_get_clean();
} else {
$wrapperAttributes = RenderHelper::getBlockWrapperAttributes($linkAtts);
}
?>
>
getUserIcon(); ?>
';
}
protected function renderAttributes($atts = []): void
{
foreach ($atts as $attr => $value) {
if ($value !== '') {
echo esc_attr($attr) . '="' . esc_attr((string)$value) . '" ';
} else {
echo esc_attr($attr);
}
}
}
}