Login Button
parent
c169c0ee50
commit
8c50bbff43
|
@ -1,17 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace WoWPress\Frontend;
|
||||
|
||||
use WoWPress\Frontend\Icon;
|
||||
|
||||
class NavWalker extends \Walker_Nav_Menu
|
||||
{
|
||||
|
||||
function start_lvl(&$output, $depth=0, $args=null) {
|
||||
function start_lvl(&$output, $depth = 0, $args = null)
|
||||
{
|
||||
$output .= '
|
||||
<div x-cloak x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="block xl:absolute right-0 w-full mt-2 origin-top-right rounded-md shadow-lg xl:w-48">
|
||||
<div x-cloak class="px-2 py-2 shadow w-full flex flex-col gap-2" style="background-color:var(--color-deepblue)">
|
||||
';
|
||||
}
|
||||
function end_lvl(&$output, $depth= 0, $args=null) {
|
||||
function end_lvl(&$output, $depth = 0, $args = null)
|
||||
{
|
||||
|
||||
|
||||
$output .= '</div></div>';
|
||||
|
@ -32,12 +36,27 @@ class NavWalker extends \Walker_Nav_Menu
|
|||
if ($args->walker->has_children) {
|
||||
$output .= '<div x-cloak @click.away="open = false" class="relative" x-data="{ open: false }">';
|
||||
$output .= '<button @click="open = !open" class="w-full nav-btn ' . implode(" ", $item->classes) . '">';
|
||||
}
|
||||
elseif ($item->url && $item->url != '#') {
|
||||
} elseif ($item->url && $item->url != '#' && $item->url != "#LOGIN") {
|
||||
if (0 === $depth) {
|
||||
$output .= '<div>';
|
||||
}
|
||||
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="' . $item->url . '">';
|
||||
} elseif ($item->url && $item->url == "#LOGIN") {
|
||||
if (!is_user_logged_in()) {
|
||||
if (0 === $depth) {
|
||||
$output .= '<div>';
|
||||
}
|
||||
$item->classes[] = "btn-red btn-outline";
|
||||
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="/wp-login.php">';
|
||||
} else {
|
||||
if (0 === $depth) {
|
||||
$output .= '<div>';
|
||||
}
|
||||
$item->classes[] = "btn-alliance btn-outline";
|
||||
|
||||
|
||||
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="/wp-admin/profile.php">';
|
||||
}
|
||||
} else {
|
||||
if (0 === $depth) {
|
||||
$output .= '<div>';
|
||||
|
@ -52,7 +71,15 @@ class NavWalker extends \Walker_Nav_Menu
|
|||
}
|
||||
}
|
||||
|
||||
if ($item->url && $item->url == "#LOGIN") {
|
||||
if (is_user_logged_in()) {
|
||||
$output .= "Profil";
|
||||
} else {
|
||||
$output .= "Login";
|
||||
}
|
||||
} else {
|
||||
$output .= $item->title;
|
||||
}
|
||||
|
||||
if ($args->walker->has_children) {
|
||||
$output .= "
|
||||
|
@ -62,19 +89,10 @@ class NavWalker extends \Walker_Nav_Menu
|
|||
|
||||
if ($args->walker->has_children) {
|
||||
$output .= "</button>";
|
||||
|
||||
|
||||
}
|
||||
elseif ($item->url && $item->url != '#') {
|
||||
} elseif ($item->url && $item->url != '#') {
|
||||
$output .= '</a>';
|
||||
} else {
|
||||
$output .= '</span>';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue