| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | * |
| 44 | 44 | * @param Parsely $parsely The Parsely instance. |
| 45 | 45 | * @param string $site_id The Site ID to be validated. |
| 46 | 46 | * @param string $api_secret The API Secret to be validated. |
| 47 | - * @return true|WP_Error True if the API Credentials are valid, WP_Error otherwise. | |
| 47 | + * @return bool|WP_Error True if the API Credentials are valid, WP_Error otherwise. | |
| 48 | 48 | */ |
| 49 | 49 | public static function validate_api_credentials( Parsely $parsely, string $site_id, string $api_secret ) { |
| 50 | 50 | // If the API secret is empty, the validation endpoint will always fail. |
| 51 | 51 | // Since it's possible to use the plugin without an API Secret, we'll |
| @@ -53,17 +53,12 @@ | ||
| 53 | 53 | if ( '' === $api_secret ) { |
| 54 | 54 | return true; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $query_args = array( | |
| 58 | - 'apikey' => $site_id, | |
| 59 | - 'secret' => $api_secret, | |
| 60 | - ); | |
| 57 | + $content_api = $parsely->get_content_api(); | |
| 58 | + $is_valid = $content_api->validate_credentials( $site_id, $api_secret ); | |
| 61 | 59 | |
| 62 | - $validate_api = new RemoteAPI\Validate_API( $parsely ); | |
| 63 | - $request = $validate_api->get_items( $query_args ); | |
| 64 | - | |
| 65 | - if ( is_wp_error( $request ) ) { | |
| 60 | + if ( is_wp_error( $is_valid ) ) { | |
| 66 | 61 | return new WP_Error( |
| 67 | 62 | self::INVALID_API_CREDENTIALS, |
| 68 | 63 | __( 'Invalid API Credentials', 'wp-parsely' ) |
| 69 | 64 | ); |
| @@ -68,7 +63,7 @@ | ||
| 68 | 63 | __( 'Invalid API Credentials', 'wp-parsely' ) |
| 69 | 64 | ); |
| 70 | 65 | } |
| 71 | 66 | |
| 72 | - return true; | |
| 67 | + return $is_valid; | |
| 73 | 68 | } |
| 74 | 69 | } |