Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function create_initial_post_types() {
'title',
'slug',
'excerpt',
'editor',
'editor' => array( 'notes' => true ),
'revisions',
'author',
),
Expand Down Expand Up @@ -486,7 +486,7 @@ function create_initial_post_types() {
'title',
'slug',
'excerpt',
'editor',
'editor' => array( 'notes' => true ),
'revisions',
'author',
),
Expand Down
37 changes: 37 additions & 0 deletions tests/phpunit/tests/post/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading