Skip to content

Commit 4bd79f2

Browse files
authored
Merge pull request #59 from boxuk/taxonomy-registration
[FEATURE] Add Taxonomy Registration to `post-types.json`.
2 parents fd790f9 + ae2f74b commit 4bd79f2

13 files changed

+431
-9
lines changed

schema/post-type.schema.json packages/editor-tools/schema/post-type.schema.json

+392-1
Large diffs are not rendered by default.

packages/editor-tools/src/PostTypes.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public function register_post_types(): void {
4141
return;
4242
}
4343

44+
foreach ( $data['taxonomies'] ?? array() as $name => $args ) {
45+
register_taxonomy( $name, array(), $args );
46+
}
47+
4448
foreach ( $data['post_types'] ?? array() as $name => $args ) {
4549
$args = wp_parse_args(
4650
$args,
@@ -54,7 +58,7 @@ public function register_post_types(): void {
5458
);
5559

5660
register_post_type( $name, $args ); // phpcs:ignore WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral
57-
}
61+
}
5862
}
5963

6064
/**

packages/editor-tools/tests/TestPostTypes.php

+15
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ public function testRegisterPostTypes(): void {
6969
->once()
7070
->with( 'bar', $expected_parsed_json_with_defaults );
7171

72+
\WP_Mock::userFunction( 'register_taxonomy' )
73+
->once()
74+
->with(
75+
'example_category',
76+
array(),
77+
array(
78+
'labels' => array(
79+
'name' => 'TestName',
80+
'singular_name' => 'TestName',
81+
),
82+
'public' => true,
83+
'rewrite' => array( 'slug' => 'example-category' ),
84+
)
85+
);
86+
7287
// Short-circuit the test here as we'll test the blocks-to-template methods separately.
7388
\WP_Mock::userFunction( 'is_admin' )
7489
->twice()

packages/editor-tools/tests/fixtures/PostTypes/post-types.json

+12
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,17 @@
1616
"menu_icon": "dashicons-admin-post",
1717
"taxonomies": [ "category", "post_tag" ]
1818
}
19+
},
20+
"taxonomies": {
21+
"example_category": {
22+
"labels": {
23+
"name": "TestName",
24+
"singular_name": "TestName"
25+
},
26+
"public": true,
27+
"rewrite": {
28+
"slug": "example-category"
29+
}
30+
}
1931
}
2032
}

packages/iconography/config/material-symbols-outlined-filled.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Outlined (Filled)",
44
"name": "boxuk/material-symbols-outlined-filled",
55
"tagName": "span",

packages/iconography/config/material-symbols-outlined.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Outlined",
44
"name": "boxuk/material-symbols-outlined",
55
"tagName": "span",

packages/iconography/config/material-symbols-rounded-filled.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Rounded (Filled)",
44
"name": "boxuk/material-symbols-rounded-filled",
55
"tagName": "span",

packages/iconography/config/material-symbols-rounded.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Rounded",
44
"name": "boxuk/material-symbols-rounded",
55
"tagName": "span",

packages/iconography/config/material-symbols-sharp-filled.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Sharp (Filled)",
44
"name": "boxuk/material-symbols-sharp-filled",
55
"tagName": "span",

packages/iconography/config/material-symbols-sharp.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../schema.json",
2+
"$schema": "../schema/icon-config.json",
33
"title": "Sharp",
44
"name": "boxuk/material-symbols-sharp",
55
"tagName": "span",

packages/iconography/includes/ConfigurationParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function parse_config( string $file ) {
9090
* @return SchemaContract
9191
*/
9292
private function get_schema(): SchemaContract {
93-
return Schema::import( plugin_dir_path( __DIR__ ) . '/schema.json' );
93+
return Schema::import( plugin_dir_path( __DIR__ ) . '/schema/icon-config.json' );
9494
}
9595

9696
/**
File renamed without changes.

0 commit comments

Comments
 (0)