From ae130d30a7f25f6035dd4a89d8c8a754ab0a3a72 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 12 Aug 2026 17:19:39 -0700 Subject: [PATCH 1/2] Editor: Allow notes on templates and template parts. Notes are gated on the editor.notes post type feature. Templates and template parts declare a plain editor feature, so the REST comments controller refuses notes for them and the block editor hides its notes UI. Declare the feature as an array for both post types, matching post and page, which leaves post_type_supports() unchanged. Notes attach to templates that exist as posts, so user-created and customized templates gain notes while theme-provided template files are unaffected. Permissions need no new code: both post types map their primitive capabilities to edit_theme_options, so the edit_post meta cap the comments controller checks already resolves correctly. --- src/wp-includes/post.php | 4 ++-- tests/phpunit/tests/post/types.php | 35 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) 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..87db97f1ef1bf 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -215,6 +215,41 @@ 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. + * + * @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 From 607c1a1ad34bb1e339512dc7abec6d0abf61b7b1 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 12 Aug 2026 19:52:27 -0700 Subject: [PATCH 2/2] Editor: Reference the Trac ticket on the template notes test. --- tests/phpunit/tests/post/types.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 87db97f1ef1bf..1891fb9b53540 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -219,6 +219,8 @@ public function test_post_type_supports() { * 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.