Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_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
597            * Fires after a comment is created or updated via the REST API.
598            *
599            * @since 4.7.0
600            *
601            * @param WP_Comment      $comment  Inserted or updated comment object.
602            * @param WP_REST_Request $request  Request object.
603            * @param bool            $creating True when creating a comment, false
604            *                                  when updating.
605            */
606           do_action( 'rest_insert_comment', $comment, $request, true );
607
608           $schema = $this->get_item_schema();
609
610           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
611                $meta_update = $this->meta->update_value( $request['meta'], $comment_id );
612
613                if ( is_wp_error( $meta_update ) ) {
614                     return $meta_update;
615                }
 
Line Code
732
733                if ( isset( $request['status'] ) ) {
734                     $this->handle_status_param( $request['status'], $id );
735                }
736           }
737
738           $comment = get_comment( $id );
739
740           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
741           do_action( 'rest_insert_comment', $comment, $request, false );
742
743           $schema = $this->get_item_schema();
744
745           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
746                $meta_update = $this->meta->update_value( $request['meta'], $id );
747
748                if ( is_wp_error( $meta_update ) ) {
749                     return $meta_update;
750                }