Skip to content

Conversation

@fabiankaegy
Copy link
Member

This pull request adds full compatibility with the new WordPress 6.9+ Block Notes feature while the "disable comments" option is enabled. It ensures that Block Notes (which use a different comment type) continue to function for editorial collaboration, even when traditional comments are disabled. Additionally, a new filter allows developers to specify which comment types should bypass the disable comments feature. Several code changes improve how comment queries and the frontend handle these exceptions.

WordPress 6.9+ Block Notes compatibility:

  • Block Notes (comment type note) are now allowed and work as expected even when comments are disabled, both in the editor and on the frontend. [1] [2]
  • Documentation updated to explain Block Notes compatibility and clarify that disabling comments does not affect Block Notes, which are only visible in the editor.

Extensibility for allowed comment types:

  • Added a new filter, tenup_experience_disable_comments_allowed_types, allowing plugins to specify additional comment types that should remain functional when comments are disabled. [1] [2]

Bug fixes and improved filtering:

  • The logic for hiding comments on the frontend and short-circuiting comment queries now properly checks comment types, ensuring only traditional comments are blocked while allowed types (like Block Notes) are preserved.

Documentation updates:

  • Updated CHANGELOG.md and README.md to document the Block Notes compatibility, new filter, and related changes. [1] [2] [3]

Closes #189

When the disable comments feature is enabled, Block Notes (introduced in
WordPress 6.9) now continue to function correctly. Block Notes are stored
as WP_Comments with a comment_type of 'note' and are used for collaborative
feedback within the block editor.

Changes:
- Add get_allowed_comment_types() helper method to centralize allowed types
- Update filter_comments_pre_query() to check comment type before short-circuiting
- Update disable_comments_hide_existing_comments() to preserve Block Notes
- Fix method signatures to match WordPress filter parameter expectations
- Add comprehensive inline documentation with references to WP 6.9 dev notes

New filter:
- tenup_experience_disable_comments_allowed_types: Allows extending the list
  of comment types that bypass the disable comments feature

This ensures editorial teams can use Block Notes for collaboration while
keeping traditional comments disabled for site visitors.

Fixes compatibility with WordPress 6.9+
See: https://make.wordpress.org/core/2025/11/15/notes-feature-in-wordpress-6-9/
@fabiankaegy fabiankaegy requested a review from Copilot December 17, 2025 14:26
@fabiankaegy fabiankaegy self-assigned this Dec 17, 2025
@fabiankaegy fabiankaegy added the bug Something isn't working label Dec 17, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds compatibility for WordPress 6.9+ Block Notes feature with the existing "disable comments" functionality. The implementation ensures that Block Notes (comment type note) continue to work for editorial collaboration even when traditional comments are disabled site-wide.

Key Changes:

  • Introduced a new get_allowed_comment_types() method that returns comment types that should bypass the disable comments feature, with note included by default
  • Modified comment filtering logic to preserve allowed comment types while blocking traditional comments
  • Added a new filter tenup_experience_disable_comments_allowed_types for extensibility

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
includes/classes/Comments/Comments.php Core implementation: adds allowed comment types logic and updates comment query/display filters to preserve Block Notes
README.md Documents the Block Notes compatibility and the new extensibility filter with usage examples
CHANGELOG.md Documents the new feature and bug fixes for the unreleased version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


#### WordPress 6.9+ Block Notes Compatibility

As of version 1.17.0, the disable comments feature is fully compatible with Block Notes introduced in WordPress 6.9. Block Notes are a collaborative feedback feature that allows teams to leave contextual comments on blocks within the editor.
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number mentioned here (1.17.0) is inconsistent with the @SInCE tags in the code which reference 1.12.0. Please ensure the version number is accurate and consistent across all documentation.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@darylldoyle darylldoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiankaegy this is a great first pass. I've left some comments, but not tested anything at this time.


#### WordPress 6.9+ Block Notes Compatibility

As of version 1.17.0, the disable comments feature is fully compatible with Block Notes introduced in WordPress 6.9. Block Notes are a collaborative feedback feature that allows teams to leave contextual comments on blocks within the editor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version will actually be 1.18.0 following semver 🙂

Suggested change
As of version 1.17.0, the disable comments feature is fully compatible with Block Notes introduced in WordPress 6.9. Block Notes are a collaborative feedback feature that allows teams to leave contextual comments on blocks within the editor.
As of version 1.18.0, the disable comments feature is fully compatible with Block Notes introduced in WordPress 6.9. Block Notes are a collaborative feedback feature that allows teams to leave contextual comments on blocks within the editor.

Comment on lines +356 to 368
if ( is_a( $query, '\WP_Comment_Query' ) ) {
$comment_type = $query->query_vars['type'] ?? '';

// Allow certain comment types (like Block Notes) to pass through.
if ( in_array( $comment_type, $this->get_allowed_comment_types(), true ) ) {
return $comment_data; // Return null to allow the query to proceed.
}

// Short-circuit count queries for traditional comments.
if ( $query->query_vars['count'] ) {
return 0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot made a valid point here, the type param can be an array, so we should handle it in a way that allows that. This should update your code to handle it gracefully.

I guess one question I have is; if we have a query with the type of ['note', 'comment'] this will let it work as-is. Should we instead clobber any non-allowlisted comment types? So ['note', 'comment'] would become ['note']?

That would ensure that we don't accidentally leak other comment types in queries, but also since I'm not close to this feature, I don't know if it will break anything.

Suggested change
if ( is_a( $query, '\WP_Comment_Query' ) ) {
$comment_type = $query->query_vars['type'] ?? '';
// Allow certain comment types (like Block Notes) to pass through.
if ( in_array( $comment_type, $this->get_allowed_comment_types(), true ) ) {
return $comment_data; // Return null to allow the query to proceed.
}
// Short-circuit count queries for traditional comments.
if ( $query->query_vars['count'] ) {
return 0;
}
}
// Only handle WP_Comment_Query instances.
if ( ! is_a( $query, '\WP_Comment_Query' ) ) {
return array();
}
$allowed_types = $this->get_allowed_comment_types();
$requested_types = $query->query_vars['type'] ?? '';
// Normalise "type" to an array.
if ( '' === $requested_types || null === $requested_types ) {
$requested_types = array();
} elseif ( ! is_array( $requested_types ) ) {
$requested_types = array( $requested_types );
}
// Does this query include any allowed comment types?
$has_allowed_type = ! empty( array_intersect( $requested_types, $allowed_types ) );
// Allow queries that involve any of the allowed types to run as normal.
if ( $has_allowed_type ) {
return $comment_data;
}
// If this is a count query, return 0 instead of letting WP run the full query.
if ( ! empty( $query->query_vars['count'] ) ) {
return 0;
}

*
* @param array $allowed_types Array of comment type strings.
*/
return apply_filters( 'tenup_experience_disable_comments_allowed_types', $allowed_types );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference here is to ensure an array is always returned for better type safety.

Suggested change
return apply_filters( 'tenup_experience_disable_comments_allowed_types', $allowed_types );
$allowed_types = apply_filters( 'tenup_experience_disable_comments_allowed_types', $allowed_types );
return is_array( $allowed_types ) ? $allowed_types : array();

@darylldoyle darylldoyle added this to the 1.18.0 milestone Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block Notes Compatibility

2 participants