feat(wpmc S3): Helpers::remove_domain_link via parse_url

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-05-12 20:04:10 +05:00
parent 11bd3a06b0
commit 22099cf1d6
2 changed files with 25 additions and 0 deletions
+16
View File
@@ -82,4 +82,20 @@ final class Helpers
$value = \get_field($selector, $post_id, $format_value);
return is_string($value) ? \do_shortcode($value) : $value;
}
public static function remove_domain_link(string $url): string
{
$parsed = parse_url($url);
if ($parsed === false || empty($parsed['scheme'])) {
return $url;
}
$scheme = strtolower((string) $parsed['scheme']);
if ($scheme !== 'http' && $scheme !== 'https') {
return $url;
}
$path = $parsed['path'] ?? '';
$query = isset($parsed['query']) ? '?' . $parsed['query'] : '';
$fragment = isset($parsed['fragment']) ? '#' . $parsed['fragment'] : '';
return $path . $query . $fragment;
}
}