Skip to content

Commit aa57c63

Browse files
author
Keven Lefebvre
committed
Add all ACF's render_callback (like ) to Sage's template() function
1 parent 4880609 commit aa57c63

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sage-acf-gutenberg-blocks.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,20 @@ function sage_blocks_callback($block, $content = '', $is_preview = false, $post_
128128
// Set up the block data
129129
$block['post_id'] = $post_id;
130130
$block['slug'] = $slug;
131-
$block['classes'] = implode(' ', [$block['slug'], $block['className'], 'align' . $block['align']]);
131+
$block['classes'] = implode(' ', [
132+
$block['slug'],
133+
$block['className'],
134+
$is_preview ? 'is-preview' : null,
135+
'align' . $block['align']
136+
]);
132137

133138
// Use Sage's template() function to echo the block and populate it with data
134-
echo \App\template("blocks/${slug}", ['block' => $block]);
139+
echo \App\template("blocks/${slug}", [
140+
'block' => $block,
141+
'content' => $content,
142+
'is_preview' => $is_preview,
143+
'post_id' => $post_id,
144+
]);
135145
}
136146

137147
/**

0 commit comments

Comments
 (0)