Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a3c2f01
Comments: Add a REST API endpoint for comment types.
adamsilverstein Jun 24, 2026
c0d63b6
Comments: Add tests for the comment types REST API endpoint.
adamsilverstein Jun 24, 2026
7daed7e
Comments: Expand REST comment-types test coverage for HEAD requests.
adamsilverstein Jun 25, 2026
e6490e1
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Jul 11, 2026
274dcb3
Comments: Clarify scope and tighten the comment types REST controller.
adamsilverstein Jul 11, 2026
e06ca77
Coding Standards: Remove a double blank line in WP_Comment_Type::set_…
adamsilverstein Jul 11, 2026
22c3975
REST API: Regenerate the wp-api.js fixture for the comment-types routes.
adamsilverstein Jul 11, 2026
0997e29
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Aug 12, 2026
af523df
REST API: Restore the application passwords block in the wp-api.js fi…
adamsilverstein Aug 12, 2026
0bd58bb
REST API: Settle the comment types endpoint's remaining divergences.
adamsilverstein Aug 12, 2026
0543a34
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Aug 23, 2026
c118907
REST API: Stamp the comment types endpoint for 7.2.0 and tidy the con…
adamsilverstein Aug 23, 2026
82a3036
Docs: Note that internal does not keep a comment type out of REST dis…
adamsilverstein Aug 23, 2026
33c7a46
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Nov 8, 2026
5e427e1
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Nov 8, 2026
0adfc69
Comments: Tighten comment type REST documentation.
adamsilverstein Nov 8, 2026
f9dcad2
Tests: Type the comment types REST tests and cover `reaction`.
adamsilverstein Nov 8, 2026
1aacc86
Merge branch 'feature/register-comment-type' into feature/rest-commen…
adamsilverstein Nov 8, 2026
0030413
Docs: Mark the new comment type APIs as @since 7.3.0.
adamsilverstein Nov 8, 2026
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
27 changes: 22 additions & 5 deletions src/wp-includes/class-wp-comment-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ final class WP_Comment_Type {
*/
public $internal = false;

/**
* Whether to expose this comment type in the `/wp/v2/comment-types` endpoint.
*
* Does not affect access to comments of this type via `/wp/v2/comments`.
* Default is the value of $public.
*
* @since 7.3.0
* @var bool
*/
public $show_in_rest;

/**
* Whether this comment type is a native or "built-in" comment type.
*
Expand Down Expand Up @@ -172,15 +183,21 @@ public function set_props( $args ): void {

// No 'label' default, so get_comment_type_labels() can fall back to the default name.
$defaults = array(
'labels' => array(),
'description' => '',
'public' => true,
'internal' => false,
'_builtin' => false,
'labels' => array(),
'description' => '',
'public' => true,
'internal' => false,
'show_in_rest' => null,
'_builtin' => false,
);

$args = array_merge( $defaults, $args );

// Unlike WP_Post_Type, there is no back-compat reason to default this to false.
if ( null === $args['show_in_rest'] ) {
$args['show_in_rest'] = $args['public'];
}

$args['name'] = $this->name;

// The hierarchical label slots are null, so a true value would null every default label.
Expand Down
38 changes: 21 additions & 17 deletions src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,27 @@ function create_initial_comment_types(): void {
* @param array|string $args {
* Optional. Array or string of arguments for registering a comment type. Default empty array.
*
* @type string $label Name of the comment type. Usually plural.
* Default is the value of $labels['name'].
* @type string[] $labels An array of labels for this comment type. If not set, the
* default comment labels are used. See get_comment_type_labels()
* for a full list of supported labels.
* @type string $description A short descriptive summary of what the comment type is.
* Default empty.
* @type bool $public Whether the comment type is intended for use publicly either via
* the admin interface or by front-end users. Core does not
* currently act on this argument. Default true.
* @type bool $internal Whether the comment type is for internal use only. Internal
* types are meant to be excluded from comment queries and counts
* by default. Core does not currently act on this argument.
* Default false.
* @type bool $_builtin For internal core use only. Marks the type as native to
* WordPress, which blocks it from being re-registered or
* unregistered. Default false.
* @type string $label Name of the comment type. Usually plural.
* Default is the value of $labels['name'].
* @type string[] $labels An array of labels for this comment type. If not set, the
* default comment labels are used. See get_comment_type_labels()
* for a full list of supported labels.
* @type string $description A short descriptive summary of what the comment type is.
* Default empty.
* @type bool $public Whether the comment type is intended for use publicly either via
* the admin interface or by front-end users. Core does not
* currently act on this argument. Default true.
* @type bool $internal Whether the comment type is for internal use only. Internal
* types are meant to be excluded from comment queries and counts
* by default. Core does not currently act on this argument.
* Default false.
* @type bool $show_in_rest Whether to expose this comment type in the REST API comment types
* discovery endpoint (`/wp/v2/comment-types`). Does not affect
* access to comments of this type via `/wp/v2/comments`.
* Default is the value of $public.
* @type bool $_builtin For internal core use only. Marks the type as native to
* WordPress, which blocks it from being re-registered or
* unregistered. Default false.
* }
* @return WP_Comment_Type|WP_Error The registered comment type object on success,
* WP_Error object on failure.
Expand Down
4 changes: 4 additions & 0 deletions src/wp-includes/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ function create_initial_rest_routes() {
$controller = new WP_REST_Comments_Controller();
$controller->register_routes();

// Comment types.
$controller = new WP_REST_Comment_Types_Controller();
$controller->register_routes();

$search_handlers = array(
new WP_REST_Post_Search_Handler(),
new WP_REST_Term_Search_Handler(),
Expand Down
Loading