Add Astra child theme for Hop On Hop Off header & footer
- disables Astra header/footer via astra_header/astra_footer hooks and renders custom design markup (logo, nav dropdown, footer columns, socials, support) - chrome.css scoped to .hoho (generated from the design source); chrome.js for burger/submenu/sticky/back-to-top; bundled icon sprite (reuses plugin's) - parameterize scope-css.js scope via VC_SCOPE env Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J4hNL1PSHxXbu94SCenpKj
This commit is contained in:
58
astra-child-hoponhopoff/inc/nav-walker.php
Normal file
58
astra-child-hoponhopoff/inc/nav-walker.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Nav walker that renders a WordPress menu with the design's markup:
|
||||
* top-level items with children become a <button class="nav__toggle"> + a
|
||||
* <ul class="nav__submenu">; everything else is a plain link.
|
||||
*/
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Hoho_Nav_Walker extends Walker_Nav_Menu {
|
||||
|
||||
private $submenu_id = '';
|
||||
|
||||
public function start_lvl( &$output, $depth = 0, $args = null ) {
|
||||
$output .= '<ul class="nav__submenu" id="' . esc_attr( $this->submenu_id ) . '">';
|
||||
}
|
||||
|
||||
public function end_lvl( &$output, $depth = 0, $args = null ) {
|
||||
$output .= '</ul>';
|
||||
}
|
||||
|
||||
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
|
||||
$title = apply_filters( 'the_title', $item->title, $item->ID );
|
||||
$url = ! empty( $item->url ) ? $item->url : '#';
|
||||
|
||||
if ( 0 === $depth ) {
|
||||
$has_children = ! empty( $args->has_children );
|
||||
if ( $has_children ) {
|
||||
$this->submenu_id = 'hoho-sub-' . (int) $item->ID;
|
||||
$output .= '<li class="nav__item--has-menu">';
|
||||
$output .= '<button class="nav__link nav__toggle" type="button" aria-expanded="false" aria-controls="' . esc_attr( $this->submenu_id ) . '">';
|
||||
$output .= '<span>' . esc_html( $title ) . '</span>';
|
||||
$output .= '<svg class="icon icon--chevron" aria-hidden="true"><use href="#i-chevron"></use></svg>';
|
||||
$output .= '</button>';
|
||||
} else {
|
||||
$output .= '<li><a class="nav__link" href="' . esc_url( $url ) . '">' . esc_html( $title ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
$output .= '<li><a href="' . esc_url( $url ) . '">' . esc_html( $title ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
public function end_el( &$output, $item, $depth = 0, $args = null ) {
|
||||
$output .= '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback nav when no menu is assigned to the "HoHo — Header Menu" location,
|
||||
* so the header is never empty. Links Home + the tours archive.
|
||||
*/
|
||||
function hoho_nav_fallback() {
|
||||
$archive = get_post_type_archive_link( 'viator_tour' );
|
||||
$archive = $archive ? $archive : home_url( '/' );
|
||||
echo '<ul class="nav__list">';
|
||||
echo '<li><a class="nav__link" href="' . esc_url( home_url( '/' ) ) . '">' . esc_html__( 'Home', 'hoponhopoff' ) . '</a></li>';
|
||||
echo '<li><a class="nav__link" href="' . esc_url( $archive ) . '">' . esc_html__( 'Tours', 'hoponhopoff' ) . '</a></li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
Reference in New Issue
Block a user