Make WordPress Core

Ticket #39578: 39578.2.diff

File 39578.2.diff, 1.3 KB (added by rmccue, 7 years ago)

Add phpDoc

  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

     
    552552                 * Filters a comment before it is inserted via the REST API.
    553553                 *
    554554                 * Allows modification of the comment right before it is inserted via wp_insert_comment().
     555                 * Returning a WP_Error value from the filter will shortcircuit insertion and allow
     556                 * skipping further processing.
    555557                 *
    556558                 * @since 4.7.0
     559                 * @since 4.8.0 $prepared_comment can now be a WP_Error to shortcircuit insertion.
    557560                 *
    558                  * @param array           $prepared_comment The prepared comment data for wp_insert_comment().
     561                 * @param array|WP_Error  $prepared_comment The prepared comment data for wp_insert_comment().
    559562                 * @param WP_REST_Request $request          Request used to insert the comment.
    560563                 */
    561564                $prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
     565                if ( is_wp_error( $prepared_comment ) ) {
     566                        return $prepared_comment;
     567                }
    562568
    563569                $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
    564570