equal
deleted
inserted
replaced
2 /** |
2 /** |
3 * Used to set up all core blocks used with the block editor. |
3 * Used to set up all core blocks used with the block editor. |
4 * |
4 * |
5 * @package WordPress |
5 * @package WordPress |
6 */ |
6 */ |
|
7 |
|
8 // Don't load directly. |
|
9 if ( ! defined( 'ABSPATH' ) ) { |
|
10 die( '-1' ); |
|
11 } |
7 |
12 |
8 define( 'BLOCKS_PATH', ABSPATH . WPINC . '/blocks/' ); |
13 define( 'BLOCKS_PATH', ABSPATH . WPINC . '/blocks/' ); |
9 |
14 |
10 // Include files required for core blocks registration. |
15 // Include files required for core blocks registration. |
11 require BLOCKS_PATH . 'legacy-widget.php'; |
16 require BLOCKS_PATH . 'legacy-widget.php'; |
18 * While {@see register_block_style_handle()} is typically used for that, the way it is |
23 * While {@see register_block_style_handle()} is typically used for that, the way it is |
19 * implemented is inefficient for core block styles. Registering those style handles here |
24 * implemented is inefficient for core block styles. Registering those style handles here |
20 * avoids unnecessary logic and filesystem lookups in the other function. |
25 * avoids unnecessary logic and filesystem lookups in the other function. |
21 * |
26 * |
22 * @since 6.3.0 |
27 * @since 6.3.0 |
23 * |
|
24 * @global string $wp_version The WordPress version string. |
|
25 */ |
28 */ |
26 function register_core_block_style_handles() { |
29 function register_core_block_style_handles() { |
27 global $wp_version; |
30 $wp_version = wp_get_wp_version(); |
28 |
31 |
29 if ( ! wp_should_load_separate_core_block_assets() ) { |
32 if ( ! wp_should_load_separate_core_block_assets() ) { |
30 return; |
33 return; |
31 } |
34 } |
32 |
35 |
153 BLOCKS_PATH . $block_folder |
156 BLOCKS_PATH . $block_folder |
154 ); |
157 ); |
155 } |
158 } |
156 } |
159 } |
157 add_action( 'init', 'register_core_block_types_from_metadata' ); |
160 add_action( 'init', 'register_core_block_types_from_metadata' ); |
|
161 |
|
162 /** |
|
163 * Registers the core block metadata collection. |
|
164 * |
|
165 * This function is hooked into the 'init' action with a priority of 9, |
|
166 * ensuring that the core block metadata is registered before the regular |
|
167 * block initialization that happens at priority 10. |
|
168 * |
|
169 * @since 6.7.0 |
|
170 */ |
|
171 function wp_register_core_block_metadata_collection() { |
|
172 wp_register_block_metadata_collection( |
|
173 BLOCKS_PATH, |
|
174 BLOCKS_PATH . 'blocks-json.php' |
|
175 ); |
|
176 } |
|
177 add_action( 'init', 'wp_register_core_block_metadata_collection', 9 ); |