Closed bph closed 2 months ago
... making sure this comment by @zzap doesn't get lost
@troychaplin please ping me when draft is ready for the first review. Thanks
Here are a few links to get you started, @troychaplin
Tips and guidelines for writers How to contribute
and in there you also find Google Doc template to get you started.. Notes on creating and formatting a Google Doc #242
Just a quick follow up @bph and @zzap, it's nearly done. Was away for a week on vacation, hoping to have the first draft done in the next couple of days.
@troychaplin - nice to see you over here, we've chatted on Ryan's livestream a bit. Here are a number of links and resources, and some GitHub issues that this could help to address.
https://github.com/WordPress/block-development-examples/issues/80
- A plugin containing multiple blocks (showing file structure / build configuration etc.)
https://wordpress.slack.com/archives/C03RL47B3S8/p1709818696592279
Specifically for the prerequisites part. Like, you are reading an advanced article. We assume you know about X, Y, Z. Where X would be wp-scripts, Y building a simple plugin, etc.
create-block-plugin
- AdvancedCan be used to scaffold multiple blocks (via CLI) - maybe a follow-up post.
Good to hear from you again @flexseth. Thanks for these links, I'll go over them once I get my first draft written and see how they relate.
@zzap The first draft of my article is ready for review -- https://docs.google.com/document/d/1vlCwOmoea4HdqkVlNACNTWuVKFC7KIs3mg4cIIva_JQ/edit?usp=sharing
This is a partial review. I added a bookmark for myself to know where to continue.
First of all, thank you so much for writing this tutorial, @troychaplin. I'm having a lot of fun following it. Here are my suggestions so far:
1. The local environment. I have doubts about this section. I use Docker on some projects, but not on some other. My default setup is Apache/mySQL/PHP, installed directly in OS because Linux is OS of WordPress hosted servers and I like to have the similar(ish) environment.
Following the tutorial, I went to one of my local installs that I use for testing, fun and break. It's just a regular WordPress inside my Apache. I ran the block scaffolding script inside of it, easy-peasy, all good. Then I saw you want to use wp-env. Oki doki, moved the plugin dir outside of my www folder, ran the env install script and, shoot, my node version is wrong. So I went to install new node version and switch to it. Then I had to shut down Apache and mySQL and run Docker Desktop. And then everything was working.
Now, I am used to this. I do this every time I switch between enterprise and smaller clients. But some people might have never used Docker or wp-env. And, honestly, they probably don't have to. But that's besides the point. The point is that local environment is NOT important for this tutorial. Blocks work in any.
Personally I would lose the whole section about environment. Just mention what you use and why, link to its documentation and say that it doesn't matter what you use to be able to follow the tutorial. Because it doesn't and it's just a roadblock for people who don't use Docker.
2. Render callback For dynamic block, I'd suggest using the render property for block.json rather than render callback, as it is more clean and up to date.
3. Best practices I left a couple of comments for applying correct textdomain and function prefixes, as we want to always apply WordPress official best practices in every code example.
The rest of the review will follow soon. Thanks again :heart:
@troychaplin - I included some suggestions in your draft. Thanks for putting this together.
Thanks for the feedback @zzap, I have made all suggested changes. The section about wp-env has been completely removed, your feedback made perfect sense. I've also updated code related to the render property, and have also taken the suggestions from @flexseth into consideration and have added more code examples in all areas of the basic setup section of the article.
I plan on going over the next advanced configuration section this evening to make similar modifications and make sure the way examples are presented is done consistently.
@zzap forgot to comment to say I'm finished with additional revisions to the content you haven't reviewed yet. Cheers!
Hey @troychaplin , thank you so much for accepting suggestions.
I completed the review and found it very interesting and informative. It has a nice arch, bringing the reader from a known place to new knowledge. I love the additional settings and custom webpack config section because that's not something you do every day, so when you do it, you become an expert, but tomorrow, that expertise is gone and you're a clueless noobie when you have to do it again in a few months :joy:
I'm left with two things on my mind after reading it:
This is not a request or suggestion, but if you have an opinion on the second item, I'd love to hear it, and maybe include it in one sentence in the article.
Thank you again.
@bph this is ready for second review.
Thanks @zzap
I am not familiar with the Interactivity API just yet, I did not know it leverages view.js. I do have a very simple work around for this, but it's not idea so I didn't want to put it out there in the article, but I do it for a couple of project. In the register_block_type function you can point to the block.json file in the src folder. The issue with the view.js is that when you add webpack and compile it this way no individual JS files get placed in each block folder in the build directory which is needed with the way the view.js file is referenced in the block.json.
I would be interested in hearing if you do dive in to this one and find a solution. I may have a look at some point too, I've never had the need to this point.
As for the copy paste, I think there's an addition I could make here. Just a little side note about being able to run npx @wordpress/create-block@latest block-two --no-plugin
directly in the src folder. Or maybe I'll do a quick revision and have the reader run that command and just get rid of the larger instructions with more manual work to get setup.
@bph could you please give me until tomorrow to make a few updates before the doc gets a second review?
@troychaplin I just got back from vacation and I am almost through my backlog. I put the review of your post on my to-do list for Monday (9/2) Have a great weekend!
For what it's worth, I like your npx @wordpress/create-block@latest block-two --no-plugin
approach.
Hey @bph and @zzap, I've updated the basic setup section of the docs to change the approach creating blocks, added a little note about how this change impact text-domain in each block.json.
@troychaplin I started the 2nd review, but ran out of steam. I will continue it tomorrow. I already left a few comments following along with your code example and had opinions. I also would urge you to read through the Tips and guidelines for writers, especially the part about avoiding the "we" and replacing it with "You" as that where most of my edits are coming from.
Ignore my bookmark to find the spot where I stopped. More tomorrow.
Thank you @bph, I just went through all of your feedback. I also went through the content after your bookmark to change the we's to you's, etc
I finished my review. You are almost there! 🎉
Most corrections are coming from the need to have the code examples adhere to the WordPress Coding Standards.
I also offered suggestions for linking to other dev blog articles, and some rewording.
somewhere I went astray and I didn't get to see the updated changes, so a few more screenshot for a set of instructions, would be wonderful.
It also would be helpful if you could provide the finished plugin on GitHub on the /wptrainingteam
organization. I just sent you an invitation so you can upload your example plugin there. (upload it as a public repo, pls.)
Once you are through this round of updates, you can start moving it to the dev blog. I also sent you and invite to your wp.org email address. You would need to click on the link to accept the invitation. I'll share the pre- and post publish checklist in the next comment.
Thanks @bph, I've gone through the checklist and have everything ready.
Here's some copy for a social post:
Learn how to build a multi-block plugin by registering several static and dynamic blocks all in one plugin
The public preview URL is https://developer.wordpress.org/news/?p=4208&preview=1&_ppp=4fd288d9fe
@troychaplin I went through the post on the blog and made quite a few adjustments.
(Don't take this as criticism of your work, that I publish my changes here. I am logging my changes so we can create formatting standards for the blog and future new writers have it a bit easier. )
I modified your headers and subheaders. We only use two-level heading (h2 and h3). That way we can avoid duplicate subheaders and too deep leveling.
This shortened the Table of Contents quite a bit and is less intimidating. I also move the TOC below your introductory remarked. They then don't need any headers either.
One sentence doesn't need a sub header.
Where it was necessary for readability to leave them I converted them to paragraphs with large and bold fonts so they stand out.
Featured image: I also uploaded a different feature image. It will be pulled into all the social sharing later.
We don't have standard instructions for what a good feature image would make either. But we have been working on it.
I also changed your note about text domain to a notice block, so it wouldn't need a sub header either.
The post is now scheduled for September 17 at 2:45 am UTC
Thanks for all the feedback and help @bph, much appreciated. I don't see this as criticism, but rather guidance on how to follow the process which I need to learn.
We are all on a learning path to get better and better. Thanks for your great work on this article!
Article has been published at https://developer.wordpress.org/news/2024/09/17/how-to-build-a-multi-block-plugin/#comment-12125
Schedule for Oct 2
Discussed in https://github.com/WordPress/developer-blog-content/discussions/289