Allow HTML in built in payment method descriptions

This commit is contained in:
Mike Jolley 2023-12-12 15:23:22 +00:00
parent 550cecf866
commit 2abd0422a8
4 changed files with 12 additions and 4 deletions

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -19,7 +21,7 @@ const label = decodeEntities( settings?.title || '' ) || defaultLabel;
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
/**

View File

@ -5,6 +5,8 @@ import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData, WC_ASSET_URL } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
import { sanitizeHTML } from '@woocommerce/utils';
import { RawHTML } from '@wordpress/element';
/**
* Internal dependencies
@ -17,7 +19,7 @@ const settings = getPaymentMethodData( 'paypal', {} );
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
return <RawHTML>{ sanitizeHTML( settings.description || '' ) }</RawHTML>;
};
const paypalPaymentMethod = {