Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,16 @@ public function registerBlockType(): void
$block['attributes'] ?? []
);

// Store render_template (class name) instead of render_callback (closure)
// in the ACF block-types store. This ensures compatibility with both ACF Pro
// and SCF: SCF reads render_callback from the store and would call the closure
// directly, bypassing the acf_block_render_template action that acf-composer
// listens on. By setting render_callback to false and render_template to the
// block class name, SCF falls through to the render_template path and fires
// the action. ACF Pro ignores the store values, so this is backwards-compatible.
$block['render_callback'] = false;
$block['render_template'] = static::class;

acf_get_store('block-types')->set($block['name'], $block);

$block['render_callback'] = 'acf_render_block_callback';
Expand Down