PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.6.0
GenerateBlocks v1.6.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / hoc / withButtonContainerLegacyMigration.js
generateblocks / src / hoc Last commit date
index.js 4 years ago withButtonContainerLegacyMigration.js 4 years ago withButtonLegacyMigration.js 4 years ago withContainerLegacyMigration.js 4 years ago withDocumentation.js 4 years ago withGridLegacyMigration.js 4 years ago withResponsiveTabs.js 4 years ago withUniqueId.js 4 years ago
withButtonContainerLegacyMigration.js
47 lines
1 import { useEffect } from '@wordpress/element';
2
3 export default ( WrappedComponent ) => {
4 return ( props ) => {
5 const {
6 attributes,
7 setAttributes,
8 } = props;
9
10 useEffect( () => {
11 // This block used to be static. Set it to dynamic by default from now on.
12 if ( 'undefined' === typeof attributes.isDynamic || ! attributes.isDynamic ) {
13 setAttributes( { isDynamic: true } );
14 }
15
16 // Set our responsive stack and fill options if set on desktop.
17 // @since 1.4.0.
18 if ( 'undefined' === typeof attributes.blockVersion || attributes.blockVersion < 2 ) {
19 if ( attributes.stack || attributes.fillHorizontalSpace ) {
20 if ( attributes.stack ) {
21 setAttributes( {
22 stackTablet: true,
23 stackMobile: true,
24 } );
25 }
26
27 if ( attributes.fillHorizontalSpace ) {
28 setAttributes( {
29 fillHorizontalSpaceTablet: true,
30 fillHorizontalSpaceMobile: true,
31 } );
32 }
33 }
34 }
35
36 // Update block version flag if it's out of date.
37 const blockVersion = 2;
38
39 if ( 'undefined' === typeof attributes.blockVersion || attributes.blockVersion < blockVersion ) {
40 setAttributes( { blockVersion } );
41 }
42 }, [] );
43
44 return ( <WrappedComponent { ...props } /> );
45 };
46 };
47