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 |