Modify WP_JSON_Server to allow authentication
This commit is contained in:
parent
a0ddef247d
commit
65f48e8456
|
@ -97,8 +97,10 @@ class WP_JSON_Server implements WP_JSON_ResponseHandler {
|
|||
*/
|
||||
public function check_authentication() {
|
||||
$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;
|
||||
}
|
||||
|
||||
if ( !isset( $_SERVER['PHP_AUTH_USER'] ) )
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue