|
<?php |
|
// |
|
// Blank navigation list Walker |
|
// |
|
// ----------------------------------------------------- |
|
class Blank_Walker extends Walker_Nav_Menu |
|
{ |
|
/** |
|
* Start the element output. |
|
* |
|
* @param string $output Passed by reference. Used to append additional content. |
|
* @param object $item Menu item data object. |
|
* @param int $depth Depth of menu item. May be used for padding. |
|
* @param array $args Additional strings. |
|
* @return void |
|
*/ |
|
function filterNonWP($item) { |
|
return strncmp($item, 'menu-', 5); |
|
} |
|
function start_el(&$output, $item, $depth, $args) |
|
{ |
|
$classes = empty( $item->classes ) ? array() : (array) $item->classes; |
|
$filteredClasses = array_filter($classes, array($this, 'filterNonWP')); |
|
if (in_array('current_page_item', $classes)) { |
|
if (!empty($filteredClasses[0])) { |
|
$output .= '<li class="active '.implode($filteredClasses, ' ').'">'; |
|
} else { |
|
$output .= '<li class="active">'; |
|
} |
|
} else { |
|
if (!empty($filteredClasses[0])) { |
|
$output .= '<li class="'.implode($filteredClasses, ' ').'"">'; |
|
} else { |
|
$output .= '<li>'; |
|
} |
|
|
|
} |
|
if (empty($attributes)) $attributes = ''; |
|
if (empty($description)) $description = ''; |
|
|
|
! empty( $item->attr_title ) |
|
and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"'; |
|
! empty( $item->target ) |
|
and $attributes .= ' target="' . esc_attr( $item->target ) .'"'; |
|
! empty( $item->xfn ) |
|
and $attributes .= ' rel="' . esc_attr( $item->xfn ) .'"'; |
|
(! empty( $item->url ) && $item->url != '#') |
|
and $attributes .= ' href="' . esc_attr( $item->url ) .'"'; |
|
|
|
$title = apply_filters( 'the_title', $item->title, $item->ID ); |
|
$wrapstart = (esc_attr( $item->url ) == '#') ? '<span'.$attributes.'>' : '<a'.$attributes.'>'; |
|
$wrapend = (esc_attr( $item->url ) == '#') ? '</span>' : '</a>'; |
|
if (!empty($args->wrapinner)) { |
|
$wrapstart .= '<'.$args->wrapinner.'>'; |
|
$wrapend = '</'.$args->wrapinner.'>'.$wrapend; |
|
} |
|
$item_output = $args->before |
|
. $wrapstart |
|
. $args->link_before |
|
. $title |
|
. $wrapend."\n" |
|
. $args->link_after |
|
. $description |
|
. $args->after; |
|
|
|
$output .= apply_filters( |
|
'walker_nav_menu_start_el' |
|
, $item_output |
|
, $item |
|
, $depth |
|
, $args |
|
); |
|
} |
|
function end_el( &$output ) |
|
{ |
|
$output; |
|
} |
|
} |