gutenberg-workshop
gutenberg-workshop copied to clipboard
:hammer_and_pick: A Gutenberg Workshop :b:
Description
This plugin adds a different Gutenberg blocks in the Gutenberg editor of your WordPress dashboard.
Features :clipboard:
- One Stop shop for learning Gutenberg
- Gutenbeg Blogs and Video Tutorial Links
- Gutenberg Example Plugins.
Installation :wrench:
-
Download the zipped plugin. Unzip the plugin.
-
Navigate to the Plugins > Add new screen in your WordPress administrative dashboard.
-
Click Add New at the top of the page.
-
Click Upload Plugin at the top of the page.
-
Click Choose File, then find and Upload the downloaded renamed zip file.
-
After the plugin finishes installing, click Activate.
or, Go to your plugin directory from terminal and Clone this repo in wp-content/plugins directory
git clone https://github.com/imranhsayed/gutenberg-workshopAnd then activate it from Plugins screen in your WordPress administrative dashboard. -
That's it!
Configuration ( @wordpress/scripts )
- This plugin uses @wordpress/scripts which installs and sets up webpack and babel config out of the box
- The
@wordpress/scriptsis installed in the root of the project. This is one single plugin that registers many blocks. - By default
@wordpress/packageusessrc/index.jsas entry point andbuild/index.js - However we have also created custom scripts by overriding the defaults.
- Example
npm run build:dynamic-blockwill use thedynamic-block/assets/js/block.jsas entry point and output it todynamic-block/build/main.js - Each directory like
dynamic-blockregister their own block. Only the bundling happens from the root.
Directory Structure
-assets
-css
-js
-block.js
-build
-main.js
-inc
-block-templates
-class-register-block.php
-helpers
-custom-functions.php
-index.php
Scripts
build:dynamic-block: will use thedynamic-block/assets/js/block.jsas entry point and output it todynamic-block/build/main.jsfor productionbuild:dynamic-block-watch: will use thedynamic-block/assets/js/block.jsas entry point and output it todynamic-block/build/main.jsin watch mode for development
Similarly Commands for creating bundle file ( JavasScript file ) for other blocks
-
build:dynamic-block-ssrcreates bundle file for dynamic-block-ssr block -
build:dynamic-block-ssr-watchcreates bundle file for dynamic-block-ssr block in watch mode. -
build:custom-categorycreates bundle file for custom-category block -
build:custom-category-watchcreates bundle file for custom-category block in watch mode.
Dynamic Block Demo :video_camera:

Custom Category Demo :video_camera:

What is included in this plugin ?
- The plugin uses ReactJS & ESNext for creating custom gutenberg block, along with PHP's OOP concept
- It uses Webpack to bundle all of its dependencies into one file index.js
- Has separate stylesheet for front-end & editor.
Blocks Description :clipboard:
-
custom-category Creates a custom catageory
GW Custom Blocksand registers a block under the same category. -
dynamic-block Creates a dynamic block
Latest Posts, that renders content as saved from the edit function in editor. The content that is returned byrender_callback()is displayed on the front end. Here the editor content and front content can be different if you return different content fromedit()in block.js andrender_callback()in php file. -
dynamic-block-ssr Creates a dynamic block and returns the same content both in editor and front end, what is returned by
render_callback(), using<ServerSideRender>. The data that you pass in attributes of<ServerSideRender attributes={{ name: 'Imran' }}>will be available inrender_callback( $attributes )in php. You must define its type in theregister_block_type()
Useful Blogs:
Gutenberg Handbook
Gutenberg Tutorials
- Introduction to Gutenberg
- Create Gutenberg Block in 3 Steps
- Custom Gutenberg Block using @wordpress/scripts
- @wordpress/scripts package features
- Attributes and Components | State
Gutenberg Talks
How to use ?
- Go to WordPress Dashboard > Posts/Pages > Add New > Add block ( + icon ) > Layout Elements > Contact Card
- Now you can add your picture, name, subtitle, description, twitter link, facebook link and email.
- When you publish the post you can see this custom contact card block as a part of your post/page on dashboard as well as on front end.
- This gutenberg block is reusable so you can use it as many times as you want on a post or page to share your contact details.