This commit is contained in:
Javier Casares 2026-08-17 16:05:38 +00:00
commit e3bfd7b6f2
12 changed files with 108 additions and 29 deletions

View file

@ -91,12 +91,25 @@ class Robotstxt_Manager_Core_Client {
}
/**
* Returns whether the client has both a URL and a key configured.
* Returns whether the client can talk to the store.
*
* Only the Store URL is required: the catalog (free plugins, prices,
* product pages) is public on Core. The API key is optional it is
* needed for subscription data and premium downloads, not for listing.
*
* @return bool
*/
public function is_configured(): bool {
return '' !== $this->store_url && '' !== $this->api_key;
return '' !== $this->store_url;
}
/**
* Returns whether an API key is configured.
*
* @return bool
*/
public function has_api_key(): bool {
return '' !== $this->api_key;
}
/**
@ -269,13 +282,16 @@ class Robotstxt_Manager_Core_Client {
private function get( string $endpoint ) {
$url = $this->store_url . '/wp-json/' . self::REST_NAMESPACE . $endpoint;
$headers = array( 'Accept' => 'application/json' );
if ( '' !== $this->api_key ) {
$headers['Authorization'] = 'Bearer ' . $this->api_key;
}
return wp_remote_get(
$url,
array(
'headers' => array(
'Authorization' => 'Bearer ' . $this->api_key,
'Accept' => 'application/json',
),
'headers' => $headers,
'timeout' => self::TIMEOUT,
)
);