plugin fixes
This commit is contained in:
@@ -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
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user