Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_after_insert_comment

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
747            * Fires completely after a comment is created or updated via the REST API.
748            *
749            * @since 5.0.0
750            *
751            * @param WP_Comment      $comment  Inserted or updated comment object.
752            * @param WP_REST_Request $request  Request object.
753            * @param bool            $creating True when creating a comment, false
754            *                                  when updating.
755            */
756           do_action( 'rest_after_insert_comment', $comment, $request, true );
757
758           $response = $this->prepare_item_for_response( $comment, $request );
759           $response = rest_ensure_response( $response );
760
761           $response->set_status( 201 );
762           $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) );
763
764           return $response;
765      }
 
Line Code
901           $fields_update = $this->update_additional_fields_for_object( $comment, $request );
902
903           if ( is_wp_error( $fields_update ) ) {
904                return $fields_update;
905           }
906
907           $request->set_param( 'context', 'edit' );
908
909           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
910           do_action( 'rest_after_insert_comment', $comment, $request, false );
911
912           $response = $this->prepare_item_for_response( $comment, $request );
913
914           return rest_ensure_response( $response );
915      }
916
917      /**
918       * Checks if a given request has access to delete a comment.
919       *