a working react/php dynamic wordpress block example integrated with the Vite build process

This commit is contained in:
2025-12-10 19:44:32 +00:00
parent b16bd77355
commit 917150bbe6
15 changed files with 247 additions and 34 deletions

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -70,7 +70,7 @@ class Editor
$data['template'] = $this->default_template();
$data['block'] = $block;
echo \Roots\view("blocks.$name.$name", [
echo \Roots\view("acf-blocks.$name.$name", [
'data' => $data,
'block' => $block,
])->render();

View File

@@ -0,0 +1,12 @@
{
"apiVersion": 3,
"name": "badegg/example",
"title": "Example",
"category": "badegg",
"icon": "cover-image",
"description": "This is an example of a custom Wordpress Block created using the offical method.",
"editorScript": "example-editor-script",
"editorStyle": "example-editor-style",
"style": "example-style",
"render": "resources/blocks/example/render.blade.php"
}

View File

@@ -0,0 +1,3 @@
.block-badegg-example-editor {
display: block;
}

View File

@@ -0,0 +1,12 @@
import { registerBlockType } from '@wordpress/blocks';
registerBlockType('badegg/example', {
apiVersion: 3, // optional in JS, primarily in block.json
edit() {
return (
<section className="block-badegg-example">
<h2>Bad Egg Block Example</h2>
</section>
);
},
});

View File

@@ -0,0 +1,3 @@
<section class="block-badegg-example">
<h2>Bad Egg Example Block (Blade)</h2>
</section>

View File

@@ -0,0 +1,3 @@
.block-badegg-hero {
display: block;
}