'Main Menu',
'secondary' => 'Footer Menu',
'extra' => 'Extra Menu'
) );
function add_menu_link_class( $atts, $item, $args ) {
if (property_exists($args, 'link_class')) {
$atts['class'] = $args->link_class;
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );
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 . '
' . "\n";
} else {
$output .= "\n" . $indent . '
' . "\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 . '
' . "\n";
} else {
$output .= "\n" . $indent . '' . "\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 .= '
';
$output .= $title;
$output .= '
Untermenu öffnen / schließen
';
} elseif ($depth == 2) {
$output .= "
";
$output .= '
';
$output .= $title;
$output .= ' ';
} else {
$output .= "";
$output .= '
Untermenu öffnen / schließen
';
$output .= '';
$output .= $title;
$output .= '';
}
}
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) {
$output .= '
';
} else {
$output .= '';
}
}
}
# Custom size settings for customizer
function theme_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'theme_color', array(
'default' => '#009982',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control(
$wp_customize, 'theme_color', array(
'section' => 'colors',
'label' => esc_html__( 'Theme color', 'theme' ),
) ) );
$wp_customize->add_setting( 'kit_sidenav-mail', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
),
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize, 'sidenav_mail_control', array(
'label' => __( 'Contact mail', 'kit' ),
'description' => __( 'Mail address used in sidebar menu', 'kit' ),
'settings' => 'kit_sidenav-mail',
'priority' => 10,
'section' => 'title_tagline',
'type' => 'text',
)
) );
$wp_customize->add_setting( 'kit_sidenav-faqpage', array(
'sanitize_callback' => 'absint',
'default' => ''
),
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize, 'kit_sidenav-faqpage', array(
'label' => __( 'FAQ page', 'kit' ),
'description' => __( 'FAQ page used in sidebar menu', 'kit' ),
'settings' => 'kit_sidenav-faqpage',
'section' => 'title_tagline',
'type' => 'dropdown-pages',
)
) );
$wp_customize->add_setting( 'kit_copyrighttext', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
),
);
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize, 'sidenav_copyrighttext', array(
'label' => __( 'Copyright text', 'kit' ),
'description' => __( 'Displayed in the footer', 'kit' ),
'settings' => 'kit_copyrighttext',
'section' => 'title_tagline',
'type' => 'text',
)
) );
$wp_customize->add_setting( 'kit_defaultimage' );
$wp_customize->add_control( new WP_Customize_Media_Control(
$wp_customize, 'kit_defaultimage', array(
'label' => __( 'Default featured image', 'kit' ),
'settings' => 'kit_defaultimage',
'section' => 'title_tagline',
)
) );
}
add_action( 'customize_register', 'theme_customize_register' );
# Apply custom CSS settings
function kit_customize_css()
{
?>
is_search() ) {
$query->set( 'posts_per_page', '10' );
} else {
$query->set( 'posts_per_page', '9' );
}
}
add_action( 'pre_get_posts', 'kit_modify_posts_per_page' );