false, 'fields' => 'id=>slug', ]); if (is_array($terms) && in_array($first_segment, $terms, true)) { $resolved = $first_segment; } } if ($resolved === null) { $resolved = \apply_filters('wpmc_main_town_slug', null); if (!is_string($resolved) || $resolved === '') { $resolved = null; } } $resolved = \apply_filters('wpmc_current_town_slug', $resolved); if (!is_string($resolved) || $resolved === '') { $resolved = null; } self::$current_town_memo = $resolved; self::$current_town_resolved = true; return $resolved; } private static function first_path_segment(string $uri): ?string { $path = strtok($uri, '?'); if ($path === false) { return null; } $parts = array_values(array_filter(explode('/', $path), static fn(string $p) => $p !== '')); return $parts[0] ?? null; } }