mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@41980 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -769,9 +769,11 @@ function wp_allow_comment( $commentdata, $avoid_die = false ) {
|
||||
* Filters a comment's approval status before it is set.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 4.9.0 Returning a WP_Error value from the filter will shortcircuit comment insertion and
|
||||
* allow skipping further processing.
|
||||
*
|
||||
* @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'.
|
||||
* @param array $commentdata Comment data.
|
||||
* @param bool|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam' or WP_Error.
|
||||
* @param array $commentdata Comment data.
|
||||
*/
|
||||
$approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
|
||||
return $approved;
|
||||
|
||||
Reference in New Issue
Block a user