From 00ed016bf1721b26e6d38946c1dece0a8aff7684 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 27 Feb 2018 12:46:36 +0000 Subject: [PATCH] Implement selective_refresh for store notice --- .../customizer/class-wc-shop-customizer.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/includes/customizer/class-wc-shop-customizer.php b/includes/customizer/class-wc-shop-customizer.php index 222067bad10..fbdbee410a2 100644 --- a/includes/customizer/class-wc-shop-customizer.php +++ b/includes/customizer/class-wc-shop-customizer.php @@ -103,6 +103,16 @@ class WC_Shop_Customizer { $( '.woocommerce-cropping-control' ).find( 'input:checked' ).change(); } ); + wp.customize( 'woocommerce_demo_store_notice', function( setting ) { + setting.bind( function( value ) { + var checkbox = wp.customize( 'woocommerce_demo_store' ); + + if ( checkbox.get() ) { + $( '.woocommerce-store-notice' ).text( value ); + } + } ); + } ); + wp.customize.section( 'woocommerce_product_catalog', function( section ) { section.expanded.bind( function( isExpanded ) { if ( isExpanded ) { @@ -253,6 +263,7 @@ class WC_Shop_Customizer { 'type' => 'option', 'capability' => 'manage_woocommerce', 'sanitize_callback' => 'wp_kses_post', + 'transport' => 'postMessage', ) ); @@ -276,6 +287,16 @@ class WC_Shop_Customizer { 'type' => 'checkbox', ) ); + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( + 'woocommerce_demo_store_notice', array( + 'selector' => '.woocommerce-store-notice', + 'container_inclusive' => true, + 'render_callback' => 'woocommerce_demo_store', + ) + ); + } } /** @@ -448,9 +469,11 @@ class WC_Shop_Customizer { } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && ! is_multisite() ) { $regen_description = __( 'After publishing your changes, new image sizes will be generated automatically.', 'woocommerce' ); } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && is_multisite() ) { + /* translators: 1: tools URL 2: regen thumbs url */ $regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you regenerate thumbnails. You can do this from the tools section in WooCommerce or by using a plugin such as Regenerate Thumbnails.', 'woocommerce' ), admin_url( 'admin.php?page=wc-status&tab=tools' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' ); } else { - $regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you Regenerate Thumbnails.', 'woocommerce' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' ); + /* translators: %s: regen thumbs url */ + $regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you Regenerate Thumbnails.', 'woocommerce' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' ); } $wp_customize->add_section(