mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-21 04:11:59 +08:00
Make the site title and description use selective refresh #362
Also removes the js currently used for asynchronous refresh
This commit is contained in:
parent
6d9cfeb7f0
commit
9696d24eff
2 changed files with 17 additions and 80 deletions
|
@ -1,69 +0,0 @@
|
|||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
// Site title and description.
|
||||
wp.customize( 'blogname', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-title a' ).text( to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'blogdescription', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-description' ).text( to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_text_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( 'body, .widget-area .widget a, .onsale, .woocommerce-tabs ul.tabs li.active a, ul.products li.product .price, .widget-area .widget a, .pagination .page-numbers li .page-numbers:not(.current), .woocommerce-pagination .page-numbers li .page-numbers:not(.current)' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_text_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.onsale' ).css( 'border-color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_heading_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-content h1, .site-content h2, .site-content h3, .site-content h4, .site-content h5, .site-content h6' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_header_text_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( 'p.site-description, .secondary-navigation ul.menu li a, .secondary-navigation ul.menu a, .site-header-cart .widget_shopping_cart, .site-header .product_list_widget li .quantity' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_header_link_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.main-navigation ul li a, .site-title a, a.cart-contents, .site-header-cart .widget_shopping_cart a' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_header_background_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-header, .main-navigation ul ul, .secondary-navigation ul ul, .main-navigation ul.menu > li.menu-item-has-children:after, .site-header-cart .widget_shopping_cart, .secondary-navigation ul.menu ul, button.menu-toggle' ).css( 'background-color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_footer_heading_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-footer h1, .site-footer h2, .site-footer h3, .site-footer h4, .site-footer h5, .site-footer h6' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_footer_text_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-footer' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_footer_link_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-footer a:not(.button)' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
wp.customize( 'storefront_footer_background_color', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-footer' ).css( 'background-color', to );
|
||||
} );
|
||||
} );
|
||||
} )( jQuery );
|
|
@ -24,7 +24,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
* @since 1.0
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ), 10 );
|
||||
add_action( 'customize_register', array( $this, 'customize_register' ), 10 );
|
||||
add_filter( 'body_class', array( $this, 'layout_class' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'add_customizer_css' ), 130 );
|
||||
|
@ -117,6 +116,7 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
*/
|
||||
public function customize_register( $wp_customize ) {
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
|
||||
// Move background color setting alongside background image.
|
||||
|
@ -131,6 +131,21 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
$wp_customize->get_section( 'header_image' )->title = __( 'Header', 'storefront' );
|
||||
$wp_customize->get_section( 'header_image' )->priority = 25;
|
||||
|
||||
// Selective refresh.
|
||||
$wp_customize->selective_refresh->add_partial( 'blogname', array(
|
||||
'selector' => '.site-title a',
|
||||
'render_callback' => function() {
|
||||
bloginfo( 'name' );
|
||||
},
|
||||
) );
|
||||
|
||||
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
|
||||
'selector' => '.site-description',
|
||||
'render_callback' => function() {
|
||||
bloginfo( 'description' );
|
||||
},
|
||||
) );
|
||||
|
||||
/**
|
||||
* Custom controls
|
||||
*/
|
||||
|
@ -143,7 +158,7 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
|
||||
/**
|
||||
* Add the typography section
|
||||
*/
|
||||
*/
|
||||
$wp_customize->add_section( 'storefront_typography' , array(
|
||||
'title' => __( 'Typography', 'storefront' ),
|
||||
'priority' => 45,
|
||||
|
@ -771,15 +786,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function customize_preview_js() {
|
||||
wp_enqueue_script( 'storefront-customizer', get_template_directory_uri() . '/assets/js/customizer/customizer.min.js', array( 'customize-preview' ), '1.16', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Layout classes
|
||||
* Adds 'right-sidebar' and 'left-sidebar' classes to the body tag
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue