So far, we've built a WordPress block using plain JavaScript which supports custom styles via a stylesheet, and which uses block attributes and the RichText component to allow the user to edit the block content. Next, we will add a block control and an additional attribute to allow the user to edit the block alignment.
2. 2
👋🏽
Welcome!
As you join, please make sure you have your local
development environment ready:
• A local WordPress installation
• A code editor like VSCode or Sublime
• The part 2 block code
• https://github.com/jonathanbossenger/wp-learn-
javascript/releases/download/0.0.3/wp-learn-
javascript.0.0.3.zip
Then, let everyone know in the chat where you’re joining
us from…
Hello!
○ My name is Jonathan Bossenger
○ From Cape Town, South Africa
○ Ex-developer turned code instructor
○ Sponsored contributor at Automattic
○ @jon_bossenger in Twitter
4. Announcements
○ Welcome, and thanks to Leo for co-hosting!
○ We’ll be presenting in focus mode, but please consider enabling your video.
○ You are welcome to ask questions.
○ You are welcome to post questions in the chat, or unmute to ask questions.
5. Announcements
○ Please consider taking the Learn WordPress Learner Survey
• https://learn.wordpress.org/individual-learner-survey/
○ Make sure your local install is ready
• https://github.com/jonathanbossenger/wp-learn-
javascript/releases/download/0.0.3/wp-learn-javascript.0.0.3.zip
○ If I am going too fast, please let me know!
○ We will be posting this session to https://wordpress.tv/ afterwards
○ For more WordPress focused content please visit https://learn.wordpress.org/
6. Learning Outcomes
1. Review of part 2 block code
2. Overview of the Block Toolbar and Settings Sidebar
3. Learn how to add multiple elements to a block
4. Prepare the block code to implement controls
5. Add an Alignment control to the block to manage content alignment
7. Objectives 1
1. Review the current block code
2. Review the Block Toolbar and Settings Sidebar
3. Update the block wrapper
4. Fix the styling based on the update
5. Implement the BlockControls and the AlignmentControl components
6. Add and apply an alignment attribute
7
8. Objectives 2
1. Update the save function to use the alignment
2. Move the control from the toolbar to the sidebar
3. Some refactoring
8