web-wordpress-kit/kit/functions.php
2020-04-08 15:53:03 +02:00

101 lines
3.4 KiB
PHP

<?php
function kit_setup() {
add_theme_support('menus');
add_theme_support( 'post-thumbnails' );
register_nav_menus( array(
'primary' => 'Main Menu',
'secondary' => 'Footer Menu',
) );
};
add_action( 'after_setup_theme', 'kit_setup' );
// <ul id="menu-hauptmenue" class="">
// <li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-45 dropdown"><a title="Über uns" href="#" data-toggle="dropdown" class="dropdown-toggle">Über uns <i class="fa fa-angle-down"></i></a>
// <ul role="menu" class=" dropdown-menu">
// <li id="menu-item-46" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-46"><a title="MitarbeiterInnen" href="http://localhost:8080/mitarbeiterinnen/">MitarbeiterInnen</a></li>
// </ul>
// </li>
// </ul>
// <ul id="menu-hauptmenue" class="">
// <li class=' menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children'>
// <a href="http://localhost:8080/ueber-uns/">Über uns</a>
// <ul class="sub-menu">
// <li class=' menu-item menu-item-type-post_type menu-item-object-page'><a href="http://localhost:8080/mitarbeiterinnen/">MitarbeiterInnen</a></li>
// </ul>
// </li>
// </ul>
class kit_custom_main_menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
// depth dependent classes
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
$display_depth = ( $depth + 1); // because it counts the first submenu as 0
$classes = array(
'sub-menu',
'menu-depth-' . $display_depth
);
$class_names = implode( ' ', $classes );
// build html
if ($display_depth == 1) {
$output .= "\n" . $indent . '<section class="nav-second-level mega-flyout" style=""><div class="content-wrap"><ul class="' . $class_names . '">' . "\n";
} else {
$output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n";
}
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
$display_depth = ( $depth + 1); // because it counts the first submenu as 0
$classes = array(
'sub-menu',
'menu-depth-' . $display_depth
);
$class_names = implode( ' ', $classes );
// build html
if ($display_depth == 1) {
$output .= "\n" . $indent . '</ul></div></section>' . "\n";
} else {
$output .= "\n" . $indent . '</ul>' . "\n";
}
}
function start_el(&$output, $item, $depth = 0, $args=array(), $id = 0) {
$object = $item->object;
$type = $item->type;
$title = $item->title;
$description = $item->description;
$permalink = $item->url;
$output .= "<li class='" . implode(" ", $item->classes) . "'>";
//Add SPAN if no Permalink
if( $permalink && $permalink != '#' ) {
$output .= '<a href="' . $permalink . '">';
} else {
$output .= '<span>';
}
$output .= $title;
if( $description != '' && $depth == 0 ) {
$output .= '<small class="description">' . $description . '</small>';
}
if( $permalink && $permalink != '#' ) {
$output .= '</a>';
} else {
$output .= '</span>';
}
}
}