\n";
}// Method
/**
@since 1.0.1
Extend WordPress end first menu level.
@param (string) $output
Used to append additional content (passed by reference).
@param (int) $depth
Depth of menu item. Used for padding.
@param (stdClass) $args
An object of wp_nav_menu() arguments.
@return (void)
*/
public function end_lvl(&$output,$depth = 0,$args = array())
{
$indent = str_repeat("\t",$depth);
$output .= "\n$indent
';
$atts = array();
$atts['title'] = !empty($item->title) ? $item->title : '';
$atts['target'] = !empty($item->target) ? $item->target : '';
$atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
// $atts['class'] = 'uk-link uk-text-primary uk-active';
// If item has_children add atts to a.
if($args->has_children && $depth === 0) :
$atts['href'] = '#';
// $atts['data-toggle'] = 'dropdown';
// $atts['class'] = 'dropdown-toggle';
// $atts['aria-haspopup'] = 'true';
else :
$atts['href'] = !empty($item->url) ? $item->url : '';
endif;
$atts = apply_filters('nav_menu_link_attributes',$atts,$item,$args);
$attributes = '';
foreach($atts as $attr => $value) :
if(!empty($value)) :
$value = ('href' === $attr) ? esc_url($value) : esc_attr($value);
$attributes .= ' ' . $attr . '="' . $value . '"';
endif;
endforeach;
$item_output = $args->before;
$item_output .= '';
$item_output .= $args->link_before . apply_filters('the_title',$item->title,$item->ID) . $args->link_after;
$item_output .= ($args->has_children && 0 === $depth) ? ' ' : '';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el',$item_output,$item,$depth,$args);
}// Method
/**
@since 1.0.1
Traverse elements to create list from elements.
Display one element if the element doesn't have any children otherwise, display the element and its children.
Will only traverse up to the max depth and no ignore elements under that depth.
This method shouldn't be called directly, use the walk() method instead.
*/
public function display_element($element,&$children_elements,$max_depth,$depth,$args,&$output)
{
if(!$element){return;}
$id_field = $this->db_fields['id'];
// Display this element.
if(is_object($args[0])) :
$args[0]->has_children = !empty($children_elements[$element->$id_field]);
endif;
parent::display_element($element,$children_elements,$max_depth,$depth,$args,$output);
}// Method
/**
@since 1.0.1
Menu Fallback
If this function is assigned to the wp_nav_menu's fallback_cb variable and a menu has not been assigned to the theme location in the WordPress menu manager the function with display nothing to a non-logged in user, and will add a link to the WordPress menu manager if logged in as an admin.
*/
public static function fallback($args)
{
if(current_user_can('manage_options')) :
extract($args);
$fb_output = NULL;
if($container) :
$fb_output = '<' . $container;
if($container_id) :
$fb_output .= ' id="' . $container_id . '"';
endif;
if($container_class) :
$fb_output .= ' class="' . $container_class . '"';
endif;
$fb_output .= '>';
endif;
$fb_output .= '
Add a menu
';
$fb_output .= '
';
if($container) :
$fb_output .= '' . $container . '>';
endif;
echo $fb_output;
endif;
}// Method
}// Class
endif;
/* Exec
______________________________
*/
if(class_exists('_uikit_starter_offcanvas_menu') === FALSE) :
class _uikit_starter_offcanvas_menu extends Walker_Nav_Menu{
/**
@since 1.0
A custom WordPress nav walker class to implement UIkit menu markup
*/
/**
@since 1.0.1
Extend WordPress start first menu level.
@param (string) $output
Used to append additional content (passed by reference).
@param (int) $depth
Depth of menu item. Used for padding.
@param (stdClass) $args
An object of wp_nav_menu() arguments.
@return (void)
*/
public function start_lvl(&$output,$depth = 0,$args = array())
{
$indent = str_repeat("\t",$depth);
$output .= "\n$indent
\n";
}// Method
/**
@since 1.0.1
Extend WordPress start menu elements.
@param (string) $output
Used to append additional content (passed by reference).
@param (WP_Post) $item
Menu item data object.
@param (int) $depth
Depth of menu item. Used for padding.
@param (stdClass) $args
An object of wp_nav_menu() arguments.
@param (int) $id
Current item ID.
@return (void)
*/
public function start_el(&$output,$item,$depth = 0,$args = array(),$id = 0)
{
$indent = ($depth) ? str_repeat("\t",$depth) : '';
$class_names = $value = '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$class_names = join(' ',apply_filters('nav_menu_css_class',array_filter($classes),$item,$args));
if($args->has_children) :
$class_names .= ' uk-parent';
endif;
if(in_array('current-menu-item',$classes) || in_array('current-menu-parent',$classes)) :
$class_names .= ' uk-active';
endif;
$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
$id = apply_filters('nav_menu_item_id','menu-item-'. $item->ID,$item,$args);
$id = $id ? ' id="' . esc_attr($id) . '"' : '';
$output .= $indent . '