plugin fixes

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 07:59:19 +00:00
parent 04f04af813
commit b2012e9563
6 changed files with 449 additions and 57 deletions

View File

@@ -220,7 +220,6 @@ class Igny8Admin {
*/
private function handle_connection() {
$api_key = sanitize_text_field($_POST['igny8_api_key'] ?? '');
$site_id = sanitize_text_field($_POST['igny8_site_id'] ?? '');
// API key is required
if (empty($api_key)) {
@@ -233,12 +232,17 @@ class Igny8Admin {
return;
}
// Site ID is required
// Extract site_id from API key format: igny8_site_{site_id}_{timestamp}_{random}
$site_id = null;
if (preg_match('/^igny8_site_(\d+)_/', $api_key, $matches)) {
$site_id = (int) $matches[1];
}
if (empty($site_id)) {
add_settings_error(
'igny8_settings',
'igny8_error',
__('Site ID is required. Create a site in IGNY8 app first.', 'igny8-bridge'),
__('Invalid API key format. Please copy the complete API key from IGNY8 app.', 'igny8-bridge'),
'error'
);
return;
@@ -253,7 +257,7 @@ class Igny8Admin {
$api = new Igny8API();
$test_response = $api->post('/v1/integration/integrations/test-connection/', array(
'site_id' => (int) $site_id,
'site_id' => $site_id,
'api_key' => $api_key,
'site_url' => $site_url
));