diff --git a/class-auth.php b/class-auth.php index 3ec988d..87bc6a9 100644 --- a/class-auth.php +++ b/class-auth.php @@ -372,6 +372,10 @@ public function is_error_response( $response ) { * @return WP_REST_Response | Array Returns WP_REST_Response or token's $payload. */ public function validate_token( $return_response = true ) { + global $l10n; + + $has_l10n = isset( $l10n[ 'jwt-auth' ] ); + /** * Looking for the HTTP_AUTHORIZATION header, if not present just * return the user. @@ -390,7 +394,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_no_auth_header', - 'message' => __( 'Authorization header not found.', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'Authorization header not found.', 'jwt-auth' ) : 'Authorization header not found.', 'data' => array(), ), 401 @@ -409,7 +413,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_bad_auth_header', - 'message' => __( 'Authorization header malformed.', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'Authorization header malformed.', 'jwt-auth' ) : 'Authorization header malformed.', 'data' => array(), ), 401 @@ -425,7 +429,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_bad_config', - 'message' => __( 'JWT is not configured properly.', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'JWT is not configured properly.', 'jwt-auth' ) : 'JWT is not configured properly.', 'data' => array(), ), 401 @@ -445,7 +449,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_bad_iss', - 'message' => __( 'The iss do not match with this server.', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'The iss do not match with this server.', 'jwt-auth' ) : 'The iss do not match with this server.', 'data' => array(), ), 401 @@ -460,7 +464,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_bad_request', - 'message' => __( 'User ID not found in the token.', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'User ID not found in the token.', 'jwt-auth' ) : 'User ID not found in the token.', 'data' => array(), ), 401 @@ -477,7 +481,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_invalid_token', - 'message' => __( "Invalid token", 'jwt-auth' ), + 'message' => $has_l10n ? __( "Invalid token", 'jwt-auth' ) : "Invalid token", 'data' => array(), ), 401 @@ -494,7 +498,7 @@ public function validate_token( $return_response = true ) { 'success' => false, 'statusCode' => 401, 'code' => 'jwt_auth_obsolete_token', - 'message' => __( 'Token is obsolete', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'Token is obsolete', 'jwt-auth' ) : 'Token is obsolete', 'data' => array(), ), 401 @@ -510,7 +514,7 @@ public function validate_token( $return_response = true ) { 'success' => true, 'statusCode' => 200, 'code' => 'jwt_auth_valid_token', - 'message' => __( 'Token is valid', 'jwt-auth' ), + 'message' => $has_l10n ? __( 'Token is valid', 'jwt-auth' ) : 'Token is valid', 'data' => array(), ); diff --git a/readme.txt b/readme.txt index 55ef295..0d5b7d2 100644 --- a/readme.txt +++ b/readme.txt @@ -816,6 +816,7 @@ You can help this plugin stay alive and maintained by giving **5 Stars** Rating/ == Changelog == = 3.0.x = +- Fix: String translation is invoked before gettext domain is loaded. - Fix: Prioritise authentication with user credentials over refresh token if both are sent. = 3.0.2 =