@@ -140,8 +140,8 @@ public function get_parameters( $require_token = true, $extra = array() ) {
140140 if ( ! empty ( $ errors ) ) {
141141 $ message = sprintf (
142142 _n (
143- 'Missing OAuth parameter %s ' ,
144- 'Missing OAuth parameters %s ' ,
143+ __ ( 'Missing OAuth parameter %s ' , ' rest_oauth1 ' ) ,
144+ __ ( 'Missing OAuth parameters %s ' , ' rest_oauth1 ' ) ,
145145 count ( $ errors )
146146 ),
147147 implode (', ' , $ errors )
@@ -252,7 +252,7 @@ public function dispatch( $route ) {
252252 return $ params ;
253253 }
254254 if ( empty ( $ params ) ) {
255- return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' ), array ( 'status ' => 400 ) );
255+ return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
256256 }
257257
258258 return $ this ->generate_request_token ( $ params );
@@ -264,7 +264,7 @@ public function dispatch( $route ) {
264264 return $ params ;
265265 }
266266 if ( empty ( $ params ) ) {
267- return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' ), array ( 'status ' => 400 ) );
267+ return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
268268 }
269269
270270 return $ this ->generate_access_token (
@@ -274,7 +274,7 @@ public function dispatch( $route ) {
274274 );
275275
276276 default :
277- return new WP_Error ( 'json_oauth1_invalid_route ' , __ ( 'Route is invalid ' ), array ( 'status ' => 404 ) );
277+ return new WP_Error ( 'json_oauth1_invalid_route ' , __ ( 'Route is invalid ' , ' rest_oauth1 ' ), array ( 'status ' => 404 ) );
278278 }
279279 }
280280
@@ -295,7 +295,7 @@ public function check_token( $token, $consumer_key ) {
295295 }
296296
297297 if ( ! hash_equals ( (string ) $ token ['consumer ' ], (string ) $ consumer ->ID ) ) {
298- return new WP_Error ( 'json_oauth1_consumer_mismatch ' , __ ( 'Token is not registered for the given consumer ' ), array ( 'status ' => 401 ) );
298+ return new WP_Error ( 'json_oauth1_consumer_mismatch ' , __ ( 'Token is not registered for the given consumer ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
299299 }
300300
301301 return array ( $ consumer , new WP_User ( $ token ['user ' ] ) );
@@ -311,13 +311,13 @@ public function get_request_token( $key ) {
311311 $ data = get_option ( 'oauth1_request_ ' . $ key , null );
312312
313313 if ( empty ( $ data ) ) {
314- return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Invalid token ' ), array ( 'status ' => 400 ) );
314+ return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Invalid token ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
315315 }
316316
317317 // Check expiration
318318 if ( $ data ['expiration ' ] < time () ) {
319319 $ this ->remove_request_token ( $ key );
320- return new WP_Error ( 'json_oauth1_expired_token ' , __ ( 'OAuth request token has expired ' ), array ( 'status ' => 401 ) );
320+ return new WP_Error ( 'json_oauth1_expired_token ' , __ ( 'OAuth request token has expired ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
321321 }
322322
323323 return $ data ;
@@ -378,7 +378,7 @@ public function set_request_token_callback( $key, $callback ) {
378378
379379 $ consumer = $ token ['consumer ' ];
380380 if ( ! $ this ->check_callback ( $ callback , $ consumer ) ) {
381- return new WP_Error ( 'json_oauth1_invalid_callback ' , __ ( 'Callback URL is invalid ' ) );
381+ return new WP_Error ( 'json_oauth1_invalid_callback ' , __ ( 'Callback URL is invalid ' , ' rest_oauth1 ' ) );
382382 }
383383
384384 $ token ['callback ' ] = $ callback ;
@@ -504,7 +504,7 @@ public function authorize_request_token( $key, $user = null ) {
504504 }
505505
506506 if ( empty ( $ user ) ) {
507- return new WP_Error ( 'json_oauth1_invalid_user ' , __ ( 'Invalid user specified for access token ' ) );
507+ return new WP_Error ( 'json_oauth1_invalid_user ' , __ ( 'Invalid user specified for access token ' , ' rest_oauth1 ' ) );
508508 }
509509
510510 $ token ['authorized ' ] = true ;
@@ -554,11 +554,11 @@ public function generate_access_token( $oauth_consumer_key, $oauth_token, $oauth
554554
555555 // Check verification
556556 if ( $ token ['authorized ' ] !== true ) {
557- return new WP_Error ( 'json_oauth1_unauthorized_token ' , __ ( 'OAuth token has not been authorized ' ), array ( 'status ' => 401 ) );
557+ return new WP_Error ( 'json_oauth1_unauthorized_token ' , __ ( 'OAuth token has not been authorized ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
558558 }
559559
560560 if ( $ oauth_verifier !== $ token ['verifier ' ] ) {
561- return new WP_Error ( 'json_oauth1_invalid_verifier ' , __ ( 'OAuth verifier does not match ' ), array ( 'status ' => 400 ) );
561+ return new WP_Error ( 'json_oauth1_invalid_verifier ' , __ ( 'OAuth verifier does not match ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
562562 }
563563
564564 $ this ->should_attempt = false ;
@@ -600,7 +600,7 @@ public function generate_access_token( $oauth_consumer_key, $oauth_token, $oauth
600600 public function revoke_access_token ( $ key ) {
601601 $ data = $ this ->get_access_token ( $ key );
602602 if ( empty ( $ data ) ) {
603- return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Access token does not exist ' ), array ( 'status ' => 401 ) );
603+ return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Access token does not exist ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
604604 }
605605
606606 delete_option ( 'oauth1_access_ ' . $ key );
@@ -652,7 +652,7 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
652652
653653 // sort parameters
654654 if ( ! uksort ( $ params , 'strcmp ' ) )
655- return new WP_Error ( 'json_oauth1_failed_parameter_sort ' , __ ( 'Invalid Signature - failed to sort parameters ' ), array ( 'status ' => 401 ) );
655+ return new WP_Error ( 'json_oauth1_failed_parameter_sort ' , __ ( 'Invalid Signature - failed to sort parameters ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
656656
657657 $ query_string = $ this ->create_signature_string ( $ params );
658658
@@ -674,13 +674,13 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
674674 break ;
675675
676676 default :
677- return new WP_Error ( 'json_oauth1_invalid_signature_method ' , __ ( 'Signature method is invalid ' ), array ( 'status ' => 401 ) );
677+ return new WP_Error ( 'json_oauth1_invalid_signature_method ' , __ ( 'Signature method is invalid ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
678678 }
679679
680680 $ signature = base64_encode ( hash_hmac ( $ hash_algorithm , $ string_to_sign , $ key , true ) );
681681
682682 if ( ! hash_equals ( $ signature , $ consumer_signature ) ) {
683- return new WP_Error ( 'json_oauth1_signature_mismatch ' , __ ( 'OAuth signature does not match ' ), array ( 'status ' => 401 ) );
683+ return new WP_Error ( 'json_oauth1_signature_mismatch ' , __ ( 'OAuth signature does not match ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
684684 }
685685
686686 return true ;
@@ -751,15 +751,15 @@ protected function check_oauth_timestamp_and_nonce( $consumer, $timestamp, $nonc
751751 $ valid_window = apply_filters ( 'json_oauth1_timestamp_window ' , 15 * MINUTE_IN_SECONDS );
752752
753753 if ( ( $ timestamp < time () - $ valid_window ) || ( $ timestamp > time () + $ valid_window ) )
754- return new WP_Error ( 'json_oauth1_invalid_timestamp ' , __ ( 'Invalid timestamp ' ), array ( 'status ' => 401 ) );
754+ return new WP_Error ( 'json_oauth1_invalid_timestamp ' , __ ( 'Invalid timestamp ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
755755
756756 $ used_nonces = $ consumer ->nonces ;
757757
758758 if ( empty ( $ used_nonces ) )
759759 $ used_nonces = array ();
760760
761761 if ( in_array ( $ nonce , $ used_nonces ) )
762- return new WP_Error ( 'json_oauth1_nonce_already_used ' , __ ( 'Invalid nonce - nonce has already been used ' ), array ( 'status ' => 401 ) );
762+ return new WP_Error ( 'json_oauth1_nonce_already_used ' , __ ( 'Invalid nonce - nonce has already been used ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
763763
764764 $ used_nonces [ $ timestamp ] = $ nonce ;
765765
0 commit comments