| @@ -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 bool|WP_Error True if the API Credentials are valid, WP_Error otherwise. | |
| 47 | + * @return true|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,12 +53,17 @@ | ||
| 53 | 53 | if ( '' === $api_secret ) { |
| 54 | 54 | return true; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $content_api = $parsely->get_content_api(); | |
| 58 | - $is_valid = $content_api->validate_credentials( $site_id, $api_secret ); | |
| 57 | + $query_args = array( | |
| 58 | + 'apikey' => $site_id, | |
| 59 | + 'secret' => $api_secret, | |
| 60 | + ); | |
| 59 | 61 | |
| 60 | - if ( is_wp_error( $is_valid ) ) { | |
| 62 | + $validate_api = new RemoteAPI\Validate_API( $parsely ); | |
| 63 | + $request = $validate_api->get_items( $query_args ); | |
| 64 | + | |
| 65 | + if ( is_wp_error( $request ) ) { | |
| 61 | 66 | return new WP_Error( |
| 62 | 67 | self::INVALID_API_CREDENTIALS, |
| 63 | 68 | __( 'Invalid API Credentials', 'wp-parsely' ) |
| 64 | 69 | ); |
| @@ -63,7 +68,7 @@ | ||
| 63 | 68 | __( 'Invalid API Credentials', 'wp-parsely' ) |
| 64 | 69 | ); |
| 65 | 70 | } |
| 66 | 71 | |
| 67 | - return $is_valid; | |
| 72 | + return true; | |
| 68 | 73 | } |
| 69 | 74 | } |