Initial commit to github
This commit is contained in:
68
views/components/menu-items/has-children.php
Normal file
68
views/components/menu-items/has-children.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation - Menu Item with children
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation/
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Variables available:
|
||||
// $item from parent template
|
||||
// $nestedNavItems, $hasChildren, $currentPage from MenuItems component
|
||||
|
||||
// Generate item classes
|
||||
$itemClasses = array(
|
||||
'menu-vdi__item',
|
||||
'menu-vdi__item--parent',
|
||||
'menu-vdi__item--' . str_replace( ' ', ' -', strtolower( $item->title ) ),
|
||||
);
|
||||
if ( ! empty( $item->classes ) ) {
|
||||
$itemClasses = array_merge( $itemClasses, $item->classes );
|
||||
}
|
||||
|
||||
// Generate toggle classes
|
||||
$toggleClasses = array( 'menu-vdi__toggle' );
|
||||
if ( ! empty( $item->classes ) ) {
|
||||
$toggleClasses = array_merge( $toggleClasses, $item->classes );
|
||||
}
|
||||
?>
|
||||
|
||||
<li id="menuVdiItem<?php echo esc_attr( $item->ID ); ?>" class="<?php echo esc_attr( implode( ' ', $itemClasses ) ); ?>">
|
||||
<button aria-expanded="false" class="<?php echo esc_attr( implode( ' ', $toggleClasses ) ); ?>">
|
||||
<?php echo esc_html( $item->title ); ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<ul class="menu-vdi__submenu">
|
||||
<?php foreach ( $nestedNavItems( $item ) as $child ) : ?>
|
||||
<?php if ( $hasChildren( $child ) ) : ?>
|
||||
<li id="menuVdiItem<?php echo esc_attr( $child->ID ); ?>">
|
||||
<span class="menu-vdi__item menu-vdi__item--child <?php echo ! empty( $item->classes ) ? esc_attr( implode( ' ', $item->classes ) ) : ''; ?>">
|
||||
<?php echo esc_html( $child->title ); ?>
|
||||
</span>
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $nestedNavItems( $child ) as $grandChild ) : ?>
|
||||
<li id="menuVdiItem<?php echo esc_attr( $grandChild->ID ); ?>" class="menu-vdi__item menu-vdi__item--grandchild <?php echo ! empty( $item->classes ) ? esc_attr( implode( ' ', $item->classes ) ) : ''; ?>">
|
||||
<a href="<?php echo esc_url( $grandChild->url ); ?>" aria-current="<?php echo esc_attr( $currentPage( $grandChild ) ); ?>"
|
||||
<?php echo isset( $grandChild->target ) ? esc_attr( "target='$grandChild->target'" ) : ''; ?> class="sub-menu-item">
|
||||
<?php echo esc_html( $grandChild->title ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php else : ?>
|
||||
<li id="menuVdiItem<?php echo esc_attr( $child->ID ); ?>" class="menu-vdi__item menu-vdi__item--child <?php echo ! empty( $item->classes ) ? esc_attr( implode( ' ', $item->classes ) ) : ''; ?>">
|
||||
<a href="<?php echo esc_url( $child->url ); ?>" class="sub-menu-item">
|
||||
<?php echo esc_html( $child->title ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
33
views/components/menu-items/index.php
Normal file
33
views/components/menu-items/index.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation - Menu Items outer list
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation/
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Variables available from MenuItems component:
|
||||
// $topLevelNavItems, $hasChildren, $nestedNavItems, $currentPage, $location
|
||||
|
||||
if ( $location === 'main_navigation' ) {
|
||||
$menuID = 'menu-container';
|
||||
} else {
|
||||
$menuID = 'menu-container-aux';
|
||||
}
|
||||
?>
|
||||
|
||||
<ul id="<?php echo esc_attr( $menuID ); ?>" class="menu-vdi">
|
||||
<li class="menu-item menu-item--search px-4 lg:hidden">
|
||||
<?php get_template_part( 'views/forms/search' ); ?>
|
||||
</li>
|
||||
|
||||
<?php foreach ( $topLevelNavItems as $item ) : ?>
|
||||
<?php if ( $hasChildren( $item ) ) : ?>
|
||||
<?php include __DIR__ . '/has-children.php'; ?>
|
||||
<?php else : ?>
|
||||
<?php include __DIR__ . '/single.php'; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
32
views/components/menu-items/single.php
Normal file
32
views/components/menu-items/single.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation - Menu Item without children
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation/
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Variables available:
|
||||
// $item from parent template
|
||||
// $currentPage from MenuItems component
|
||||
|
||||
// Generate classes
|
||||
$itemClasses = array(
|
||||
'menu-vdi__item',
|
||||
'menu-vdi__item--single',
|
||||
'menu-vdi__item--' . str_replace( ' ', '-', strtolower( $item->title ) ),
|
||||
);
|
||||
|
||||
if ( ! empty( $item->classes ) ) {
|
||||
$itemClasses = array_merge( $itemClasses, $item->classes );
|
||||
}
|
||||
?>
|
||||
|
||||
<li id="menuVdiItem<?php echo esc_attr( $item->ID ); ?>" class="<?php echo esc_attr( implode( ' ', $itemClasses ) ); ?>">
|
||||
<a href="<?php echo esc_url( $item->url ); ?>" aria-current="<?php echo esc_attr( $currentPage( $item ) ); ?>"
|
||||
<?php echo isset( $item->target ) ? esc_attr( "target='$item->target'" ) : ''; ?> class="menu-vdi__link">
|
||||
<?php echo esc_html( $item->title ); ?>
|
||||
</a>
|
||||
</li>
|
||||
39
views/components/nav-aux.php
Normal file
39
views/components/nav-aux.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation - Auxiliary
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation-aux.html
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Init Variables
|
||||
global $wp, $views;
|
||||
|
||||
$menus = get_nav_menu_locations();
|
||||
|
||||
if ( isset( $menus['aux_navigation'] ) ) {
|
||||
$navItems = wp_get_nav_menu_items( $menus['aux_navigation'] );
|
||||
}
|
||||
|
||||
$currentPageURL = home_url( $wp->request ) . '/';
|
||||
?>
|
||||
|
||||
<div class="nav-aux__container hidden lg:block bg-dark w-full h-12 py-2">
|
||||
<div class="container flex items-center justify-end gap-x-4 gap-y-0 flex-wrap">
|
||||
<nav class="nav-aux" role="navigation" aria-label="Auxiliary">
|
||||
<?php
|
||||
if ( has_nav_menu( 'aux_navigation' ) ) {
|
||||
// Initialize and render menu items
|
||||
$menuItems = new MenuItems( 'aux_navigation' );
|
||||
$menuItems->render();
|
||||
}
|
||||
?>
|
||||
</nav>
|
||||
|
||||
<?php get_template_part( 'views/partials/social-media' ); ?>
|
||||
|
||||
<?php get_template_part( 'views/forms/search' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
24
views/components/nav-main.php
Normal file
24
views/components/nav-main.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation Component
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation/
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
global $views;
|
||||
?>
|
||||
|
||||
<nav class="nav-main" role="navigation" aria-label="Main">
|
||||
<?php require_once __DIR__ . '/nav-main__toggle.php'; ?>
|
||||
|
||||
<?php
|
||||
if ( has_nav_menu( 'main_navigation' ) ) {
|
||||
// Initialize and render menu items
|
||||
$menuItems = new MenuItems( 'main_navigation' );
|
||||
$menuItems->render();
|
||||
}
|
||||
?>
|
||||
</nav>
|
||||
46
views/components/nav-main__toggle.php
Normal file
46
views/components/nav-main__toggle.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Navigation - Toggle Button
|
||||
*
|
||||
* Please review documentation upon first use, and, as-needed:
|
||||
* https://docs.vincentdevelopment.ca/docs/starter-v3-enhancements/navigation/
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Init Variables
|
||||
$navIcon = isset( get_field( 'header', 'option' )['nav_icon'] ) ? get_field( 'header', 'option' )['nav_icon'] : '';
|
||||
|
||||
// Generate toggle classes
|
||||
$toggleClasses = array( 'nav-main__toggle' );
|
||||
if ( $navIcon ) {
|
||||
$toggleClasses[] = 'custom-icon';
|
||||
}
|
||||
?>
|
||||
|
||||
<button
|
||||
id="navMainToggle"
|
||||
aria-label="Menu"
|
||||
aria-expanded="false"
|
||||
class="<?php echo esc_attr( implode( ' ', $toggleClasses ) ); ?>"
|
||||
>
|
||||
<?php if ( $navIcon ) : ?>
|
||||
<?php echo wp_get_attachment_image( $navIcon, 'full' ); ?>
|
||||
<?php else : ?>
|
||||
<!-- Hamburger Icon -->
|
||||
<span class="nav-toggle-icon nav-toggle-hamburger">
|
||||
<svg class="text-black fill-black" viewBox="0 0 100 80" width="40" height="40">
|
||||
<rect y="0" width="100" height="15"></rect>
|
||||
<rect y="30" width="100" height="15"></rect>
|
||||
<rect y="60" width="100" height="15"></rect>
|
||||
</svg>
|
||||
</span>
|
||||
<!-- X Icon -->
|
||||
<span class="nav-toggle-icon nav-toggle-x">
|
||||
<svg class="text-black fill-black" viewBox="0 0 100 80" width="40" height="40">
|
||||
<line x1="20" y1="20" x2="80" y2="60" stroke="black" stroke-width="15" stroke-linecap="round" />
|
||||
<line x1="80" y1="20" x2="20" y2="60" stroke="black" stroke-width="15" stroke-linecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
Reference in New Issue
Block a user