Automattic\WooCommerce\Blocks\BlockTypes
CustomerAccount::render_visual
Render the user avatar and icon.
Method of the class: CustomerAccount{}
No Hooks.
Returns
string. Avatar and icon markup.
Usage
// private - for code of main (parent) class only $result = $this->render_visual( $attributes );
- $attributes(array) (required)
- Block attributes.
CustomerAccount::render_visual() CustomerAccount::render visual code 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>';
}