Deprecate single product block save (#51153)
* Add deprecated save * Fix button styles * Add changelog * Add attributes to deprecated prop * Add supports prop to deprecated obj * Add code comment
This commit is contained in:
parent
b728f53f29
commit
e4f03589ab
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* External dependencies
|
||||||
|
*/
|
||||||
|
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
import metadata from './block.json';
|
||||||
|
|
||||||
|
const v1 = {
|
||||||
|
attributes: metadata.attributes,
|
||||||
|
supports: metadata.supports,
|
||||||
|
save: () => {
|
||||||
|
const blockProps = useBlockProps.save();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div { ...blockProps }>
|
||||||
|
{ /* @ts-expect-error: `InnerBlocks.Content` is a component that is typed in WordPress core*/ }
|
||||||
|
<InnerBlocks.Content />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const deprecated = [ v1 ];
|
||||||
|
|
||||||
|
export default deprecated;
|
|
@ -10,10 +10,12 @@ import { BLOCK_ICON } from './constants';
|
||||||
import metadata from './block.json';
|
import metadata from './block.json';
|
||||||
import edit from './edit';
|
import edit from './edit';
|
||||||
import save from './save';
|
import save from './save';
|
||||||
|
import deprecated from './deprecated';
|
||||||
|
|
||||||
// @ts-expect-error: `registerBlockType` is a function that is typed in WordPress core.
|
// @ts-expect-error: `registerBlockType` is a function that is typed in WordPress core.
|
||||||
registerBlockType( metadata, {
|
registerBlockType( metadata, {
|
||||||
icon: BLOCK_ICON,
|
icon: BLOCK_ICON,
|
||||||
edit,
|
edit,
|
||||||
save,
|
save,
|
||||||
|
deprecated,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
|
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
|
||||||
|
|
||||||
const Save = () => {
|
const Save = () => {
|
||||||
|
// We add the `woocommerce` class to the wrapper to apply WooCommerce styles to the block.
|
||||||
const blockProps = useBlockProps.save( {
|
const blockProps = useBlockProps.save( {
|
||||||
className: 'woocommerce',
|
className: 'woocommerce',
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Deprecate single product block save #51153
|
|
@ -1699,7 +1699,10 @@ p.demo_store,
|
||||||
* Buttons
|
* Buttons
|
||||||
*/
|
*/
|
||||||
.woocommerce:where(body:not(.woocommerce-block-theme-has-button-styles)),
|
.woocommerce:where(body:not(.woocommerce-block-theme-has-button-styles)),
|
||||||
:where(body:not(.woocommerce-block-theme-has-button-styles)) .woocommerce {
|
:where(body:not(.woocommerce-block-theme-has-button-styles)):where(
|
||||||
|
:not(.edit-post-visual-editor *)
|
||||||
|
)
|
||||||
|
.woocommerce {
|
||||||
a.button,
|
a.button,
|
||||||
button.button,
|
button.button,
|
||||||
input.button,
|
input.button,
|
||||||
|
|
Loading…
Reference in New Issue