$prepared_comment =
$this->
prepare_item_for_database( $request );
if ( is_wp_error( $prepared_comment ) ) { return $prepared_comment;
} $prepared_comment['comment_type'
] = 'comment';
if ( !
isset( $prepared_comment['comment_content'
] ) ) { $prepared_comment['comment_content'
] = '';
} if ( !
$this->
check_is_comment_content_allowed( $prepared_comment ) ) { return new WP_Error( 'rest_comment_content_invalid',
__( 'Invalid comment content.'
),
array
( 'status' => 400
) );
} // Setting remaining values before wp_insert_comment so we can use wp_allow_comment().
if ( !
isset( $prepared_comment['comment_date_gmt'
] ) ) { $prepared_comment['comment_date_gmt'
] =
current_time( 'mysql', true
);
}