Skip to content

Instantly share code, notes, and snippets.

@rachelmccollin
Last active December 22, 2017 12:39
Show Gist options
  • Save rachelmccollin/5e4c15d29e9e97307266fcdfe6b0b3f6 to your computer and use it in GitHub Desktop.
Save rachelmccollin/5e4c15d29e9e97307266fcdfe6b0b3f6 to your computer and use it in GitHub Desktop.
WPMU DEV Adding Styling via the Customizer Without Adding CSS to the Page
<?php
function wpmu_customize_register( $wp_customize ) {
}
add_action( 'customize_register', 'wpmu_customize_register' );
/*******************************************
Section
********************************************/
// colors section
$wp_customize->add_section( 'wpmu_colors' , array(
'title' => __( 'Colors', 'wpmu')
) );
/*******************************************
Color settings
********************************************/
//logo position
$wp_customize->add_setting( 'wpmu_nav_color' );
$wp_customize->add_control( 'wpmu_nav_color', array (
'label' => 'Navigation Menu Color',
'section' => 'wpmu_colors',
'settings' => 'wpmu_header_color',
'type' => 'radio',
'choices' => array(
'blue' => __( 'Blue', 'wpmu' ),
'red' => __( 'Red', 'wpmu' ),
'green' => __( 'Green', 'wpmu' ),
)
));
include( get_stylesheet_directory() . '/includes/customizer.php' );
<nav class="main <?php echo apply_filters( 'wpmu_header_color_css', 'blue' ); ?>">
<?php wp_nav_menu( array(
'theme_location' => 'header-menu',
'container_class' => 'menu'
) ); ?>
</nav>
<nav class="main">
<?php wp_nav_menu( array(
'theme_location' => 'header-menu',
'container_class' => 'menu'
) ); ?>
</nav>
nav.main.blue
nav.main.blue a {
background: #312d72;
}
nav.main.red,
nav.main.red a {
background: #8b1b1b;
}
nav.main.green,
nav.main.green a {
background: #0e4813;
}
function wpmu_header_color( $header_color ) {
$header_color = get_theme_mod( 'wpmu_header_color', 'blue' );
return $header_color;
}
add_filter( 'wpmu_header_color_css' , 'wpmu_header_color' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment