diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 2db73e9a20476..b9d370e1a7168 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -422,7 +422,7 @@ function create_initial_post_types() { 'title', 'slug', 'excerpt', - 'editor', + 'editor' => array( 'notes' => true ), 'revisions', 'author', ), @@ -486,7 +486,7 @@ function create_initial_post_types() { 'title', 'slug', 'excerpt', - 'editor', + 'editor' => array( 'notes' => true ), 'revisions', 'author', ), diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 5ae45c67e1044..1891fb9b53540 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -215,6 +215,43 @@ public function test_post_type_supports() { $this->assertFalse( post_type_supports( 'notaposttype', 'notafeature' ) ); } + /** + * Templates and template parts opt in to notes so that the block editor can + * attach them to a template that has been saved to the database. + * + * @ticket 65866 + * + * @dataProvider data_template_post_types_support_notes + * + * @param string $post_type Template post type name. + */ + public function test_template_post_types_support_notes( $post_type ) { + $supports = get_all_post_type_supports( $post_type ); + + $this->assertArrayHasKey( 'editor', $supports, 'The editor feature should be registered.' ); + $this->assertIsArray( $supports['editor'], 'The editor feature should carry arguments.' ); + $this->assertTrue( + array_any( $supports['editor'], static fn( $item ) => ! empty( $item['notes'] ) ), + 'The editor feature should declare notes support.' + ); + $this->assertTrue( + post_type_supports( $post_type, 'editor' ), + 'Editor support should remain enabled.' + ); + } + + /** + * Data provider. + * + * @return array[] + */ + public function data_template_post_types_support_notes() { + return array( + 'template' => array( 'wp_template' ), + 'template part' => array( 'wp_template_part' ), + ); + } + /** * @ticket 21586 * @ticket 41172