Skip to content

Instantly share code, notes, and snippets.

@chaance
Last active May 24, 2019 05:37
Show Gist options
  • Save chaance/273c93c902bb48b471f029ba7de92f5b to your computer and use it in GitHub Desktop.
Save chaance/273c93c902bb48b471f029ba7de92f5b to your computer and use it in GitHub Desktop.
WordPress editor block example with deprecated versions
/**
* Each version gets a directory where I copy over all of the old block files,
* then export them from here for use in your main block file.
*/
export { default as v1 } from './v1';
export { default as v1_01 } from './v1_01';
import * as exampleBlock from './blocks/example-block';
const { registerBlockType } = wp.blocks;
const { registerPlugin } = wp.plugins;
const plugins = [ /* plugins go here */ ];
const blocks = [
/* blocks go here */
exampleBlock,
];
blocks.forEach( ( { name, settings } ) => {
registerBlockType( name, settings );
} );
plugins.forEach( ( { name, settings } ) => {
registerPlugin( name, settings );
} );
import attributes from './attributes';
import edit from './edit';
import save from './save';
import { v1, v1_01 } from './_deprecated';
import './style.scss';
const { __ } = wp.i18n;
export const name = `my-blocks-plugin/example-block`;
export const settings = {
title: __( 'Buy Now Button', 'my-blocks-plugin' ),
description: __(
'A customizeable button for linking to purchases.',
'my-blocks-plugin',
),
icon: 'money', // https://material.io/tools/icons/
category: 'layout',
keywords: [
__( 'buy now', 'my-blocks-plugin' ),
__( 'buy button', 'my-blocks-plugin' ),
__( 'call to action', 'my-blocks-plugin' ),
],
supports: {
align: false,
alignWide: false,
},
attributes,
edit,
save,
deprecated: [ v1, v1_01 ],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment