Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* A custom REST server for Gutenberg.
*
* @package gutenberg
* @since 6.8.0
* @since 6.9.0
*/

// Create a new class that extends WP_REST_Comments_Controller
class Gutenberg_REST_Comment_Controller extends WP_REST_Comments_Controller {
class Gutenberg_REST_Comment_Controller_6_9 extends WP_REST_Comments_Controller {

public function get_items_permissions_check( $request ) {
$is_note = ! empty( $request['type'] ) && 'note' === $request['type'];
$is_edit_context = ! empty( $request['context'] ) && 'edit' === $request['context'];
$is_note = 'note' === $request['type'];
$is_edit_context = 'edit' === $request['context'];

if ( ! empty( $request['post'] ) ) {
foreach ( (array) $request['post'] as $post_id ) {
Expand Down Expand Up @@ -305,7 +305,7 @@ public function create_item( $request ) {
return $prepared_comment;
}

$prepared_comment['comment_type'] = empty( $request['type'] ) ? 'comment' : $request['type'];
$prepared_comment['comment_type'] = $request['type'];

if ( ! isset( $prepared_comment['comment_content'] ) ) {
$prepared_comment['comment_content'] = '';
Expand Down Expand Up @@ -504,11 +504,11 @@ private function check_post_type_supports_notes( $post_type ) {
return false;
}
foreach ( $supports['editor'] as $item ) {
if ( is_array( $item ) && isset( $item['notes'] ) && true === $item['notes'] ) {
if ( ! empty( $item['notes'] ) ) {
return true;
}
}
return true;
return false;
}

/**
Expand Down Expand Up @@ -577,7 +577,7 @@ protected function check_is_comment_content_allowed( $prepared_comment ) {
add_action(
'rest_api_init',
function () {
$controller = new Gutenberg_REST_Comment_Controller();
$controller = new Gutenberg_REST_Comment_Controller_6_9();
$controller->register_routes();
}
);
Loading
Loading