Make WordPress Core


Ignore:
Timestamp:
10/23/2017 10:11:11 PM (6 years ago)
Author:
peterwilsoncc
Message:

Comments: Check if wp_new_comment() returns an error.

Adds checks throughout to allow for wp_new_comment() returning a WP_Error instance.

Updates the docs for the pre_comment_approved filter to include that it can be passed an error.

Props enrico.sorcinelli, ryotsun.
Fixes #39730.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r41940 r41980  
    770770     *
    771771     * @since 2.1.0
    772      *
    773      * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.
    774      * @param array       $commentdata Comment data.
     772     * @since 4.9.0 Returning a WP_Error value from the filter will shortcircuit comment insertion and
     773     *              allow skipping further processing.
     774     *
     775     * @param bool|string|WP_Error $approved    The approval status. Accepts 1, 0, 'spam' or WP_Error.
     776     * @param array                $commentdata Comment data.
    775777     */
    776778    $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
Note: See TracChangeset for help on using the changeset viewer.