gutenberg comes to wordpress - iron code studior e s o u r c e s (without es6+, jsx, webpack ,...

94
GUTENBERG COMES GUTENBERG COMES TO WORDPRESS TO WORDPRESS / Sal Ferrarello @salcode

Upload: others

Post on 13-Aug-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

GUTENBERG COMESGUTENBERG COMESTO WORDPRESSTO WORDPRESS

/

Sal Ferrarello @salcode

Page 2: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 3: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 4: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 5: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 6: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

BLOCK BASED EDITORBLOCK BASED EDITOR

Page 7: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 8: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 9: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:paragraph --> <p>This is a paragraph block.</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>This is another paragraph block.</p> <!-- /wp:paragraph -->

Page 10: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:quote --> <blockquote class="wp-block-quote"> <p>I was only ever wrong once and that was the time I thought I was wrong.</p> <cite>My Grandfather</cite></blockquote> <!-- /wp:quote -->

Page 11: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

WHOA, SLOW DOWN!WHOA, SLOW DOWN!

Page 12: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

or the Plugin

add_filter( 'gutenberg_can_edit_post_type', '__return_false' );

Disable Gutenberg

Page 13: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

BLOCK TOOLBARBLOCK TOOLBAR

Page 14: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

BLOCK INSPECTORBLOCK INSPECTOR CONTROLSCONTROLS

Page 15: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 16: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

THEME SUPPORTTHEME SUPPORTfunctions.php

<?php /** * Add support for .alignwide and .alignfull * CSS classes. Typically used on images. */ add_theme_support( 'align-wide' );

Page 17: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 18: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 19: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

COLOR CONTROLCOLOR CONTROL

Page 20: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

functions.phpadd_theme_support( 'disable-custom-colors' ); add_theme_support( 'editor-color-palette', [ 'name' => 'dark blue', 'color' => '#007fbc', ] );

Page 21: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 22: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

TEST DRIVETEST DRIVE

websiteWordPress Gutenberg PluginFrontenberg

Page 23: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ONE BLOCK, MANY PAGESONE BLOCK, MANY PAGESSHARED BLOCKSSHARED BLOCKS

Page 24: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

BUILD YOURBUILD YOUR OWN BLOCKOWN BLOCK

Page 25: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 26: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

REQUIREMENTSREQUIREMENTSES6+JSXWebpackBabelnpmReact

Page 27: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

REQUIREMENTSREQUIREMENTSES6+JSXWebpackBabelnpmReact

Page 28: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

WP CLIWP CLI$ wp scaffold plugin my-plugin

$ wp scaffold block my-block \ --plugin=my-plugin

$ wp plugin activate my-plugin

Page 29: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php `-- blocks |-- my-block.php `-- my-block |-- editor.css |-- index.js `-- style.css

Page 30: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php (root plugin file) `-- blocks |-- my-block.php `-- my-block |-- editor.css |-- index.js `-- style.css

Page 31: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin.php include( plugin_dir_path( __FILE__ ) . 'blocks/my-block.php' );

Page 32: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 33: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 34: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

Page 35: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 36: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block --> <p class="wp-block-my-plugin-my-block"> Hello from the saved content!</p> <!-- /wp:my-plugin/my-block -->

Page 37: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php `-- blocks |-- my-block.php `-- my-block |-- editor.css |-- index.js `-- style.css

Page 38: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php `-- blocks |-- my-block.php (PHP for block) `-- my-block |-- editor.css |-- index.js `-- style.css

Page 39: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ 'editor_script' => 'myblock-block-editor', 'editor_style' => 'myblock-block-editor', 'style' => 'myblock-block', ] );

Page 40: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ 'editor_script' => 'myblock-block-editor', 'editor_style' => 'myblock-block-editor', 'style' => 'myblock-block', 'render_callback'=> 'my_render_callback', ] );

Page 41: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpfunction my_render_callback( $attributes ) { return sprintf( '<pre><code>%s</code></pre>', 'My rendered output' ); }

Page 42: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

Page 43: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpfunction my_render_callback( $attributes ) { return sprintf( '<pre><code>%s</code></pre>', 'My rendered output' ); }

Page 44: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpfunction my_render_callback( $attributes ) { return sprintf( '<pre><code>%s</code></pre>', esc_html( get_the_author() ) ); }

Page 45: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

[shortcode]

Page 46: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpfunction my_render_callback( $attributes ) { return sprintf( '<pre><code>%s</code></pre>', esc_html( get_the_author() ) ); }

Page 47: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpfunction my_render_callback( $attributes ) { return sprintf( '<pre><code>%s</code></pre>', print_r( $attributes, true ) ); }

Page 48: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

$attributes argument is an empty array

Page 49: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ 'editor_script' => 'myblock-block-editor', 'editor_style' => 'myblock-block-editor', 'style' => 'myblock-block', 'render_callback'=> 'my_render_callback', ] );

Page 50: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ 'editor_script' => 'myblock-block-editor', 'editor_style' => 'myblock-block-editor', 'style' => 'myblock-block', 'render_callback'=> 'my_render_callback', 'attributes' => [ 'val' => [], ], ] );

Page 51: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

Page 52: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 53: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

THE ENDTHE END OF AVOIDING JAVASCRIPTOF AVOIDING JAVASCRIPT

Page 54: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php `-- blocks |-- my-block.php `-- my-block |-- editor.css |-- index.js `-- style.css

Page 55: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

my-plugin |-- my-plugin.php `-- blocks |-- my-block.php `-- my-block |-- editor.css |-- index.js (block JavaScript) `-- style.css

Page 56: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

( function( wp ) { } )( window.wp );

Page 57: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.jsvar el = wp.element.createElement; var __ = wp.i18n.__; var registerBlockType = wp.blocks.registerBlockType;

Page 58: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.js registerBlockType( 'my-plugin/my-block', { title: __( 'My block' ), edit: function( props ) {}, save: function( props ) {} } );

Page 59: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.js

blocks/my-block.php

registerBlockType()

register_block_type()

Page 60: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 61: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.js registerBlockType( 'my-plugin/my-block', { title: __( 'My block' ), edit: function( props ) {}, save: function( props ) {} } );

Page 62: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.js registerBlockType( 'my-plugin/my-block', { title: __( 'My block' ), edit: function( props ) {}, save: function(props) { return null; } } );

Page 63: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block /-->

Page 64: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.js registerBlockType( 'my-plugin/my-block', { title: __( 'My block' ), edit: function( props ) {}, save: function(props) { return null; } } );

Page 65: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

edit: function( props ) { return el( 'p', { className: props.className }, __( 'Hello from the editor!' ) ); },

Page 66: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

edit: function( props ) { return wp.element.createElement( 'p', { className: props.className }, __( 'Hello from the editor!' ) ); },

Page 67: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

edit: function( props ) { return React.createElement( 'p', { className: props.className }, __( 'Hello from the editor!' ) ); },

Page 68: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 69: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <p class="wp-block-my-plugin-my-block"> Hello from the editor! </p>

Page 70: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ReactReact

Page 71: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

return el( 'p', { className: props.className }, __( 'Hello from the editor!' ) );

Page 72: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

return el( wp.components.TextControl, { className: props.className, value: props.attributes.val } );

Page 73: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

return el( wp.components.TextControl, { className: props.className, onChange: function( newVal ) { props.setAttributes( { val: newVal }); }, value: props.attributes.val } );

Page 74: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

IN THE EDITORIN THE EDITOR

Page 75: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ON THE FRONT-ENDON THE FRONT-END

Page 76: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block /-->

Page 77: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block {"val":"Now I have editable content. I editted this."} /-->

Page 78: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

STATIC BLOCKSSTATIC BLOCKSRemove render_callback in PHPModify JavaScript save function

Page 79: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.jssave: function() { return el( 'p', {}, __( 'Hello from the saved content!' ) ); },

Page 80: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.jssave: function( props ) { return el( 'p', {}, __( 'Hello from the saved content!' ) ); },

Page 81: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block/index.jssave: function( props ) { return el( 'p', {}, props.attributes.val ); },

Page 82: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block {"val":"Now I have editable content. I editted this."}--> <p class="wp-block-my-plugin-my-block"> Now I have editable content. I editted this.</p> <!-- /wp:my-plugin/my-block -->

Page 83: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

SOURCE OF TRUTH ?SOURCE OF TRUTH ?'post_content'

<!-- wp:my-plugin/my-block {"val":"Now I have editable content. I editted this."}--> <p class="wp-block-my-plugin-my-block"> Now I have editable content. I editted this.</p> <!-- /wp:my-plugin/my-block -->

Page 84: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 85: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ ... 'attributes' => [ 'val' => [], ], ] );

Page 86: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

blocks/my-block.phpregister_block_type( 'my-plugin/my-block', [ ... 'attributes' => [ 'val' => [ 'selector' => 'p', 'source' => 'text', ], ], ] );

Page 87: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

'post_content' <!-- wp:my-plugin/my-block --> <p class="wp-block-my-plugin-my-block"> Now I have editable content. I editted this.</p> <!-- /wp:my-plugin/my-block -->

Page 88: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 89: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

cake block attributes 'attributes' => [ 'message' => [ 'selector' => 'h3', 'source' => 'text', ], 'name' => [ 'selector' => '.name', 'source' => 'text', ], ],

Page 90: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

SAL FERRARELLOSAL FERRARELLOsalcode.com/phptek

@salcode

Page 91: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack
Page 92: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

ES6+, JSX, BABEL, WEBPACKES6+, JSX, BABEL, WEBPACKBLOCK TEMPLATEBLOCK TEMPLATE

$ create-guten-block

Page 93: GUTENBERG COMES TO WORDPRESS - Iron Code StudioR E S O U R C E S (without ES6+, JSX, Webpack , Babel) Mika Epstein's Bill Erickson's WP CLI generated Ahmad A wais's (ES6+, JSX, Webpack

RESOURCESRESOURCES

(without ES6+, JSX,Webpack, Babel)Mika Epstein's Bill Erickson's

WP CLI generated Ahmad Awais's (ES6+, JSX,Webpack, Babel)

FrontenbergWordPress Gutenberg PluginCake BlockWordPress Custom Editor Block

You Don’t Need a [custom] BlockGetting your theme ready

for GutenbergMy Block Plugin

create-guten-block