WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
Line | Code |
---|---|
581 | * Returning a WP_Error value from the filter will shortcircuit insertion and allow |
582 | * skipping further processing. |
583 | * |
584 | * @since 4.7.0 |
585 | * @since 4.8.0 `$prepared_comment` can now be a WP_Error to shortcircuit insertion. |
586 | * |
587 | * @param array|WP_Error $prepared_comment The prepared comment data for wp_insert_comment(). |
588 | * @param WP_REST_Request $request Request used to insert the comment. |
589 | */ |
590 | $prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request ); |
591 | if ( is_wp_error( $prepared_comment ) ) { |
592 | return $prepared_comment; |
593 | } |
594 |
|
595 | $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) ); |
596 |
|
597 | if ( ! $comment_id ) { |
598 | return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) ); |
599 | } |