Skip to content

Instantly share code, notes, and snippets.

@salcode
Created August 6, 2015 20:46
Show Gist options
  • Save salcode/5a39e9edc9ad18bc6aeb to your computer and use it in GitHub Desktop.
Save salcode/5a39e9edc9ad18bc6aeb to your computer and use it in GitHub Desktop.
Bootstrap Genesis - add the logo in the nav to the customizer. This file can be dropped into the wp-content/mu-plugins/ directory (note: you may need to create the mu-plugins folder within wp-content if it does not already exist)
<?php
// add customizer controls
add_action( 'customize_register', 'bsg_navbar_brand_logo_customize_register' );
function bsg_navbar_brand_logo_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'brand_logo',
array(
'default' => '',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
)
);
$wp_customize->add_control( new WP_Customize_Image_Control(
$wp_customize,
'bsg_brand_logo',
array(
'label' => __( 'Navbar Logo', 'bsg' ),
'section' => 'title_tagline',
'settings' => 'brand_logo',
'priority' => 10,
)
) );
}
// show logo if it has been added via customizer
add_filter( 'bsg_navbar_brand', 'bsg_customizer_add_navbar_brand' );
function bsg_customizer_add_navbar_brand( $output ) {
$brand_logo = get_theme_mod( 'brand_logo' );
// check $brand_logo is set
if ( ! $brand_logo ) {
return $output;
}
$output = '<a style="padding: 0 15px;" class="" id="logo" title="' .
esc_attr( get_bloginfo( 'description' ) ) .
'" href="' .
esc_url( home_url( '/' ) ) .
'">';
$output .= '<img style="width: 104px; height: 46px; margin-top: 3px;" src="' .
$brand_logo .
'" alt="' .
esc_attr( get_bloginfo( 'name' ) ) .
'">';
$output .= '</a>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment