Add Site Metadata Endpoint and API Key Management

- Introduced a new Site Metadata endpoint (`GET /wp-json/igny8/v1/site-metadata/`) for retrieving available post types and taxonomies, including counts.
- Added API key input in the admin settings for authentication, with secure storage and revocation functionality.
- Implemented a toggle for enabling/disabling two-way sync operations.
- Updated documentation to reflect new features and usage examples.
- Enhanced permission checks for REST API calls to ensure secure access.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-21 15:18:48 +00:00
parent 1eba4a4e15
commit c35b3c3641
10 changed files with 475 additions and 34 deletions

View File

@@ -32,6 +32,13 @@ class Igny8API {
*/
private $access_token = null;
/**
* Whether authentication is via API key (true) or tokens (false)
*
* @var bool
*/
private $api_key_auth = false;
/**
* Refresh token
*
@@ -46,9 +53,17 @@ class Igny8API {
if (function_exists('igny8_get_secure_option')) {
$this->access_token = igny8_get_secure_option('igny8_access_token');
$this->refresh_token = igny8_get_secure_option('igny8_refresh_token');
$api_key = igny8_get_secure_option('igny8_api_key');
} else {
$this->access_token = get_option('igny8_access_token');
$this->refresh_token = get_option('igny8_refresh_token');
$api_key = get_option('igny8_api_key');
}
// If an API key is provided, prefer it as the access token
if (!empty($api_key)) {
$this->access_token = $api_key;
$this->api_key_auth = true;
}
}