[wp-trac] [WordPress Trac] #44639: Allow multiple comment types on class-wp-rest-comments-controller.php
WordPress Trac
noreply at wordpress.org
Wed Jul 25 10:43:40 UTC 2018
#44639: Allow multiple comment types on class-wp-rest-comments-controller.php
--------------------------+-----------------------------
Reporter: apermo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I want to create an entry/comment for the Liveblogging Plugin
https://de.wordpress.org/plugins/liveblog/ with the rest api.
The Liveblog Plugin uses comments with a special comment_type `liveblog`
and a special comment_approved `liveblog`
The rest API `WP_REST_Comments_Controller::create_item()` has a hardcoded
check for a comment type
{{{
// Do not allow comments to be created with a non-default type.
if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) {
return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot
create a comment with that type.' ), array( 'status' => 400 ) );
}
}}}
1. Why does the comment endpoint except `type` if it only accepts a single
value?
2. Can you at least add a filter here, maybe like:
{{{
$allowed_comment_types = apply_filter(
'fancy_allowed_comment_types_filter_name', [ 'comment' ] );
// Do not allow comments to be created with a non-default type.
if ( ! empty( $request['type'] ) && ! in_array( $request['type'],
allowed_comment_types ) ) {
return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot
create a comment with that type.' ), array( 'status' => 400 ) );
}
}}}
Extending the whole class, while copying a single function of nearly 150
lines to change a single if statement seems a bit over the top.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44639>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list