use standard block.json method with ACF blocks

This commit is contained in:
2025-12-15 18:10:06 +00:00
parent d47b3fdb07
commit f0d8cb2065
22 changed files with 752 additions and 403 deletions

View File

@@ -6,12 +6,6 @@
"description": "An example block powered by ACF",
"keywords": ["acf", "demo"],
"editorScript": "acfdemo-editor-script",
"editorStyle": "acfdemo-editor-style",
"script": "acfdemo-script",
"style": "acfdemo-style",
"viewScript": "acfdemo-view-script",
"acf": {
"mode": "preview",
"validate": "false",

View File

@@ -1,3 +1,10 @@
<section class="wp-block-{{ $block['slug'] }}">
<h2>ACF Example</h2>
</section>
@extends('layouts.block-acf', [
'block' => $block,
'is_preview' => $is_preview,
'context' => $context,
'knockout' => true,
])
@section('block-content')
{!! the_field('content') !!}
@overwrite

View File

@@ -10,7 +10,7 @@ registerBlockType(metadata.name, {
const blockProps = useBlockProps();
return (
<section { ...blockProps }>
<div { ...blockProps }>
<div className="container">
<InnerBlocks
allowedBlocks={ allowedBlocks }
@@ -24,16 +24,16 @@ registerBlockType(metadata.name, {
}
/>
</div>
</section>
</div>
);
},
save() {
return (
<section { ...useBlockProps.save() }>
<div { ...useBlockProps.save() }>
<div className="container">
<InnerBlocks.Content />
</div>
</section>
</div>
)
}
});

View File

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