Modify WP_JSON_Server to allow authentication

This commit is contained in:
Max Rice 2013-11-03 18:53:35 -05:00
parent a0ddef247d
commit 65f48e8456
1 changed files with 3 additions and 1 deletions

View File

@ -97,8 +97,10 @@ class WP_JSON_Server implements WP_JSON_ResponseHandler {
*/ */
public function check_authentication() { public function check_authentication() {
$user = apply_filters( 'json_check_authentication', null ); $user = apply_filters( 'json_check_authentication', null );
if ( is_a( $user, 'WP_User' ) ) if ( ! is_null( $user ) && ( is_a( $user, 'WP_User' ) || is_wp_error( $user ) ) ) {
wp_set_current_user( $user->ID );
return $user; return $user;
}
if ( !isset( $_SERVER['PHP_AUTH_USER'] ) ) if ( !isset( $_SERVER['PHP_AUTH_USER'] ) )
return; return;