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.

Built from https://develop.svn.wordpress.org/trunk@39487


git-svn-id: http://core.svn.wordpress.org/trunk@39427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
James Nylen 2016-12-04 19:30:41 +00:00
parent 5ffc6a7fe0
commit 87eedbd2f7
2 changed files with 2 additions and 2 deletions

View File

@ -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 ) );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-39486';
$wp_version = '4.8-alpha-39487';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.