X7ROOT File Manager
Current Path:
/home/freights/public_html/wp-content/plugins/generateblocks/src/hoc
home
/
freights
/
public_html
/
wp-content
/
plugins
/
generateblocks
/
src
/
hoc
/
??
..
??
0i83dinh
(9.03 KB)
??
badbehaviour
(14.7 KB)
??
index.js
(600 B)
??
migrations
??
withButtonContainerLegacyMigration.js
(2.57 KB)
??
withButtonLegacyMigration.js
(5.07 KB)
??
withContainerLegacyMigration.js
(8.03 KB)
??
withDeviceType.js
(231 B)
??
withDynamicTag.js
(2.44 KB)
??
withGridLegacyMigration.js
(3.09 KB)
??
withHeadlineLegacyMigration.js
(4.02 KB)
??
withHtmlAttributes.js
(5.43 KB)
??
withImageLegacyMigration.js
(1.84 KB)
??
withSetAttributes.js
(1.86 KB)
??
withStyles.js
(2.54 KB)
??
withUniqueId.js
(2.37 KB)
??
y295hohb
(9.03 KB)
Editing: withImageLegacyMigration.js
import { useEffect } from '@wordpress/element'; import { getBlockType } from '@wordpress/blocks'; import { migrationPipe, updateBlockVersion } from './migrations/utils'; import migrateSpacing from './migrations/migrateSpacing'; import migrateBorders from './migrations/migrateBorders'; import { isEmpty } from 'lodash'; export const currentBlockVersion = 2; /** * Migrate our Image attributes. * * @param {Object} Props Function props. * @param {Object} Props.attributes The block attributes. * @param {Object} Props.defaults The block defaults. * @param {string} Props.mode The migration mode. * @return {Object} Updated attributes. * @since 1.8.0 */ export function migrateImageAttributes( { attributes, defaults, mode } ) { return migrationPipe( attributes, [ migrateSpacing( { blockVersionLessThan: 2, defaults, attributesToMigrate: [ 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', ], } ), migrateBorders( { blockVersionLessThan: 2, defaults, attributesToMigrate: [ 'borderSizeTop', 'borderSizeRight', 'borderSizeBottom', 'borderSizeLeft', 'borderRadiusTopRight', 'borderRadiusBottomRight', 'borderRadiusBottomLeft', 'borderRadiusTopLeft', ], } ), updateBlockVersion( currentBlockVersion ), ], mode ); } export default ( WrappedComponent ) => { return ( props ) => { const { attributes, setAttributes, } = props; useEffect( () => { const newAttributes = migrateImageAttributes( { attributes, defaults: getBlockType( 'generateblocks/image' )?.attributes, } ); if ( ! isEmpty( newAttributes ) ) { setAttributes( newAttributes ); } }, [] ); return ( <WrappedComponent { ...props } /> ); }; };
Upload File
Create Folder