mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
REST API: Treat any falsy value as false in 'rest_allow_anonymous_comments'.
Extend the check in 'rest_allow_anonymous_comments' to accept any falsy value (previously this was an explicit check for `false`). One possible failure case is that a plugin developer forgets to include a return value for some code path in their callback for this filter, leading to a value of `null` which is currently treated like `true`. Props joehoyle, jnylen0. Fixes #39010. git-svn-id: https://develop.svn.wordpress.org/trunk@39487 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -392,7 +392,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
* response.
|
||||
*/
|
||||
$allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
|
||||
if ( false === $allow_anonymous ) {
|
||||
if ( ! $allow_anonymous ) {
|
||||
return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user