-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·46 lines (43 loc) · 1.23 KB
/
index.php
File metadata and controls
executable file
·46 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Add custom block category to default categories.
*
* @param array[] $block_categories Block categories.
* @param WP_Block_Editor_Context $block_editor_context Block Editor context.
*
* @return array
*/
function wordpress_blocks_starter_block_categories( $block_categories, $block_editor_context ) {
/*
if ( 'post' !== $block_editor_context->post->post_type ) {
return $block_categories;
}
*/
return array_merge(
$block_categories,
array(
array(
'slug' => 'theme-blocks',
'title' => esc_html__( 'Theme Blocks', 'my-theme' ),
),
)
);
}
add_filter( 'block_categories_all', 'wordpress_blocks_starter_block_categories', 10, 2 );
/**
* Enqueue Theme-Blocks: Backend.
*
* @link https://developer.wordpress.org/reference/functions/register_block_type/
*
* @return void
*/
function wordpress_blocks_starter_auto_register_block_types() {
if ( file_exists( __DIR__ . '/build/' ) ) {
$block_json_files = glob( __DIR__ . '/build/*/block.json' );
// Autoregister all blocks found in the `build/blocks` folder.
foreach ( $block_json_files as $filename ) {
register_block_type( dirname( $filename ) );
}
}
}
add_action( 'init', 'wordpress_blocks_starter_auto_register_block_types' );