* Fix html in preview of product titles

Previously the html wasn't rendered in the preview for product titles.
This renders the html.

* Update test snapshot

* Also decode html for featured preview name.

* Un-escape HTML for featured post title render
This commit is contained in:
Kevin Killingsworth 2019-02-25 23:32:04 -06:00 committed by GitHub
parent ffc19e26ec
commit 7ffc11d987
4 changed files with 23 additions and 11 deletions

View File

@ -278,9 +278,12 @@ class FeaturedProduct extends Component {
style={ style }
>
<div className="wc-block-featured-product__wrapper">
<h2 className="wc-block-featured-product__title">
{ product.name }
</h2>
<h2
className="wc-block-featured-product__title"
dangerouslySetInnerHTML={ {
__html: product.name,
} }
/>
{ showDesc && (
<div
className="wc-block-featured-product__description"

View File

@ -25,7 +25,10 @@ const ProductPreview = ( { product } ) => {
return (
<div className="wc-product-preview">
{ image }
<div className="wc-product-preview__title">{ product.name }</div>
<div
className="wc-product-preview__title"
dangerouslySetInnerHTML={ { __html: product.name } }
/>
<div
className="wc-product-preview__price"
dangerouslySetInnerHTML={ { __html: product.price_html } }

View File

@ -10,9 +10,12 @@ exports[`ProductPreview should render a single product preview with an image 1`]
/>
<div
className="wc-product-preview__title"
>
Winter Jacket
</div>
dangerouslySetInnerHTML={
Object {
"__html": "Winter Jacket",
}
}
/>
<div
className="wc-product-preview__price"
dangerouslySetInnerHTML={
@ -43,9 +46,12 @@ exports[`ProductPreview should render a single product preview without an image
/>
<div
className="wc-product-preview__title"
>
Winter Jacket
</div>
dangerouslySetInnerHTML={
Object {
"__html": "Winter Jacket",
}
}
/>
<div
className="wc-product-preview__price"
dangerouslySetInnerHTML={

View File

@ -56,7 +56,7 @@ class WC_Block_Featured_Product {
$title = sprintf(
'<h2 class="wc-block-featured-product__title">%s</h2>',
esc_html( $product->get_title() )
wp_kses_post( $product->get_title() )
);
$desc_str = sprintf(