read some more…
Reusable blocks are done via a custom post type and i think that answers my question: iam not able to create a custom post from a theme..
so i will revert to just use a block pattern with the *default* content. and leave it open the the user to convert it to a Reusable block.
or is it possible to create a custom post from/by a theme?
sunny greetings
stefan
Your theme could insert a new post of any type on activation. It can insert a reusable block post by simply specifying the correct post type as part of wp_insert_post() parameters.
When someone edits a reusable block, that edit will be applied to all instances of that block anywhere in your site. Is that what you want? If not, I think you might want to use a block pattern instead?
thanks @bcworkz yeah that is what i want..
it is a block-group for a newsletter section…
and i incorporated a *styled-warning-sign* to highlight that all edits will change this on all sites…
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* hacky tweak for reusable blocks editing */
/* based on https://wordpress.org/support/topic/make-it-less-easy-to-edit-reusable-blocks/#post-14525041 */
/* .wp-block:not(.is-reusable) {
border: 1px dashed #ddd;
} */
.block-library-block__reusable-block-container {
background-color: hsl(300, 100%, 50%);
box-shadow: 0 0 3px 3px hsl(300, 100%, 50%);
border: 3px dashed hsl(180, 100%, 50%);
padding:1px;
}
.block-library-block__reusable-block-container > * {
pointer-events: none;
}
/* .wp-block.is-reusable .wp-block:not(.is-reusable) {
} */
.block-library-block__reusable-block-container.is-selected::before,
.block-library-block__reusable-block-container.has-child-selected::before {
content: 'Rusable Block – Be Careful with editing! → this changes all occurrences of the block.';
font-weight: bold;
font-size: 20px;
padding: 1rem;
}
my i think that should work curiosity is often a bit to active 😉
as it is just a one-shot client theme (only this customer will use it..)
for now it is to much additional work.
Thanks for your pointers!!
sunny greetings
stefan