feat(wpmc S5): LinkFilter scaffold + register 3 URL filters
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WPMultiCity;
|
||||
|
||||
final class LinkFilter
|
||||
{
|
||||
public static function register(): void
|
||||
{
|
||||
\add_filter('home_url', [self::class, 'filter_home_url'], 9999, 4);
|
||||
\add_filter('post_link', [self::class, 'filter_post_link'], 10, 3);
|
||||
\add_filter('acf/load_value', [self::class, 'filter_acf_load_value'], 9999, 3);
|
||||
}
|
||||
|
||||
public static function filter_home_url(string $url, string $path = '', $orig_scheme = null, $blog_id = null): string
|
||||
{
|
||||
return self::add_town_prefix($url);
|
||||
}
|
||||
|
||||
public static function filter_post_link(string $permalink, $post = null, bool $leavename = false): string
|
||||
{
|
||||
return self::add_town_prefix($permalink);
|
||||
}
|
||||
|
||||
public static function filter_acf_load_value($value, $post_id = null, $field = null)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
return self::add_town_prefix($value);
|
||||
}
|
||||
|
||||
public static function add_town_prefix(string $url): string
|
||||
{
|
||||
// Implementation in Task 4.
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user