Skip to content

Commit

Permalink
Merge 62c877f into f1da983
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Apr 23, 2020
2 parents f1da983 + 62c877f commit 75d611f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions php/class-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,15 @@ public function format_exception( $code, $error_status = 500 ) {
switch ( $error_status ) {
case 401:
/* translators: %s: Link to settings page. */
$message = sprintf( __( 'Request unauthorized. Please check your <a href="%s">Unsplash settings</a>.', 'unsplash' ), get_admin_url( null, 'options-general.php?page=unsplash' ) );
$message = sprintf( __( 'The Unsplash API credentials supplied are not authorized. Please visit the <a href="%s">Unsplash settings page</a> to reconnect to Unsplash now.', 'unsplash' ), get_admin_url( null, 'options-general.php?page=unsplash' ) );
break;
case 403:
/* translators: %s: Link to settings page. */
$message = sprintf( __( 'Request forbidden. Please check your <a href="%s">Unsplash settings</a>.', 'unsplash' ), get_admin_url( null, 'options-general.php?page=unsplash' ) );
$message = sprintf( __( 'The Unsplash API credentials supplied are not authorized for this request. Please visit the <a href="%s">Unsplash settings page</a> to reconnect to Unsplash now.', 'unsplash' ), get_admin_url( null, 'options-general.php?page=unsplash' ) );
break;
case 500:
$message = __( 'Server error. An error occurred contacting the Unsplash API.', 'unsplash' );
/* translators: %s: Link to status page. */
$message = sprintf( __( 'There appears to be a communication issue with Unsplash, please check <a href="%s">status.unsplash.com</a> and try again in a few minutes.', 'unsplash' ), 'https://status.unsplash.com' );
break;
default:
$message = get_status_header_desc( $error_status );
Expand All @@ -482,9 +483,8 @@ public function check_api_credentials() {
return new WP_Error(
'missing_api_credential',
sprintf(
/* translators: 1: Missing api credential, 2: Link to settings page */
__( 'The following API credential is missing: %1$s. Please go to <a href="%2$s">Unsplash settings</a> to setup this plugin.', 'unsplash' ),
$key,
/* translators: %s: Link to settings page. */
__( 'The Unsplash plugin has not been provided with API credentials. Please visit the <a href="%s">Unsplash settings page</a> and confirm that the API key/secret has been provided.', 'unsplash' ),
get_admin_url( null, 'options-general.php?page=unsplash' )
),
[
Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/php/class-test-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,12 +1114,12 @@ private function get_photo_response() {
*/
public function data_test_format_exception() {
return [
[ 'test_500', 500, 'Server error. An error occurred contacting the Unsplash API.' ],
[ 'test_401', 401, 'Request unauthorized. Please check your Unsplash settings.' ],
[ 'test_403', 403, 'Request forbidden. Please check your Unsplash settings.' ],
[ 'test_500', 500, 'There appears to be a communication issue with Unsplash, please check status.unsplash.com and try again in a few minutes.' ],
[ 'test_401', 401, 'The Unsplash API credentials supplied are not authorized. Please visit the Unsplash settings page to reconnect to Unsplash now.' ],
[ 'test_403', 403, 'The Unsplash API credentials supplied are not authorized for this request. Please visit the Unsplash settings page to reconnect to Unsplash now.' ],
[ 'test_418', 418, 'I\'m a teapot' ],
[ 'test_0', 0, 'Server error. An error occurred contacting the Unsplash API.' ],
[ 'test_foo', 'foo', 'Server error. An error occurred contacting the Unsplash API.' ],
[ 'test_0', 0, 'There appears to be a communication issue with Unsplash, please check status.unsplash.com and try again in a few minutes.' ],
[ 'test_foo', 'foo', 'There appears to be a communication issue with Unsplash, please check status.unsplash.com and try again in a few minutes.' ],
];
}

Expand Down Expand Up @@ -1161,7 +1161,7 @@ public function test_no_check_api_credentials() {
$rest_controller = new Rest_Controller( new Plugin() );
$wp_error = $rest_controller->check_api_credentials();
$this->assertEquals( $wp_error->get_error_code(), 'missing_api_credential' );
$this->assertEquals( wp_strip_all_tags( $wp_error->get_error_message() ), 'The following API credential is missing: applicationId. Please go to Unsplash settings to setup this plugin.' );
$this->assertEquals( wp_strip_all_tags( $wp_error->get_error_message() ), 'The Unsplash plugin has not been provided with API credentials. Please visit the Unsplash settings page and confirm that the API key/secret has been provided.' );
remove_filter( 'unsplash_api_credentials', [ $this, 'disable_unsplash_api_credentials' ] );
}

Expand Down

0 comments on commit 75d611f

Please sign in to comment.