* Registers the routes for the objects of the controller.
43
41
*
44
42
* @since 4.7.0
45
* @access public
46
43
*/
47
44
public function register_routes() {
48
45
111
108
* Checks if a given request has access to read comments.
112
109
*
113
110
* @since 4.7.0
114
* @access public
115
111
*
116
112
* @param WP_REST_Request $request Full details about the request.
117
113
* @return WP_Error|bool True if the request has read access, error object otherwise.
164
160
* Retrieves a list of comment items.
165
161
*
166
162
* @since 4.7.0
167
* @access public
168
163
*
169
164
* @param WP_REST_Request $request Full details about the request.
170
165
* @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
339
334
* Checks if a given request has access to read the comment.
340
335
*
341
336
* @since 4.7.0
342
* @access public
343
337
*
344
338
* @param WP_REST_Request $request Full details about the request.
345
339
* @return WP_Error|bool True if the request has read access for the item, error object otherwise.
371
365
* Retrieves a comment.
372
366
*
373
367
* @since 4.7.0
374
* @access public
375
368
*
376
369
* @param WP_REST_Request $request Full details about the request.
377
370
* @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
392
385
* Checks if a given request has access to create a comment.
393
386
*
394
387
* @since 4.7.0
395
* @access public
396
388
*
397
389
* @param WP_REST_Request $request Full details about the request.
398
390
* @return WP_Error|bool True if the request has access to create items, error object otherwise.
480
472
* Creates a comment.
481
473
*
482
474
* @since 4.7.0
483
* @access public
484
475
*
485
476
* @param WP_REST_Request $request Full details about the request.
486
477
* @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
648
639
* Checks if a given REST request has access to update a comment.
649
640
*
650
641
* @since 4.7.0
651
* @access public
652
642
*
653
643
* @param WP_REST_Request $request Full details about the request.
654
644
* @return WP_Error|bool True if the request has access to update the item, error object otherwise.
670
660
* Updates a comment.
671
661
*
672
662
* @since 4.7.0
673
* @access public
674
663
*
675
664
* @param WP_REST_Request $request Full details about the request.
676
665
* @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
767
756
* Checks if a given request has access to delete a comment.
768
757
*
769
758
* @since 4.7.0
770
* @access public
771
759
*
772
760
* @param WP_REST_Request $request Full details about the request.
773
761
* @return WP_Error|bool True if the request has access to delete the item, error object otherwise.
788
776
* Deletes a comment.
789
777
*
790
778
* @since 4.7.0
791
* @access public
792
779
*
793
780
* @param WP_REST_Request $request Full details about the request.
794
781
* @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
823
810
} else {
824
811
// If this type doesn't support trashing, error out.
825
812
if ( ! $supports_trash ) {
826
return new WP_Error( 'rest_trash_not_supported', __( 'The comment does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
813
/* translators: %s: force=true */
814
return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
827
815
}
828
816
829
817
if ( 'trash' === $comment->comment_approved ) {
857
845
* Prepares a single comment output for response.
858
846
*
859
847
* @since 4.7.0
860
* @access public
861
848
*
862
849
* @param WP_Comment $comment Comment object.
863
850
* @param WP_REST_Request $request Request object.
923
910
* Prepares links for the request.
924
911
*
925
912
* @since 4.7.0
926
* @access protected
927
913
*
928
914
* @param WP_Comment $comment Comment object.
929
915
* @return array Links for the given comment.
992
978
* Prepends internal property prefix to query parameters to match our response fields.
993
979
*
994
980
* @since 4.7.0
995
* @access protected
996
981
*
997
982
* @param string $query_param Query parameter.
998
983
* @return string The normalized query parameter.
1025
1010
* Checks comment_approved to set comment status for single comment output.