PluginProbe
Gutenberg / 5.9.0
Gutenberg v5.9.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / blocks.php

blocks.php in Gutenberg 5.9.0, at lib/blocks.php

48 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Block registration functions.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Substitutes the implementation of a core-registered block type, if exists,
10 * with the built result from the plugin.
11 */
12 function gutenberg_reregister_core_block_types() {
13 // Blocks directory may not exist if working from a fresh clone.
14 $blocks_dir = dirname( __FILE__ ) . '/../build/block-library/blocks/';
15 if ( ! file_exists( $blocks_dir ) ) {
16 return;
17 }
18
19 $block_names = array(
20 'archives.php' => 'core/archives',
21 'block.php' => 'core/block',
22 'calendar.php' => 'core/calendar',
23 'categories.php' => 'core/categories',
24 'latest-comments.php' => 'core/latest-comments',
25 'latest-posts.php' => 'core/latest-posts',
26 'legacy-widget.php' => 'core/legacy-widget',
27 'rss.php' => 'core/rss',
28 'shortcode.php' => 'core/shortcode',
29 'search.php' => 'core/search',
30 'tag-cloud.php' => 'core/tag-cloud',
31 );
32
33 $registry = WP_Block_Type_Registry::get_instance();
34
35 foreach ( $block_names as $file => $block_name ) {
36 if ( ! file_exists( $blocks_dir . $file ) ) {
37 return;
38 }
39
40 if ( $registry->is_registered( $block_name ) ) {
41 $registry->unregister( $block_name );
42 }
43
44 require $blocks_dir . $file;
45 }
46 }
47 add_action( 'init', 'gutenberg_reregister_core_block_types' );
48