From 7cb049fd3b3cc63b3e8f1bd3e8af7fb5a730a307 Mon Sep 17 00:00:00 2001 From: danlapteacru Date: Fri, 4 Apr 2025 10:23:45 +0300 Subject: [PATCH 1/2] Block:assets() export the ->block property to a separate variable and passing it into the hook --- src/Block.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Block.php b/src/Block.php index 662a8cf7..e57c0088 100644 --- a/src/Block.php +++ b/src/Block.php @@ -782,8 +782,9 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w ->filter(fn ($value) => filled($value) && $value !== ';'); if (! is_admin() && method_exists($this, 'assets')) { - add_action('enqueue_block_assets', function () { - $this->assets((array) $this->block ?? []); + $blockInstance = (array) ($this->block ?? []); + add_action('enqueue_block_assets', function () use ($blockInstance): void { + $this->assets($blockInstance); }); } From 01f53eb46ab9486857891bd878058f541431ff12 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 4 Apr 2025 11:29:55 -0500 Subject: [PATCH 2/2] Update Block.php --- src/Block.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Block.php b/src/Block.php index e57c0088..566cac0d 100644 --- a/src/Block.php +++ b/src/Block.php @@ -782,9 +782,10 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w ->filter(fn ($value) => filled($value) && $value !== ';'); if (! is_admin() && method_exists($this, 'assets')) { - $blockInstance = (array) ($this->block ?? []); - add_action('enqueue_block_assets', function () use ($blockInstance): void { - $this->assets($blockInstance); + $instance = (array) ($this->block ?? []); + + add_action('enqueue_block_assets', function () use ($instance): void { + $this->assets($instance); }); }