web-wordpress-kit/kit/functions.php

107 lines
3 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' );
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">
<div class="container container-3-cols">
<div class="column">
<div class="nav-second-level-group">
' . "\n";
} else {
$output .= "\n" . $indent . '<ul>' . "\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 . '
</div>
</div>
</div>
</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;
$theme_template_path = get_template_directory_uri();
if ($depth == 1) {
$output .= '
<a class="nav-second-level-group-headline" href="' . $permalink . '">
<img class="icon" src="' . $theme_template_path .'/img/nav-second-level-star-primary.svg" alt="" width="24" height="24">
<span>
';
$output .= $title;
$output .= '
</span>
</a>';
} else {
$output .= "<li class='" . implode(" ", $item->classes) . "'>";
$output .= '<a href="' . $permalink . '">';
$output .= $title;
$output .= '</a>';
}
}
function end_el(&$output, $item, $depth = 0, $args=array(), $id = 0) {
$object = $item->object;
$type = $item->type;
$title = $item->title;
$description = $item->description;
$permalink = $item->url;
if ($depth == 1) {
} else {
$output .= '</li>';
}
}
}