add settings to customizer for sidebar nav
This commit is contained in:
parent
0892fab0ac
commit
cfe79db5b1
2 changed files with 48 additions and 29 deletions
|
|
@ -8,22 +8,25 @@ function kit_setup() {
|
||||||
add_theme_support( 'post-thumbnails' );
|
add_theme_support( 'post-thumbnails' );
|
||||||
add_theme_support( 'custom-logo' );
|
add_theme_support( 'custom-logo' );
|
||||||
|
|
||||||
register_nav_menus( array(
|
|
||||||
'primary' => 'Main Menu',
|
|
||||||
'secondary' => 'Footer Menu',
|
|
||||||
'extra' => 'Extra Menu'
|
|
||||||
) );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
add_action( 'after_setup_theme', 'kit_setup' );
|
add_action( 'after_setup_theme', 'kit_setup' );
|
||||||
|
|
||||||
|
# Registering menus
|
||||||
|
|
||||||
|
register_nav_menus( array(
|
||||||
|
'primary' => 'Main Menu',
|
||||||
|
'secondary' => 'Footer Menu',
|
||||||
|
'extra' => 'Extra Menu'
|
||||||
|
) );
|
||||||
|
|
||||||
function add_menu_link_class( $atts, $item, $args ) {
|
function add_menu_link_class( $atts, $item, $args ) {
|
||||||
if (property_exists($args, 'link_class')) {
|
if (property_exists($args, 'link_class')) {
|
||||||
$atts['class'] = $args->link_class;
|
$atts['class'] = $args->link_class;
|
||||||
}
|
}
|
||||||
return $atts;
|
return $atts;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );
|
add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );
|
||||||
|
|
||||||
class kit_custom_main_menu extends Walker_Nav_Menu {
|
class kit_custom_main_menu extends Walker_Nav_Menu {
|
||||||
|
|
@ -125,6 +128,8 @@ class kit_custom_main_menu extends Walker_Nav_Menu {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Custom size settings for customizer
|
||||||
|
|
||||||
function theme_customize_register( $wp_customize ) {
|
function theme_customize_register( $wp_customize ) {
|
||||||
|
|
||||||
$wp_customize->add_setting( 'theme_color', array(
|
$wp_customize->add_setting( 'theme_color', array(
|
||||||
|
|
@ -132,40 +137,52 @@ function theme_customize_register( $wp_customize ) {
|
||||||
'transport' => 'refresh',
|
'transport' => 'refresh',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'theme_color', array(
|
$wp_customize->add_control( new WP_Customize_Color_Control(
|
||||||
|
$wp_customize, 'theme_color', array(
|
||||||
'section' => 'colors',
|
'section' => 'colors',
|
||||||
'label' => esc_html__( 'Theme color', 'theme' ),
|
'label' => esc_html__( 'Theme color', 'theme' ),
|
||||||
) ) );
|
) ) );
|
||||||
|
|
||||||
$wp_customize->add_section( 'kit_advanced_settings' , array(
|
$wp_customize->add_setting( 'kit_sidenav-mail', array(
|
||||||
'title' => __('Advanced settings','kit'),
|
'default' => '',
|
||||||
'priority' => 30,
|
'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_url_setting_id', array(
|
$wp_customize->add_setting( 'kit_sidenav-faqpage', array(
|
||||||
'capability' => 'edit_theme_options',
|
'sanitize_callback' => 'absint',
|
||||||
'sanitize_callback' => 'kit_sanitize_url',
|
'default' => ''
|
||||||
) );
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$wp_customize->add_control( 'kit_url_setting_id', array(
|
$wp_customize->add_control( new WP_Customize_Control(
|
||||||
'type' => 'url',
|
$wp_customize, 'kit_sidenav-faqpage', array(
|
||||||
'section' => 'nav',
|
'label' => __( 'FAQ page', 'kit' ),
|
||||||
'label' => __( 'Custom URL' ),
|
'description' => __( 'FAQ page used in sidebar menu', 'kit' ),
|
||||||
'description' => __( 'This is a custom url input.' ),
|
'settings' => 'kit_sidenav-faqpage',
|
||||||
'input_attrs' => array(
|
'section' => 'title_tagline',
|
||||||
'placeholder' => __( 'http://www.google.com' ),
|
'type' => 'dropdown-pages',
|
||||||
),
|
)
|
||||||
) );
|
) );
|
||||||
|
|
||||||
function kit_sanitize_url( $url ) {
|
|
||||||
return esc_url_raw( $url );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'customize_register', 'kit_advanced_settings' );
|
|
||||||
add_action( 'customize_register', 'theme_customize_register' );
|
add_action( 'customize_register', 'theme_customize_register' );
|
||||||
|
|
||||||
|
# Apply custom CSS settings
|
||||||
|
|
||||||
function kit_customize_css()
|
function kit_customize_css()
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
|
|
@ -291,8 +308,10 @@ function kit_customize_css()
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'wp_head', 'kit_customize_css');
|
add_action( 'wp_head', 'kit_customize_css');
|
||||||
|
|
||||||
|
# Search customizations
|
||||||
|
|
||||||
function kit_modify_posts_per_page( $query ) {
|
function kit_modify_posts_per_page( $query ) {
|
||||||
if ( $query->is_search() ) {
|
if ( $query->is_search() ) {
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
<span>Suche</span>
|
<span>Suche</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="<?php echo home_url(); ?>/faq" class="aside-icon">
|
<a href="<?php echo esc_url( get_page_link( get_theme_mod('kit_sidenav-faqpage') ) ); ?>" class="aside-icon">
|
||||||
<img src="<?php bloginfo('stylesheet_directory');?>/img/faq-white.svg" alt="Zu den FAQ">
|
<img src="<?php bloginfo('stylesheet_directory');?>/img/faq-white.svg" alt="Zu den FAQ">
|
||||||
<span>Zu den FAQ</span>
|
<span>Zu den FAQ</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="mailto:info@ausbildung.kit.edu" class="aside-icon">
|
<a href="mailto:<?php echo get_option('kit_sidenav-mail'); ?>" class="aside-icon">
|
||||||
<img src="<?php bloginfo('stylesheet_directory');?>/img/mail-white.svg" alt="Kontakt">
|
<img src="<?php bloginfo('stylesheet_directory');?>/img/mail-white.svg" alt="Kontakt">
|
||||||
<span>Kontakt</span>
|
<span>Kontakt</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue