Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gutenberg Workshop Slides - WordCamp London 2018

Gutenberg Workshop Slides - WordCamp London 2018

In this "workshop" we go over some of the basic content from WordCamp London workshop on Gutenberg Development

Zac Gordon

April 15, 2018
Tweet

More Decks by Zac Gordon

Other Decks in Technology

Transcript

  1. https://gutenberg.courses/wcldn @zgordon Gutenberg JavaScript Libraries • wp.element - React abstraction

    • wp.blocks - Resources for building blocks • wp.components - Generic UI components • wp.i18n - Internationalization • wp.data - Redux data store
  2. https://gutenberg.courses/wcldn @zgordon // Get funcs & components from global scope

    const { __ } = wp.i18n; const { Component } = wp.element; const { registerBlockType, RichText } = wp.blocks; const { Button } = wp.components;
  3. https://gutenberg.courses/wcldn @zgordon Tooling and Enqueuing CSS & JS • Tools

    - babel, webpack, npm • enqueue_block_editor_assets - Editor Only • enqueue_block_assets - Frontend & Editor
  4. https://gutenberg.courses/wcldn @zgordon registerBlockType Settings 1. title - Name of the

    block 2. description - Short description of the block 3. category - How block is organized with other blocks 4. icon - Appears with the title when adding the block 5. keywords - Additional ways to search for the block 6. supports - Enables and disables certain block features 7. attributes - Identifies dynamic data in your block 8. edit - The UI and functionality for editing the block 9. save - The UI (and functionality) for how block on frontend
  5. https://gutenberg.courses/wcldn @zgordon // Example of some of the registerBlockType settings

    wp.blocks.registerBlockType(
 'example-plugin/example-custom-block', { title: wp.i18n.__( 'Example Custom Block', 'myplugin' ), category: 'common', icon: 'wordpress-alt', keywords: [ wp.i18n.__( 'Demo' ) ], edit: () => <p>{ wp.i18n.__( 'Edit this.', 'myplugin' ) }</p>, save: () => <p>{ wp.i18n.__( 'Save this.', 'myplugin' ) }</p>, } );