feat(wpmc S5): RestUrlFilter forces HTTPS + preserves HTTP_HOST
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WPMultiCity;
|
||||
|
||||
final class RestUrlFilter
|
||||
{
|
||||
public static function register(): void
|
||||
{
|
||||
\add_filter('rest_url', [self::class, 'preserve_host']);
|
||||
}
|
||||
|
||||
public static function preserve_host(string $url): string
|
||||
{
|
||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||||
if ($host === '') {
|
||||
return $url;
|
||||
}
|
||||
$replaced = preg_replace('#^https?://[^/]+#', 'https://' . $host, $url);
|
||||
return is_string($replaced) ? $replaced : $url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user