Skip to content

Commit 6b0c127

Browse files
authored
Merge pull request #196 from boxuk/fix/editor-tools/post-type-registration
[FIX] Ensure taxonomies are registered if no custom post-types are.
2 parents f6c64d4 + e1afc2f commit 6b0c127

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@
461461
"^[a-zA-Z0-9_]+$": {
462462
"type": "object",
463463
"properties": {
464+
"post_types": {
465+
"type": "array",
466+
"description": "An array of post type identifiers that will be registered for the taxonomy. Post types can be registered later with register_post_type() or register_post_type_for_object_type().",
467+
"items": {
468+
"type": "string",
469+
"pattern": "^[a-zA-Z0-9_]+$",
470+
"description": "Post type identifier"
471+
}
472+
},
464473
"labels": {
465474
"type": "object",
466475
"description": "An array of labels for this taxonomy. If not set, taxonomy labels are inherited from post type labels. See [get_taxonomy_labels()](https://developer.wordpress.org/reference/functions/get_taxonomy_labels/) for a full list of supported labels.",

packages/editor-tools/src/PostTypes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function register_post_types(): void {
4242
}
4343

4444
foreach ( $data['taxonomies'] ?? array() as $name => $args ) {
45-
register_taxonomy( $name, array(), $args );
45+
register_taxonomy( $name, $args['post_types'] ?? 'post', $args );
4646
}
4747

4848
foreach ( $data['post_types'] ?? array() as $name => $args ) {

packages/editor-tools/tests/TestPostTypes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testRegisterPostTypes(): void {
7373
->once()
7474
->with(
7575
'example_category',
76-
array(),
76+
'post',
7777
array(
7878
'labels' => array(
7979
'name' => 'TestName',

0 commit comments

Comments
 (0)