1
This commit is contained in:
@@ -63,10 +63,7 @@ class Igny8Admin {
|
||||
*/
|
||||
public function register_settings() {
|
||||
register_setting('igny8_settings', 'igny8_email');
|
||||
register_setting('igny8_settings', 'igny8_site_id', array(
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint'
|
||||
));
|
||||
register_setting('igny8_settings', 'igny8_site_id');
|
||||
register_setting('igny8_settings', 'igny8_enable_two_way_sync', array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => array($this, 'sanitize_boolean'),
|
||||
@@ -85,6 +82,12 @@ class Igny8Admin {
|
||||
'default' => array_keys(igny8_get_supported_post_types())
|
||||
));
|
||||
|
||||
register_setting('igny8_bridge_controls', 'igny8_enabled_taxonomies', array(
|
||||
'type' => 'array',
|
||||
'sanitize_callback' => array($this, 'sanitize_taxonomies'),
|
||||
'default' => array('category', 'post_tag', 'product_cat', 'igny8_sectors', 'igny8_clusters')
|
||||
));
|
||||
|
||||
register_setting('igny8_bridge_controls', 'igny8_enable_woocommerce', array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => array($this, 'sanitize_boolean'),
|
||||
@@ -278,33 +281,11 @@ class Igny8Admin {
|
||||
}
|
||||
}
|
||||
|
||||
// Try to get site ID by matching current site URL
|
||||
// Try to get site ID (if available) using the authenticated client
|
||||
$site_response = $api->get('/system/sites/');
|
||||
if ($site_response['success'] && !empty($site_response['results'])) {
|
||||
$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'] . ')');
|
||||
}
|
||||
$site = $site_response['results'][0];
|
||||
update_option('igny8_site_id', $site['id']);
|
||||
}
|
||||
|
||||
add_settings_error(
|
||||
@@ -568,6 +549,31 @@ class Igny8Admin {
|
||||
return !empty($clean) ? $clean : $supported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize taxonomies option
|
||||
*
|
||||
* @param mixed $value Raw value
|
||||
* @return array
|
||||
*/
|
||||
public function sanitize_taxonomies($value) {
|
||||
$supported = array_keys(igny8_get_supported_taxonomies());
|
||||
|
||||
if (!is_array($value)) {
|
||||
return array('category', 'post_tag', 'product_cat', 'igny8_sectors', 'igny8_clusters');
|
||||
}
|
||||
|
||||
$clean = array();
|
||||
foreach ($value as $taxonomy) {
|
||||
$taxonomy = sanitize_key($taxonomy);
|
||||
if (in_array($taxonomy, $supported, true)) {
|
||||
$clean[] = $taxonomy;
|
||||
}
|
||||
}
|
||||
|
||||
// Return defaults if nothing selected
|
||||
return !empty($clean) ? $clean : array('category', 'post_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize boolean option
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user