custom logo selective refresh

This commit is contained in:
James Koster 2016-08-03 09:49:16 +01:00
parent 279147af4e
commit 71bc5b3961
2 changed files with 37 additions and 19 deletions

View file

@ -144,8 +144,15 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->get_section( 'header_image' )->priority = 25;
// Selective refresh.
$wp_customize->selective_refresh->add_partial( 'custom_logo', array(
'selector' => '.site-branding',
'render_callback' => function() {
storefront_site_title_or_logo();
},
) );
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'selector' => '.site-title.beta a',
'render_callback' => function() {
bloginfo( 'name' );
},

View file

@ -153,7 +153,7 @@ if ( ! function_exists( 'storefront_header_widget_region' ) ) {
if ( ! function_exists( 'storefront_site_branding' ) ) {
/**
* Display Site Branding
* Site branding wrapper and display
*
* @since 1.0.0
* @return void
@ -161,28 +161,39 @@ if ( ! function_exists( 'storefront_site_branding' ) ) {
function storefront_site_branding() {
?>
<div class="site-branding">
<?php
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
$logo = get_custom_logo();
echo $logo = is_front_page() ? '<h1 class="logo">' . $logo . '</h1>' : $logo;
} elseif ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) {
jetpack_the_site_logo();
} else {
$tag = is_front_page() ? 'h1' : 'div';
echo '<' . esc_attr( $tag ) . ' class="beta site-title"><a href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . esc_attr( get_bloginfo( 'name' ) ) . '</a></' . esc_attr( $tag ) .'>';
if ( '' != get_bloginfo( 'description' ) ) { ?>
<p class="site-description"><?php echo bloginfo( 'description' ); ?></p>
<?php
}
} ?>
<?php storefront_site_title_or_logo(); ?>
</div>
<?php
}
}
if ( ! function_exists( 'storefront_site_title_or_logo' ) ) {
/**
* Display the site title or logo
*
* @since 2.1.0
* @return void
*/
function storefront_site_title_or_logo() {
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
$logo = get_custom_logo();
echo $logo = is_front_page() ? '<h1 class="logo">' . $logo . '</h1>' : $logo;
} elseif ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) {
jetpack_the_site_logo();
} else {
$tag = is_front_page() ? 'h1' : 'div';
echo '<' . esc_attr( $tag ) . ' class="beta site-title"><a href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . esc_attr( get_bloginfo( 'name' ) ) . '</a></' . esc_attr( $tag ) .'>';
if ( '' != get_bloginfo( 'description' ) ) { ?>
<p class="site-description"><?php echo bloginfo( 'description' ); ?></p>
<?php
}
}
}
}
if ( ! function_exists( 'storefront_primary_navigation' ) ) {
/**
* Display Primary Navigation