2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Navigation
|
|
|
|
*
|
|
|
|
* Renders the main navigation bar.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 5.0.0
|
2024-04-12 19:44:12 +02:00
|
|
|
* @since 5.12.5 - Added wrapper actions and support for wide header.
|
2024-06-12 12:30:02 +02:00
|
|
|
* @since 5.20.0 - Added Elementor support.
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2023-08-03 20:39:31 +02: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
|
|
|
*/
|
|
|
|
|
2023-08-20 20:21:48 +02:00
|
|
|
|
|
|
|
// No direct access!
|
|
|
|
defined( 'ABSPATH' ) OR exit;
|
|
|
|
|
2023-11-24 23:34:57 +01:00
|
|
|
// 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';
|
2023-11-24 23:34:57 +01:00
|
|
|
$classes = [];
|
|
|
|
|
2024-04-13 01:28:03 +02:00
|
|
|
if ( $mobile_nav_style === 'collapse' || $header_style === 'wide' ) {
|
2023-11-24 23:34:57 +01:00
|
|
|
$classes[] = '_collapse-on-mobile';
|
|
|
|
}
|
|
|
|
|
2024-04-12 19:44:12 +02:00
|
|
|
if ( $header_style === 'wide' ) {
|
|
|
|
$classes[] = '_wide';
|
|
|
|
}
|
|
|
|
|
2023-08-20 20:21:48 +02:00
|
|
|
?>
|
|
|
|
|
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
|
|
|
|
2024-06-12 12:30:02 +02: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">
|
2024-06-12 12:30:02 +02:00
|
|
|
<?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>
|
2024-06-12 12:30:02 +02:00
|
|
|
|
|
|
|
<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;
|
2024-10-13 13:07:27 +02:00
|
|
|
$transient_enabled = fictioneer_enable_menu_transients( 'nav_menu' );
|
2024-06-12 12:30:02 +02:00
|
|
|
|
2024-10-13 13:07:27 +02:00
|
|
|
if ( $transient_enabled ) {
|
2024-06-12 12:30:02 +02:00
|
|
|
$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 );
|
|
|
|
}
|
|
|
|
|
2024-10-13 13:07:27 +02:00
|
|
|
if ( $transient_enabled ) {
|
2024-06-12 12:30:02 +02:00
|
|
|
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
|
|
|
|
2024-06-12 12:30:02 +02:00
|
|
|
echo $menu;
|
2023-08-23 22:02:12 +02:00
|
|
|
}
|
|
|
|
}
|
2024-06-12 12:30:02 +02:00
|
|
|
?>
|
|
|
|
</nav>
|
2023-08-04 13:48:00 +02:00
|
|
|
|
2024-06-12 12:30:02 +02:00
|
|
|
<div class="main-navigation__right">
|
2024-10-02 23:57:12 +02:00
|
|
|
<?php fictioneer_render_icon_menu( array( 'location' => 'in-navigation' ) );; ?>
|
2024-06-12 12:30:02 +02:00
|
|
|
</div>
|
2023-11-24 02:23:07 +01:00
|
|
|
|
2024-06-12 12:30:02 +02:00
|
|
|
<?php do_action( 'fictioneer_navigation_wrapper_end', $args ); ?>
|
2023-11-24 02:23:07 +01:00
|
|
|
|
2024-06-12 12:30:02 +02: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; ?>>
|