wp/wp-includes/blocks/index.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-includes/blocks/index.php	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/blocks/index.php	Fri Sep 05 18:52:52 2025 +0200
@@ -5,6 +5,11 @@
  * @package WordPress
  */
 
+// Don't load directly.
+if ( ! defined( 'ABSPATH' ) ) {
+	die( '-1' );
+}
+
 define( 'BLOCKS_PATH', ABSPATH . WPINC . '/blocks/' );
 
 // Include files required for core blocks registration.
@@ -20,11 +25,9 @@
  * avoids unnecessary logic and filesystem lookups in the other function.
  *
  * @since 6.3.0
- *
- * @global string $wp_version The WordPress version string.
  */
 function register_core_block_style_handles() {
-	global $wp_version;
+	$wp_version = wp_get_wp_version();
 
 	if ( ! wp_should_load_separate_core_block_assets() ) {
 		return;
@@ -155,3 +158,20 @@
 	}
 }
 add_action( 'init', 'register_core_block_types_from_metadata' );
+
+/**
+ * Registers the core block metadata collection.
+ *
+ * This function is hooked into the 'init' action with a priority of 9,
+ * ensuring that the core block metadata is registered before the regular
+ * block initialization that happens at priority 10.
+ *
+ * @since 6.7.0
+ */
+function wp_register_core_block_metadata_collection() {
+	wp_register_block_metadata_collection(
+		BLOCKS_PATH,
+		BLOCKS_PATH . 'blocks-json.php'
+	);
+}
+add_action( 'init', 'wp_register_core_block_metadata_collection', 9 );