fix: Simplify localhost detection and add early metrics support
Some checks failed
Create Release Package / build-release (push) Failing after 53s

- License/Manager: Simplify localhost TLD detection to .localhost and .local
- Prometheus/Integration: Add collect_early_metrics() for wp-prometheus early mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 22:53:07 +01:00
parent d4e7c9127d
commit 36a546c224
2 changed files with 35 additions and 9 deletions

View File

@@ -443,23 +443,25 @@ final class Manager {
public static function is_localhost(): bool {
$host = wp_parse_url( home_url(), PHP_URL_HOST );
// Common localhost identifiers.
$localhost_hosts = array(
$localhost_patterns = array(
'localhost',
'127.0.0.1',
'::1',
);
if ( in_array( $host, $localhost_hosts, true ) ) {
// Check exact matches.
if ( in_array( $host, $localhost_patterns, true ) ) {
return true;
}
// Common local development TLDs.
$local_tlds = array( '.local', '.test', '.localhost', '.dev.local' );
foreach ( $local_tlds as $tld ) {
if ( str_ends_with( $host, $tld ) ) {
return true;
}
// Check .localhost TLD (e.g., mysite.localhost).
if ( str_ends_with( $host, '.localhost' ) ) {
return true;
}
// Check .local TLD (common for local development).
if ( str_ends_with( $host, '.local' ) ) {
return true;
}
return false;