topbar_items_option() ); switch ( $item['item'] ) { case 'menu': $this->topbar_menu(); break; case 'primary-menu': get_template_part( 'template-parts/headers/menu-primary' ); break; case 'currency': \Razzi\Helper::currency_switcher(); break; case 'language': \Razzi\Helper::language_switcher(); break; case 'social': \Razzi\Helper::socials_menu(); break; case 'text': $html_svg = ''; if ( $svg = Helper::get_option( 'topbar_svg_code' ) ) { $html_svg = ''; } echo '
'; break; case 'close': echo \Razzi\Icon::get_svg( 'close', 'razzi-topbar__close' ); break; default: do_action( 'razzi_header_topbar_item', $item['item'] ); break; } } } /** * Display topbar items * * @since 1.0.0 * * @return void */ public function topbar_mobile_items( $items ) { if ( empty( $items ) ) { return; } foreach ( $items as $item ) { $item['item'] = $item['item'] ? $item['item'] : key( $this->topbar_items_option() ); switch ( $item['item'] ) { case 'menu': $this->topbar_menu(); break; case 'currency': \Razzi\Helper::currency_switcher(); break; case 'language': \Razzi\Helper::language_switcher(); break; case 'social': \Razzi\Helper::socials_menu(); break; case 'text': $html_svg = ''; if ( $svg = Helper::get_option( 'mobile_topbar_svg_code' ) ) { $html_svg = ''; } echo ''; break; case 'close': echo \Razzi\Icon::get_svg( 'close', 'razzi-topbar__close' ); break; default: do_action( 'razzi_header_topbar_mobile_item', $item['item'] ); break; } } } /** * Get topbar menu * * @since 1.0.0 * * @return string */ public function topbar_menu() { $menu_slug = Helper::get_option( 'topbar_menu_item' ); if( empty($menu_slug) ) { return; } $menu = array( 'theme_location' => '__no_such_location', 'menu' => $menu_slug, 'container' => 'nav', 'container_id' => 'topbar-menu', 'container_class' => 'main-navigation topbar-menu-container', 'menu_class' => 'nav-menu topbar-menu menu', ); $container_class = Helper::get_option( 'topbar_menu_show_arrow' ) ? ' has-arrow main-navigation topbar-menu-container' : 'main-navigation topbar-menu-container'; if ( class_exists( '\Razzi\Addons\Modules\Mega_Menu\Walker' ) ) { wp_nav_menu( apply_filters( 'razzi_topbar_menu_content', array( 'theme_location' => '__no_such_location', 'menu' => $menu_slug, 'container' => 'nav', 'container_id' => 'topbar-menu', 'container_class' => $container_class, 'menu_class' => 'nav-menu topbar-menu menu', 'walker' => new \Razzi\Addons\Modules\Mega_Menu\Walker() ) ) ); } else { wp_nav_menu( apply_filters( 'razzi_topbar_menu_content', array( 'theme_location' => '__no_such_location', 'menu' => $menu_slug, 'container' => 'nav', 'container_id' => 'topbar-menu', 'container_class' => $container_class, 'menu_class' => 'nav-menu topbar-menu menu', ) ) ); } } /** * Options of topbar items * * @since 1.0.0 * * @return array */ public function topbar_items_option() { return apply_filters( 'razzi_topbar_items_option', array( 'menu' => esc_html__('Primary Menu', 'razzi'), 'secondary-menu' => esc_html__('Secondary Menu', 'razzi'), 'currency' => esc_html__('Currency Switcher', 'razzi'), 'language' => esc_html__('Language Switcher', 'razzi'), 'social' => esc_html__('Socials', 'razzi'), 'text' => esc_html__('Custom Text 1', 'razzi'), 'close' => esc_html__('Close Icon', 'razzi'), ) ); } }