mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-20 04:00:29 +08:00
custom logo selective refresh
This commit is contained in:
parent
279147af4e
commit
71bc5b3961
2 changed files with 37 additions and 19 deletions
|
@ -144,8 +144,15 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
||||||
$wp_customize->get_section( 'header_image' )->priority = 25;
|
$wp_customize->get_section( 'header_image' )->priority = 25;
|
||||||
|
|
||||||
// Selective refresh.
|
// 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(
|
$wp_customize->selective_refresh->add_partial( 'blogname', array(
|
||||||
'selector' => '.site-title a',
|
'selector' => '.site-title.beta a',
|
||||||
'render_callback' => function() {
|
'render_callback' => function() {
|
||||||
bloginfo( 'name' );
|
bloginfo( 'name' );
|
||||||
},
|
},
|
||||||
|
|
|
@ -153,7 +153,7 @@ if ( ! function_exists( 'storefront_header_widget_region' ) ) {
|
||||||
|
|
||||||
if ( ! function_exists( 'storefront_site_branding' ) ) {
|
if ( ! function_exists( 'storefront_site_branding' ) ) {
|
||||||
/**
|
/**
|
||||||
* Display Site Branding
|
* Site branding wrapper and display
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -161,28 +161,39 @@ if ( ! function_exists( 'storefront_site_branding' ) ) {
|
||||||
function storefront_site_branding() {
|
function storefront_site_branding() {
|
||||||
?>
|
?>
|
||||||
<div class="site-branding">
|
<div class="site-branding">
|
||||||
<?php
|
<?php 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
|
|
||||||
}
|
|
||||||
} ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?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' ) ) {
|
if ( ! function_exists( 'storefront_primary_navigation' ) ) {
|
||||||
/**
|
/**
|
||||||
* Display Primary Navigation
|
* Display Primary Navigation
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue