From 5aa74cd2d5af50c3259c9cf33d1ba6f7ff568032 Mon Sep 17 00:00:00 2001 From: Luigi Date: Wed, 3 May 2023 11:47:04 +0200 Subject: [PATCH] use 'enqueue_block_assets' is available --- src/Assets/AssetDataRegistry.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Assets/AssetDataRegistry.php b/src/Assets/AssetDataRegistry.php index a72a81c960d..760be8ce6e4 100644 --- a/src/Assets/AssetDataRegistry.php +++ b/src/Assets/AssetDataRegistry.php @@ -66,7 +66,8 @@ public function __construct( Api $asset_api ) { * Hook into WP asset registration for enqueueing asset data. */ protected function init() { - add_action( 'init', array( $this, 'register_data_script' ) ); + // @todo: Remove this check when WordPress 6.3 is the minimum supported version. + add_action( has_action( 'enqueue_block_assets' ) ? 'enqueue_block_assets' : 'init', array( $this, 'register_data_script' ) ); add_action( 'wp_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 ); add_action( 'admin_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 ); }