You've already forked wp-bootstrap
feat: offcanvas mobile navigation with user avatar and admin bar fix (v1.0.11)
Switch mobile nav from collapse to offcanvas, add logged-in user avatar and My Account link to offcanvas header, move dark mode toggle to offcanvas footer. Fix admin bar overlapping offcanvas via inline CSS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ class ContextBuilder
|
||||
'layout' => 'default',
|
||||
'header_variant' => $this->getHeaderVariant(),
|
||||
'footer_variant' => $this->getFooterVariant(),
|
||||
'user' => $this->getUserData(),
|
||||
];
|
||||
|
||||
if (is_singular()) {
|
||||
@@ -93,6 +94,28 @@ class ContextBuilder
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user data for header/navigation.
|
||||
*/
|
||||
private function getUserData(): array
|
||||
{
|
||||
if (! is_user_logged_in()) {
|
||||
return ['logged_in' => false];
|
||||
}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$account_url = function_exists('wc_get_page_permalink')
|
||||
? wc_get_page_permalink('myaccount')
|
||||
: admin_url('profile.php');
|
||||
|
||||
return [
|
||||
'logged_in' => true,
|
||||
'display_name' => $user->display_name,
|
||||
'avatar' => get_avatar($user->ID, 32, '', '', ['class' => 'rounded-circle']),
|
||||
'account_url' => $account_url,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get navigation menu items for a location.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user