Foundation Walker
class FoundationMenu extends Walker_Nav_Menu
{
function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output )
{
$element->has_children = !empty( $children_elements[$element->ID] );
$element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : '';
$element->classes[] = ( $element->has_children ) ? 'has-dropdown' : '';
parent:: display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
function start_el( &$output, $object, $depth = 0, $args = array ( ) , $current_object_id = 0 )
{
$item_html = '';
parent:: start_el( $item_html, $object, $depth, $args );
$output.= ( $depth == 0 ) ? '<li class = "divider"></li>' : '';
$classes = empty( $object->classes ) ? array ( ) : ( array ) $object->classes;
if( in_array( 'label', $classes ) ){
$output.= '<li class = "divider"></li>';
$item_html = preg_replace( '/<a[^>]*>( .* )<\/a>/iU', '<label>$1</label>', $item_html );
}
if ( in_array( 'divider', $classes ) ){
$item_html = preg_replace( '/<a[^>]*>( .* )<\/a>/iU', '', $item_html );
}
$output.= $item_html;
}
function start_lvl( &$output, $depth = 0, $args = array ( ) )
{
$output.= "<ul class=\"menu vertical dropdown\" data-dropdown-menu>";
}
}
Save this file as foundation-menu.php
functions.php
function foundation_menu_left()
{
wp_nav_menu(array(
'container' => false,
'container_class' => '',
'menu' => 'header-left',
'theme_location' => 'header-left',
'menu_class' => 'dropdown menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'depth' => 0,
'fallback_cb' => false,
'$items_wrap' => '<ul class="menu vertical dropdown" >',
'items_wrap' => '<ul id="%1$s" class="%2$s" data-dropdown-menu data-options="closingTime:50;alignment:right;">%3$s</ul>',
'walker' => new FoundationMenu()
)
);
}
function foundation_menu_right()
{
wp_nav_menu(array(
'container' => false,
'container_class' => '',
'menu' => 'header-right',
'theme_location' => 'header-right',
'menu_class' => 'dropdown menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'depth' => 0,
'fallback_cb' => false,
'$items_wrap' => '<ul class="menu vertical dropdown" >',
'items_wrap' => '<ul id="%1$s" class="%2$s" data-dropdown-menu data-options="closingTime:50;alignment:right;">%3$s</ul>',
'walker' => new FoundationMenu()
)
);
}
require_once get_template_directory().'/foundation-menu.php';
header.php
<div class="top-bar">
<div class="top-bar-title">
<span data-responsive-toggle="responsive-menu" data-hide-for="medium">
<span class="menu-icon" data-toggle></span>
</span>
<a href="<?= $url;?>"><strong>TITLE</strong></a>
</div>
<div id="responsive-menu">
<div class="top-bar-left">
<?php foundation_menu_left();?>
</div>
<div class="top-bar-right">
<?php foundation_menu_right();?>
</div>
</div>
</div>
Comments
Very informative article,
thanks for sharing the amazing post
طراحی سایت
طراحی وب سایت
سئو
طراحی سایت شرکتی
طراحی سایت ارزان
طراحی سایت فروشگاهی
طراحی سایت
طراحی وب سایت
سئو
طراحی سایت
فاو