From 0525269f79c3e0d73ab3662c0917c56e3a83b46d Mon Sep 17 00:00:00 2001 From: Elias Kautto Date: Fri, 25 Oct 2024 12:52:03 +0300 Subject: [PATCH] Add global variable for current block during render_acf_block --- CHANGELOG.md | 4 ++++ inc/template-tags/acf-blocks.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b194a66e..0c85e29d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Unreleased + +* Add global variable for current block during `render_acf_block` (T-17629) + ### 9.5.0rc: 2024-09-18 * Rewrite: allowed_block_types - Change logic for allowed blocks: 'none', 'all', 'all-core-blocks', 'all-acf-blocks', Fixes #226 (thanks @villekujansuu) diff --git a/inc/template-tags/acf-blocks.php b/inc/template-tags/acf-blocks.php index 4163e8a0..38a7e291 100644 --- a/inc/template-tags/acf-blocks.php +++ b/inc/template-tags/acf-blocks.php @@ -32,6 +32,9 @@ function render_acf_block( $block, $content = '', $is_preview = false, $post_id $cache_key = "post_{$post_id}_{$block['id']}|{$content_hash}"; $cache_key = apply_filters( 'air_acf_block_cache_key', $cache_key, $block_slug, $post_id ); + global $air_light_current_block; + $air_light_current_block = $block; + // Get block contents if ( ! $block_cache_enabled ) { $cache_bypass_reason = $is_preview || 'development' === wp_get_environment_type() ? 'preview/development' : 'cache setting';