Merge pull request #22645 from woocommerce/update/21963

Add notice hash to store notice cookie
This commit is contained in:
Mike Jolley 2019-02-08 13:05:03 +00:00 committed by GitHub
commit 8404b644da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -14,19 +14,22 @@ jQuery( function( $ ) {
} }
}); });
// Set a cookie and hide the store notice when the dismiss button is clicked var noticeID = $( '.woocommerce-store-notice' ).data( 'notice-id' ) || '',
$( '.woocommerce-store-notice__dismiss-link' ).click( function() { cookieName = 'store_notice' + noticeID;
Cookies.set( 'store_notice', 'hidden', { path: '/' } );
$( '.woocommerce-store-notice' ).hide();
});
// Check the value of that cookie and show/hide the notice accordingly // Check the value of that cookie and show/hide the notice accordingly
if ( 'hidden' === Cookies.get( 'store_notice' ) ) { if ( 'hidden' === Cookies.get( cookieName ) ) {
$( '.woocommerce-store-notice' ).hide(); $( '.woocommerce-store-notice' ).hide();
} else { } else {
$( '.woocommerce-store-notice' ).show(); $( '.woocommerce-store-notice' ).show();
} }
// Set a cookie and hide the store notice when the dismiss button is clicked
$( '.woocommerce-store-notice__dismiss-link' ).click( function() {
Cookies.set( cookieName, 'hidden', { path: '/' } );
$( '.woocommerce-store-notice' ).hide();
});
// Make form field descriptions toggle on focus. // Make form field descriptions toggle on focus.
$( document.body ).on( 'click', function() { $( document.body ).on( 'click', function() {
$( '.woocommerce-input-wrapper span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 ); $( '.woocommerce-input-wrapper span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 );

View File

@ -974,7 +974,9 @@ if ( ! function_exists( 'woocommerce_demo_store' ) ) {
$notice = __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ); $notice = __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' );
} }
echo apply_filters( 'woocommerce_demo_store', '<p class="woocommerce-store-notice demo_store">' . wp_kses_post( $notice ) . ' <a href="#" class="woocommerce-store-notice__dismiss-link">' . esc_html__( 'Dismiss', 'woocommerce' ) . '</a></p>', $notice ); // WPCS: XSS ok. $notice_id = md5( $notice );
echo apply_filters( 'woocommerce_demo_store', '<p class="woocommerce-store-notice demo_store" data-notice-id="' . esc_attr( $notice_id ) . '" style="display:none;">' . wp_kses_post( $notice ) . ' <a href="#" class="woocommerce-store-notice__dismiss-link">' . esc_html__( 'Dismiss', 'woocommerce' ) . '</a></p>', $notice ); // WPCS: XSS ok.
} }
} }