Automattic\WooCommerce\Blocks\BlockTypes
CustomerAccount::render_visual
Render the user avatar and icon.
Метод класса: CustomerAccount{}
Хуков нет.
Возвращает
string. Avatar and icon markup.
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_visual( $attributes );
- $attributes(массив) (обязательный)
- Block attributes.
Код CustomerAccount::render_visual() CustomerAccount::render visual WC 11.2.1
private function render_visual( $attributes ) {
if ( self::TEXT_ONLY === $attributes['displayStyle'] ) {
return '';
}
$icon = $this->render_icon( $attributes );
$user_id = get_current_user_id();
if ( $user_id ) {
// We use `blank` as the default so if the user has no avatar, the icon underneath is visible.
$avatar = get_avatar(
$user_id,
48,
'blank',
'',
array(
'class' => 'wc-block-customer-account__avatar',
)
);
if ( $avatar ) {
return '<div class="wc-block-customer-account__visual">' . $icon . wp_kses_post( $avatar ) . '</div>';
}
}
return '<div class="wc-block-customer-account__visual">' . $icon . '</div>';
}