refactor(ip-geo): drop dual-read gates; keep single meta and four surfaces

Canonical keys only (ip_geo_display defaults to all four, aksrt_user_addr /
aksrt_comment_addr only). Self-view still resolves current IP on read.
This commit is contained in:
2026-07-25 15:14:29 +08:00
parent 6e71008d00
commit 3bb7fb0ba6
4 changed files with 87 additions and 177 deletions
+3 -3
View File
@@ -44,7 +44,7 @@ class IPGeo {
}
}
$provider = sanitize_key((string) ($config['ip_addr_sdk'] ?? ($config['ip_geo_provider'] ?? 'null')));
$provider = sanitize_key((string) ($config['ip_addr_sdk'] ?? 'null'));
$result = $this->query_provider($provider, $ip, $config);
if (!empty($result['province']) || !empty($result['city']) || !empty($result['country'])) {
@@ -66,7 +66,7 @@ class IPGeo {
*/
public function get_status(): array {
$config = $this->get_config();
$provider = sanitize_key((string) ($config['ip_addr_sdk'] ?? ($config['ip_geo_provider'] ?? 'null')));
$provider = sanitize_key((string) ($config['ip_addr_sdk'] ?? 'null'));
$enabled = !empty($config['ip_geo_enabled']);
$missing = [];
@@ -88,7 +88,7 @@ class IPGeo {
'transport' => 'http_api',
'missing_fields' => $missing,
'cache_ttl' => (int) ($config['ip_geo_cache_ttl'] ?? 86400),
'display' => (array) ($config['ip_geo_display'] ?? ['comment']),
'display' => (array) ($config['ip_geo_display'] ?? ['comment', 'user_home', 'user_center', 'post']),
'format' => (string) ($config['ip_geo_format'] ?? 'province_city'),
];
}