Skip to content

Commit 3a58280

Browse files
authored
🩹 Pass current $block instance to the asset hook (Fixes #331) (#332)
1 parent c634e44 commit 3a58280

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Block.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,10 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w
782782
->filter(fn ($value) => filled($value) && $value !== ';');
783783

784784
if (! is_admin() && method_exists($this, 'assets')) {
785-
add_action('enqueue_block_assets', function () {
786-
$this->assets((array) $this->block ?? []);
785+
$instance = (array) ($this->block ?? []);
786+
787+
add_action('enqueue_block_assets', function () use ($instance): void {
788+
$this->assets($instance);
787789
});
788790
}
789791

0 commit comments

Comments
 (0)