Gutenberg Blocks for WordPress and React Developers
- Description
- Curriculum
- FAQ
- Reviews
Recently WordPress decided to change their old WYSIWYG editor into a new ReactJS based block editor known as ‘Gutenberg’. Gutenberg also known as the block editor is based on blocks. So your post will be composed of some blocks and each block will have a purpose. You can have a block that displays a button or an image or some text and so on.
In this course you will learn everything you need to know in order to create custom blocks for the block editor. We will start by a simple block and then we will create some more complex blocks.
In order to gain the most out of this course you need to have WordPress theme/plugin development knowledge. Javascript knowledge is required for this course. You should be familiar with basic JavaScript concepts and preferably the recent ES6+ versions. ReactJS knowledge is also required for this course. So concepts like component state, hooks and basic react concepts should not be new to you. Also advanced concepts like higher order component knowledge would be ideal however it will be discussed briefly in the course. Redux knowledge is also ideal. Not all blocks will require using redux, however in some blocks we will use redux heavily. So it would be ideal if you are familiar with redux concepts like stores, actions, reducers and so on.
The course content will go as follows:
-
First and before any coding we will discuss some design guidelines that you should follow when designing a block.
-
We will take a look on how your Gutenberg post is saved in your database and what happens behind the scenes in order to construct your ReactJS based UI from the content saved in the database.
-
In Section 2, we will create a WordPress plugin. Inside this plugin we will register out first Gutenberg block. We will also use a tool provided by WordPress called wp-scripts in order to process JS and CSS files in this plugin. We will also integrate tools like ESLint, Prettier, Stylelint and Husky for an improved development workflow.
-
In section 3, we will take a quick look on some stuff that you can do in your WordPress theme that will allow you to modify/add some features in the block editor.
-
In section 4 we will create a simple block. However in this simple block we will learn a lot about what we can do in a block.
-
In section 5 we will use our knowledge to create a more complex block with some advanced features. These features include how to add blocks inside of other blocks, how to handle images and many more.
-
Section 6 will be about creating dynamic blocks. So blocks can be static or in other words only generate some static HTML. But also they can be dynamic for example they can fetch something from the database.
-
Section 7 will discover more about the redux-like data stores in the block editor. We will see how to use the existing data stores and also create our own store.
-
Section 8 we will see different ways that we can follow in order to manage metadata in Gutenberg. We will manage metadata using a block. And we will also learn how to create a custom sidebar plugin and manage metadata in this sidebar.
-
In the final section we are going to discuss various topics like: context, patterns, templates, formatting API, filters and internationalization.
-
1Before Watching the Course
-
2Installing a Starter WordPress Theme
In this lecture we will install and activate a theme that we will use through out the course. You can use your own theme if you like since most of the work will be in a plugin. Additionally we are going to take a look at the gutenberg repository on github. This will be useful incase you ever needed to look at the source code of existing core blocks.
-
3The Block Editor Interface
In this lecture we will explore the structure of the new block editor page. We will see what every area in the editor is called and its usage.
-
4The Block Interface & Design Guidelines
In this lecture we will take a look at the structure of the blocks in the new editor. We will explore the UI elements of the block and their purpose. We will also discuss some design guidelines that we should follow when designing a block.
-
5How is a Post in the Block Editor Saved in the Database
You might be wondering how a post in the block editor is saved in the database? Do we save 2 representations for the post? One for the frontend and one for the editor? In this lecture we will answer this question.
-
6How the Visual Editor is Reconstructed From Plain HTML
In this lecture we will discover how the visual editor is reconstructed by parsing the post’s HTML content.
-
7A Brief Introduction to the Redux-like Data Stores in the Block Editor
In this lecture we will briefly take a look on how data is managed in a redux-like fashion in the block editor.
-
8The Post State Array in Action
In this lecture we will revisit the diagram that explains how do we reconstruct the visual editor from the HTML. But we can get a better understanding now that we can see the post state array and other data stored in the redux-like stores.
-
9Creating a New WordPress Plugin
In this lecture we will just create a simple WordPress plugin in order to start working on our first block.
-
10Registering our First Block
In this lecture we will see how to register a new block in the block editor. We will see how to define all the necessary information and also define the edit and save functions.
-
11Returning React Components in the Edit & Save Functions
Let's now instead of returning a simple string; return a react component in the edit and save functions.
-
12Compiling ESNext to ES5 with wp-scripts
In this lecture we are going to migrate our code from ES5 to ESNext. And then we are going to use w-scripts; which is a tool provided by WordPress in order to compile our code back to ES5 so that it can run on any browser.
-
13Compiling & Loading SASS Files
In this lecture we will learn how to properly load CSS or SASS files for our blocks
-
14Generating a Block with @wordpress/create-block
Let's in this lecture discover an easier way to create blocks. And that way is command line tool called @wordpress/create-block.
-
15Configuring ESLint & Prettier for JavaScript Files
In this lecture we are going to configure ESLint and Prettier so that they work consistently with the wp-scripts commands.
-
16Configuring Stylelint for Linting our SCSS Files
Let's now displaying linter errors in VS Code and also modify the format script so that it fixes SCSS Files as well.
-
17Adding a Pre-commit Git Hook with Husky
Let's now add a pre-commit hook so that we can check that our code does not contain any JavaScript or SCSS problems before committing files to Git.
-
18Adding Custom Styles to the Block Editor
In this lecture we will discover how can we apply styles to our editor page in order to make it look similar to the actual front-end.
-
19Adding Support for Align Wide and Align Full
Let's implement another block editor feature in our theme. And this one adds extra alignment types to our blocks; align wide and align full.
-
20Adding Custom Colour Pallets
In this lecture we will learn how to customize the colour pallets that appear in the block editor for customizing colours in some blocks.
-
21Adding Custom Font Sizes
In this lecture we will learn how to add custom font sizes in the block editor.
-
22Custom Sizing & Custom Units
In this lecture we are going to unlock two more features in the block editor; custom sizing and custom units.
-
23Creating a New Clone from our Boilerplate Properly
Let's clone the boilerplate that we created earlier in order to create a new bock. This will be a simple process however there are a few things that we need to consider.
-
24Editing the Boilerplate's Metadata
Let's now adjust our boilerplate's metadata to show information about the text box block.
-
25Customizing the Block's Icon
Let's see how can we customize the icon by adding an SVG instead of a dashicon and also changing the colours.
-
26The RichText Component
Le't now make our text editable by using the RichText component.
-
27Adding Options in the Block Toolbar Using BlockControls
In this lecture we are going to see how the BlockControls component is used in order to add buttons and menus in the block toolbar.
-
28The AlignmentToolbar Component
In this lecture we are going to add alignment options to our block. But instead of adding a toolbar with three buttons ourselves, we will use a ready to use component provided by WordPress.
-
29Adding Options in the Sidebar Using InspectorControls
Let's see how can we add options in the editor's sidebar. And also discover some of the input components that WordPress provides us.
-
30Adding an Option to Change the Background and Text Colours
Let's see how can we use the ColorPallet input to change the background color of our block. We will also introduce a new component called PanelColorSettings that offers more features when it comes to editing colours.
-
31Using the withColors Higher Order Component
Let's take a look at a higher order component called withColors. This HOC can be used to provide us more information about the chosen colors so that we can avoid using inline styling as much as we can.
-
32Changing the Background and Text Colours using Block Supports
In this lecture we are going to redo what we have done in the previous couple of lectures but in a much simpler way.
-
33Adding an Option to Change the Block's Padding
In this lecture we will take a look at the BoxControl component and how to add spacing support in our block. We will also see how can we visualize our spacing in the editor.
-
34Adding an Option for toggling Box Shadow
In this lecture we are going to add a new option where we can turn on and off box shadow in out text box. We will also add an additional option to control the opacity of the shadow.
-
35Adding Support for Different Style Options
In this lecture we will take a look at a built-in feature that allows you to have multiple styles for your block.
-
36Examples & Variations
Let's see how can we add a preview example for our blocks. And also take a quick look on a feature called variation that allows us to add multiple variations of the block with the same code.
-
37Transforming Blocks into Other Blocks
Let's take a look on how to transform our block into another block. And also how to transform other blocks into our block.
-
38Adding Deprecated Versions for our Block
Let's see how can we handle the case where we would like to update something in our code; and at the same time avoid breaking the blocks for our users.
-
39Adding Deprecated Versions for our Block (Part. 2)
Let's try another example of deprecated blocks. In this one we are going to see how to handle the case were we need to update an attribute name.
-
40Block Overview
Let's have a quick overview on what we are going to be creating in this section.
-
41Initializing a New Plugin for Our Block
Let's do our block initialization by cloning our boilerplate repository.
-
42Editing the Boilerplate's Metadata
Let's change the boilerplate metadata so that it matches our new team members block.
-
43Using InnerBlocks to Create a Nested Block
In this lecture we are going to see how the InnerBlocks component can be used to create nested blocks.
-
44Registering the Team Member Block
Let's register a new block "Team Member" that will be used as a child to our team members block.
-
45Creating the edit and save functions for the name and bio
Let's start our block with a simple part. In this lecture we are going to create the edit and save functions and add the functionality to edit and save the title and the bio attributes.
-
46Adding templates for our team members
Let's see how can we add a template that will be used by default whenever a new team members block is inserted.
-
47Adding an option for changing the number of columns
Let's add a new attribute that will be used to control the number of columns and add an input in the sidebar to control it.
-
48Styling the Front-end of the Block
Let's now use our columns attribute and style our block to reflect the number of columns in the front-end.
-
49Adding the Editor Styles for our Block
Let's now work on styling our columns i the editor page.
-
50Introducing the ImagePlaceholder Component
Let's take a look at the ImagePlaceholder component that we will use in order to upload images.
-
51Storing & Displaying the Team Member Image
Let's now add some attributes to store the image that we get from the MediaPlaceholder component and then display this image in our block.
-
52Handiling Inserting an Image from an External URL
Now that we are able to upload images, let's see how to handle inserting external URL images.
-
53Displaying Image Related Errors
Let's now handle displaying image related errors by using a higher order component called withNotices.
-
54Displaying the Image in the Save Function (Front-end)
Now that we are adding and manipulating our image in the editor page, let's work on displaying the image in the front-end.
-
55Blob URL Edge Case & Memory Optimization
Let's take a look at a case that our users could run into while uploading an image. We will also do some memory optimization to avoid memory leaks that blob URL's could cause.
-
56Replacing the Image with a Toolbar Option
Let's add a button in the block toolbar to replace the selected image.
-
57Removing the Image with a Toolbar Option
Let's add a button in the block toolbar to remove the selected image.
-
58Adding a Sidebar Option to Modify the Alt Text of the Image
Let's allow for modifying the alt text of the image by adding a textarea in the sidebar.
-
59Adding an Option for Changing the Image Size
Let's now see how to access our data stroe in our block component in order to display image size options.
-
60Focusing on the Name Input After Selecting an Image
Let's add a small yet useful feature. In this lecture we are going to see how can we focus on the team member name input after selecting an image.
-
61Adding Alignment Options for the Team Members Block
In this quick lecture we are going to discover how to support the align wide and align full options in our block.
-
62Adding & Displaying an Attribute for the Social Links
Let's see how can add a new type of attributes in order to store our social media links. And then let's also display this new attribute in the edit function.
-
63Styling the Social Links for the Editor Page
Now that we have added our markup, let's do some styling!
-
64Selected Link State & Styling
Let's add a way to store our currently selected link and also add some styling to indicate our selected link.
-
65Adding New Items to the Social Links
Let's work on the functionality for adding new items to our social links array.
-
66The Save Function Markup for the Social Links
Let's now work on the markup for the front-end part of the social media links.
-
67Extracting the Social Links Array from the HTML to Improve Efficiency
In this lecture we are going to improve our block's output size by extracting the social links array from the HTML markup instead of storing it in the block delimiter.
-
68Adding the Markup for the Edit Link Form
Let's now work on editing the social links. And let's start by adding the markup for our edit form.
-
69Editing the Social Media Links & Icons
Now that we have our edit link form markup, let's work on the functionality for this form.
-
70Removing Social Links
Now that we are able to add and edit social links, let's finally add a function that will remove the currently selected link.
-
71Making our Social Links Sortable (Part. 1)
Let's now do our final task. Let's use a plugin that will allow us to make our social media links sortable so that we can re-order them.
-
72Making our Social Links Sortable (Part. 2)
Now that we have successfully created a dummy sortable list. Let's now move our old static list to use the sortable list features.
-
73Adding an Example for the Block Preview
Let's add an example to our block so that a preview will be available in the editor.
-
74Adding Transformations for the Team Members Block
Let's add a useful feature to our block. In this lecture we are going to allow galleries and images blocks to be transformed into our Team Members block.
-
75Introduction to Dynamic Blocks
Let's take a quick overview on what are dynamic blocks and when do we need them.
-
76Initializing our Latest Posts Block
Let's do our block initialization by cloning our boilerplate repository.
-
77Editing the Boilerplate's Metadata
Let's change the boilerplate metadata so that it matches our latest posts block.
-
78Displaying Dynamic Content in the Front-end
Let's now use the render callback php function in order to display dynamic content in our front-end.
-
79Displaying the Latest Posts in the Frond-end Using PHP
Let's now write our PHP loop in order to display our block's front-end content dynamically.
-
80Preparing Our Data for the Editor Loop
Let's now see how can we access our data stores in order to fetch the latest posts using JavaScript
-
81Displaying the Latest Posts in the Editor
Let's now replicate our PHP loop but this time using JS and React.
-
82Styling the Posts in the Editor and Front-end
Let's add some simple styling to our block.
-
83Adding Options for Number of Posts and Featured Image
Let's add a couple of options in the sidebar for controlling the number of posts and displaying the featured image.
-
84Adding an Option for Changing the Order of the Posts
Let's add one more option that will enable us to control the order and orderby options for our posts.
-
85Filtering Posts by Categories
Let's add our final feature which is filtering the posts by multiple categories.
-
86Quick Note!
-
87Creating a New Plugin Boilerplate for the Block Editor
Let's create a new template for a plugin and add JS and CSS files that are only enqueued in the block editor.
-
88Integrating wp-scripts in our Boilerplate
Let's install wp-scripts in our boilerplate so that we can compile and minify our assets and more.