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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user