PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.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 / blocks / button-container / deprecated.js
generateblocks / src / blocks / button-container Last commit date
components 1 year ago css 2 years ago attributes.js 3 years ago block.js 1 year ago deprecated.js 3 years ago edit.js 3 years ago editor.scss 4 years ago
deprecated.js
78 lines
1 /**
2 * External dependencies
3 */
4 import classnames from 'classnames';
5 import blockAttributes from './attributes';
6
7 import {
8 InnerBlocks,
9 } from '@wordpress/block-editor';
10
11 import {
12 applyFilters,
13 } from '@wordpress/hooks';
14
15 import { getBlockAttributes } from '../../block-context';
16 import buttonContainerContext from '../../block-context/button-container';
17
18 const allAttributes = Object.assign(
19 {},
20 getBlockAttributes(
21 blockAttributes,
22 buttonContainerContext,
23 generateBlocksDefaults.buttonContainer
24 ),
25 );
26
27 const deprecated = [
28 // v1 of container block. Deprecated the gb-grid-column wrapper in save component.
29 {
30 attributes: allAttributes,
31 supports: {
32 anchor: false,
33 className: false,
34 customClassName: false,
35 },
36 migrate( attributes ) {
37 const oldClasses = attributes.cssClasses ? attributes.cssClasses : attributes.className;
38 const oldAnchor = attributes.elementId ? attributes.elementId : attributes.anchor;
39
40 return {
41 ...attributes,
42 className: oldClasses,
43 anchor: oldAnchor,
44 cssClasses: '',
45 elementId: '',
46 };
47 },
48 save( { attributes } ) {
49 const {
50 uniqueId,
51 elementId,
52 cssClasses,
53 } = attributes;
54
55 let htmlAttributes = {
56 id: !! elementId ? elementId : undefined,
57 className: classnames( {
58 'gb-button-wrapper': true,
59 [ `gb-button-wrapper-${ uniqueId }` ]: true,
60 [ `${ cssClasses }` ]: '' !== cssClasses,
61 } ),
62 };
63
64 htmlAttributes = applyFilters( 'generateblocks.frontend.htmlAttributes', htmlAttributes, 'generateblocks/button-container', attributes );
65
66 return (
67 <div
68 { ...htmlAttributes }
69 >
70 <InnerBlocks.Content />
71 </div>
72 );
73 },
74 },
75 ];
76
77 export default deprecated;
78