2019-05-16 13:03:11 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { RawHTML } from '@wordpress/element';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import getShortcode from './get-shortcode';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a save function using the blockType to generate the correct shortcode.
|
2019-12-10 17:17:46 +00:00
|
|
|
*
|
|
|
|
* @param {*} blockType Block being rendered.
|
2019-05-16 13:03:11 +00:00
|
|
|
*/
|
|
|
|
export const deprecatedConvertToShortcode = ( blockType ) => {
|
|
|
|
return function( props ) {
|
2019-09-05 15:09:31 +00:00
|
|
|
const { align, contentVisibility } = props.attributes;
|
2019-05-16 13:03:11 +00:00
|
|
|
const classes = classnames( align ? `align${ align }` : '', {
|
|
|
|
'is-hidden-title': ! contentVisibility.title,
|
|
|
|
'is-hidden-price': ! contentVisibility.price,
|
|
|
|
'is-hidden-rating': ! contentVisibility.rating,
|
|
|
|
'is-hidden-button': ! contentVisibility.button,
|
|
|
|
} );
|
|
|
|
return (
|
|
|
|
<RawHTML className={ classes }>
|
|
|
|
{ getShortcode( props, blockType ) }
|
|
|
|
</RawHTML>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|