diff --git a/header.php b/header.php
index c0fff59..4e0db0f 100644
--- a/header.php
+++ b/header.php
@@ -68,6 +68,7 @@
'primary-menu',
+ 'fallback_cb' => '\Aldine\Helpers\default_menu',
'container' => 'nav',
'container_class' => 'js-header-nav',
'container_id' => 'navigation',
diff --git a/inc/filters/namespace.php b/inc/filters/namespace.php
index 32e90be..86bead7 100644
--- a/inc/filters/namespace.php
+++ b/inc/filters/namespace.php
@@ -106,51 +106,7 @@ function add_blocks( $init_array ) {
function adjust_menu( $items, $args ) {
if ( $args->theme_location === 'primary-menu' ) {
- if ( ! is_front_page() ) {
- $items = sprintf(
- '
%2$s',
- '/',
- __( 'Home', 'pressbooks-aldine' )
- ) . $items;
- }
- if ( get_option( 'pb_network_contact_form' ) ) {
- $items .= sprintf(
- '%2$s',
- '#contact',
- __( 'Contact', 'pressbooks-aldine' )
- );
- }
- if ( ! is_user_logged_in() ) {
- $items .= sprintf(
- '%2$s',
- wp_login_url( get_permalink() ),
- __( 'Sign In', 'pressbooks-aldine' )
- );
- if ( in_array( get_site_option( 'registration' ), [ 'user', 'all' ], true ) ) {
- $items .= sprintf(
- '%2$s',
- network_home_url( '/wp-signup.php' ),
- __( 'Sign Up', 'pressbooks-aldine' )
- );
- }
- } else {
- if ( is_super_admin() || is_user_member_of_blog() ) {
- $items .= sprintf(
- '%2$s',
- admin_url(),
- __( 'Admin', 'pressbooks-aldine' )
- );
- }
- $items .= sprintf(
- '%2$s',
- wp_logout_url( get_permalink() ),
- __( 'Sign Out', 'pressbooks-aldine' )
- );
- }
- /* @codingStandardsIgnoreStart $items .= sprintf(
- '',
- get_search_form( false )
- ); @codingStandardsIgnoreEnd */
+ return \Aldine\Helpers\get_default_menu( $items );
}
return $items;
diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php
index 706e037..c4ef836 100644
--- a/inc/helpers/namespace.php
+++ b/inc/helpers/namespace.php
@@ -64,6 +64,75 @@ function get_catalog_licenses() {
return [];
}
+/**
+ * Return the default (non-page) menu items.
+ *
+ * @param string $items
+ * @return string $items
+ */
+function get_default_menu( $items = '' ) {
+ if ( ! is_front_page() ) {
+ $items = sprintf(
+ '%2$s',
+ '/',
+ __( 'Home', 'pressbooks-aldine' )
+ ) . $items;
+ }
+ if ( get_option( 'pb_network_contact_form' ) ) {
+ $items .= sprintf(
+ '%2$s',
+ '#contact',
+ __( 'Contact', 'pressbooks-aldine' )
+ );
+ }
+ if ( ! is_user_logged_in() ) {
+ $items .= sprintf(
+ '%2$s',
+ wp_login_url( get_permalink() ),
+ __( 'Sign In', 'pressbooks-aldine' )
+ );
+ if ( in_array( get_site_option( 'registration' ), [ 'user', 'all' ], true ) ) {
+ $items .= sprintf(
+ '%2$s',
+ network_home_url( '/wp-signup.php' ),
+ __( 'Sign Up', 'pressbooks-aldine' )
+ );
+ }
+ } else {
+ if ( is_super_admin() || is_user_member_of_blog() ) {
+ $items .= sprintf(
+ '%2$s',
+ admin_url(),
+ __( 'Admin', 'pressbooks-aldine' )
+ );
+ }
+ $items .= sprintf(
+ '%2$s',
+ wp_logout_url( get_permalink() ),
+ __( 'Sign Out', 'pressbooks-aldine' )
+ );
+ }
+ /* @codingStandardsIgnoreStart $items .= sprintf(
+ '',
+ get_search_form( false )
+ ); @codingStandardsIgnoreEnd */
+
+ return $items;
+}
+
+/**
+ * Echo the default menu.
+ *
+ * @param string $items
+ * @return null
+ */
+function default_menu( $args = [], $items = '' ) {
+ printf(
+ "<{$args['container']} id='{$args['container_id']}' class='{$args['container_class']}'>{$args['container']}>",
+ get_default_menu( $items )
+ );
+}
+
/**
*
* Handler for contact form submissions.