fictioneer/partials/_navigation.php

115 lines
3.7 KiB
PHP
Raw Normal View History

2023-01-21 01:31:34 +01:00
<?php
/**
* Partial: Navigation
*
* Renders the main navigation bar.
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.0.0
2024-04-12 19:44:12 +02:00
* @since 5.12.5 - Added wrapper actions and support for wide header.
* @since 5.20.0 - Added Elementor support.
2023-01-21 01:31:34 +01:00
*
* @internal $args['post_id'] Optional. Current post ID.
* @internal $args['story_id'] Optional. Current story ID (if chapter).
* @internal $args['header_image_url'] URL of the filtered header image or false.
* @internal $args['header_args'] Arguments passed to the header.php partial.
2024-04-12 19:44:12 +02:00
* @internal $args['tag'] Optional. Wrapping tag.
2023-01-21 01:31:34 +01:00
*/
// No direct access!
defined( 'ABSPATH' ) OR exit;
// Setup
2024-04-12 19:44:12 +02:00
$header_style = get_theme_mod( 'header_style', 'default' );
$mobile_nav_style = get_theme_mod( 'mobile_nav_style', 'overflow' );
$tag = $args['tag'] ?? 'div';
$classes = [];
2024-04-13 01:28:03 +02:00
if ( $mobile_nav_style === 'collapse' || $header_style === 'wide' ) {
$classes[] = '_collapse-on-mobile';
}
2024-04-12 19:44:12 +02:00
if ( $header_style === 'wide' ) {
$classes[] = '_wide';
}
?>
2024-04-12 19:44:12 +02:00
<<?php echo $tag; ?> id="full-navigation" class="main-navigation <?php echo implode( ' ', $classes ); ?>">
2023-07-30 17:00:40 +02:00
<div id="nav-observer-sticky" class="observer nav-observer"></div>
2024-04-12 19:44:12 +02:00
2023-01-21 01:31:34 +01:00
<div class="main-navigation__background"></div>
2023-07-29 14:49:22 +02:00
<?php do_action( 'fictioneer_navigation_top', $args ); ?>
2023-01-21 01:31:34 +01:00
<div class="main-navigation__wrapper">
2023-11-24 02:23:07 +01:00
<?php if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'nav_bar' ) ) : ?>
<?php do_action( 'fictioneer_navigation_wrapper_start', $args ); ?>
2024-12-06 17:38:32 +01:00
<button class="mobile-menu-button follows-alert-number" data-fictioneer-follows-target="newDisplay" data-action="click->fictioneer#toggleMobileMenu">
<?php
fictioneer_icon( 'fa-bars', 'off' );
fictioneer_icon( 'fa-xmark', 'on' );
?>
2024-08-07 14:28:58 +02:00
<span class="mobile-menu-button__label"><?php _ex( 'Menu' , 'Mobile menu label', 'fictioneer' ); ?></span>
2024-12-06 17:38:32 +01:00
</button>
<nav class="main-navigation__left" aria-label="<?php echo esc_attr__( 'Main Navigation', 'fictioneer' ); ?>">
<?php
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'nav_menu' ) ) {
if ( has_nav_menu( 'nav_menu' ) ) {
$menu = null;
$transient_enabled = fictioneer_enable_menu_transients( 'nav_menu' );
if ( $transient_enabled ) {
$menu = get_transient( 'fictioneer_main_nav_menu_html' );
}
if ( empty( $menu ) ) {
$menu = wp_nav_menu(
array(
'theme_location' => 'nav_menu',
'menu_class' => 'main-navigation__list',
'container' => '',
'menu_id' => 'menu-navigation',
'items_wrap' => '<ul id="%1$s" data-menu-id="main" class="%2$s">%3$s</ul>',
'echo' => false
)
);
if ( $menu !== false ) {
$menu = str_replace( ['current_page_item', 'current-menu-item', 'aria-current="page"'], '', $menu );
}
if ( $transient_enabled ) {
set_transient( 'fictioneer_main_nav_menu_html', $menu );
}
}
2024-08-07 12:05:30 +02:00
fictioneer_add_taxonomy_submenus( $menu );
2024-08-06 22:04:52 +02:00
echo $menu;
}
}
?>
</nav>
<div class="main-navigation__right">
<?php fictioneer_render_icon_menu( array( 'location' => 'in-navigation' ) );; ?>
</div>
2023-11-24 02:23:07 +01:00
<?php do_action( 'fictioneer_navigation_wrapper_end', $args ); ?>
2023-11-24 02:23:07 +01:00
<?php endif; ?>
2024-04-12 19:44:12 +02:00
2023-01-21 01:31:34 +01:00
</div>
2023-07-29 14:49:22 +02:00
<?php do_action( 'fictioneer_navigation_bottom', $args ); ?>
2023-11-24 02:23:07 +01:00
2024-04-12 19:44:12 +02:00
</<?php echo $tag; ?>>