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
613            * Fires after a comment is created or updated via the REST API.
614            *
615            * @since 4.7.0
616            *
617            * @param WP_Comment      $comment  Inserted or updated comment object.
618            * @param WP_REST_Request $request  Request object.
619            * @param bool            $creating True when creating a comment, false
620            *                                  when updating.
621            */
622           do_action( 'rest_insert_comment', $comment, $request, true );
623
624           $schema = $this->get_item_schema();
625
626           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
627                $meta_update = $this->meta->update_value( $request['meta'], $comment_id );
628
629                if ( is_wp_error( $meta_update ) ) {
630                     return $meta_update;
631                }
 
Line Code
747
748                if ( isset( $request['status'] ) ) {
749                     $this->handle_status_param( $request['status'], $id );
750                }
751           }
752
753           $comment = get_comment( $id );
754
755           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
756           do_action( 'rest_insert_comment', $comment, $request, false );
757
758           $schema = $this->get_item_schema();
759
760           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
761                $meta_update = $this->meta->update_value( $request['meta'], $id );
762
763                if ( is_wp_error( $meta_update ) ) {
764                     return $meta_update;
765                }