fixes
This commit is contained in:
@@ -63,7 +63,10 @@ class Igny8Admin {
|
||||
*/
|
||||
public function register_settings() {
|
||||
register_setting('igny8_settings', 'igny8_email');
|
||||
register_setting('igny8_settings', 'igny8_site_id');
|
||||
register_setting('igny8_settings', 'igny8_site_id', array(
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint'
|
||||
));
|
||||
register_setting('igny8_settings', 'igny8_enable_two_way_sync', array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => array($this, 'sanitize_boolean'),
|
||||
@@ -275,11 +278,33 @@ class Igny8Admin {
|
||||
}
|
||||
}
|
||||
|
||||
// Try to get site ID (if available) using the authenticated client
|
||||
// Try to get site ID by matching current site URL
|
||||
$site_response = $api->get('/system/sites/');
|
||||
if ($site_response['success'] && !empty($site_response['results'])) {
|
||||
$site = $site_response['results'][0];
|
||||
update_option('igny8_site_id', $site['id']);
|
||||
$current_site_url = get_site_url();
|
||||
$current_domain = parse_url($current_site_url, PHP_URL_HOST);
|
||||
|
||||
// Try to find matching site by domain
|
||||
$matched_site = null;
|
||||
foreach ($site_response['results'] as $site) {
|
||||
if (!empty($site['domain'])) {
|
||||
$site_domain = parse_url($site['domain'], PHP_URL_HOST);
|
||||
if ($site_domain === $current_domain) {
|
||||
$matched_site = $site;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to first site if no match found
|
||||
if ($matched_site) {
|
||||
update_option('igny8_site_id', $matched_site['id']);
|
||||
error_log('IGNY8: Matched site by domain: ' . $matched_site['name'] . ' (ID: ' . $matched_site['id'] . ')');
|
||||
} else {
|
||||
$site = $site_response['results'][0];
|
||||
update_option('igny8_site_id', $site['id']);
|
||||
error_log('IGNY8: No domain match, using first site: ' . $site['name'] . ' (ID: ' . $site['id'] . ')');
|
||||
}
|
||||
}
|
||||
|
||||
add_settings_error(
|
||||
|
||||
Reference in New Issue
Block a user