Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#53412 new feature request

Consider allowing themes to include block directory block references

Reported by: helen's profile helen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: Cc:


Important note: this is not a plugin dependencies ticket!! But maybe a little bit.

Imagine that you've found a perfect-looking single page theme for your establishment and the screenshot or demo shows a map in a really convenient spot, but then you go to edit that page or template and you have no idea where exactly that map should go. Everything else looks just right thanks to patterns and other core blocks, but that pesky map needs a block from the block directory. How could core help users discover blocks that are recommended/especially styled by a given theme?

In my imagination, this is something like showing a placeholder prompting the editor to install/activate the block and why they would want to do that (or delete the block if they don't need it). But that's just one person's imagination - this would definitely benefit from exploration and positing other relevant scenarios (even/especially ones that would disprove this as a helpful feature).

I believe this could apply to both FSE/block-based themes within template areas as well as all themes with starter content, though it may make sense to narrow the initial support. Also, we may/probably want to support theme demos on .org showing blocks from the block directory to go along with this, if we go this route.

Attachments (1)

missing-block-in-directory.png (566.3 KB) - added by ryelle 3 years ago.

Download all attachments as: .zip

Change History (6)

#1 @youknowriad
3 years ago

I remember related discussions/proposals with @matveb and @ryelle so I'll add them to this discussion.

#2 @knutsp
3 years ago

Nice idea.

This has been a challenge for starter content, and some themes have a "companion" plugin to handle importing and dependencies. Now we get blocks i templates. Let's start with block dependencies for FSE themes - then iterate on the idea.

#3 @ryelle
3 years ago

Right now, if you try to add a pattern that uses a block you don't have, it will use the "missing block" warning to ask you to install it. I'm sure this could be improved, but the basic idea is in core already.

Edit: The block needs to be in the block directory specifically, which means blocks from "collection" plugins (CoBlocks, Jetpack, etc) aren't picked up by this.

Last edited 3 years ago by ryelle (previous) (diff)

#4 @matveb
3 years ago

Indeed! As @ryelle mentions the core of this idea is already in place for blocks that are available in the block directory. The main inconvenient, though, is that most block libraries come in the form of plugin bundles and their blocks are not available standalone. A next step is to figure out a way to make it easy for plugins to make their blocks available in the directory as single blocks while still allowing collections of blocks to exist in some form (a plugin could just indicate what blocks from the directory are part of the bundle using the block namespace, for example). All in all it has to be easy for existing libraries to publish their blocks in the directory without disruption or overhead. Some of that work is described in

Last edited 3 years ago by matveb (previous) (diff)

#5 @matveb
3 years ago

Some more related discussion here around patterns:

Note: See TracTickets for help on using tickets.