-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
One appealing aspect of blocks is that they lend themselves to become reusable pieces. This will be key for theme customization (think menus, headers, footers, etc) down the road, but it could already be useful in the context of posts, and it may be wise to get the foundation in place.
Examples
- Say you create a gallery for a post that you also want to display in a page, and you want them to be in sync.
- Or you create a custom HTML block for a quick bio that you want to repeat in other posts and you want to only have to update it once.
- Or you insert a quote you want to be a testimonial repeated in different pages... etc.
WordPress at the moment treats galleries like this—you insert the shortcode and it is evaluated at render time. But it would be nice if any block could be turned into such a reusable entity in a way that is clear to the user and not a surprise.
Proposal
- Every static block has the ability (from the inspector) to become reusable or shared.
- This stores the block content and name in a specific post type reserved for blocks.
- Once a block becomes reusable they are listed in the inserter as "shared blocks" or similar.
- When inserting a shared block the markup is just an HTML comment reference to the block, like dynamic widgets are at the moment.
Shared blocks can get a different outline color:
And when updating them the user can be presented with a confirm dialog asking if they want to update across all posts or convert the current instance back to a static block.
Saving flow can be tricky, because we could issue saves through the API separately from saving a post, since the post only has a reference to the content of the block. This is more of a UX question, though, that will affect blocks like "navigation menu" down the road.
cc @aduth @nb @westonruter @jasmussen @melchoyce @iseulde @youknowriad @nylen and anyone interested.