diff --git a/includes/class-indieauth-authorize.php b/includes/class-indieauth-authorize.php index e58d260..2beeb29 100644 --- a/includes/class-indieauth-authorize.php +++ b/includes/class-indieauth-authorize.php @@ -84,26 +84,25 @@ public function get_indieauth_response( $response ) { * Attached to the rest_authentication_errors filter. Passes through existing * errors registered on the filter. * - * @param WP_Error|null Current error, or null. + * @param WP_Error|null|true Current error, null or true. * - * @return WP_Error|null Error if one is set, otherwise null. + * @return WP_Error|null|true Error if one is set, unchanged otherwise. */ public function rest_authentication_errors( $error = null ) { if ( is_user_logged_in() ) { // Another OAuth2 plugin successfully authenticated. - return null; - } - - if ( ! empty( $error ) ) { return $error; } + if ( is_wp_error( $this->error ) ) { return $this->error; } + if ( is_oauth_error( $this->error ) ) { return $this->error->to_wp_error(); } - return null; + + return $error; } /**