From 95868105071976c4e6374af9a116c7451a8ad95e Mon Sep 17 00:00:00 2001 From: Vladimir Bryzgalov Date: Tue, 19 May 2026 02:15:46 +0500 Subject: [PATCH] feat(wpmc 1.1.0): Redirect hook moves to template_redirect@1 Co-Authored-By: Claude Opus 4.7 --- includes/class-redirect.php | 2 +- tests/PluginBootS4Test.php | 6 +++--- tests/PluginBootTest.php | 4 ++-- tests/RedirectTest.php | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/class-redirect.php b/includes/class-redirect.php index 6ba7f3d..43b499a 100644 --- a/includes/class-redirect.php +++ b/includes/class-redirect.php @@ -7,7 +7,7 @@ final class Redirect { public static function register(): void { - \add_action('wp', [self::class, 'handle'], 9998); + \add_action('template_redirect', [self::class, 'handle'], 1); } public static function handle(): void diff --git a/tests/PluginBootS4Test.php b/tests/PluginBootS4Test.php index d3b2847..2e92fe9 100644 --- a/tests/PluginBootS4Test.php +++ b/tests/PluginBootS4Test.php @@ -34,9 +34,9 @@ final class PluginBootS4Test extends TestCase 'boot() must register Router on wp@9999' ); self::assertSame( - 9998, - has_action('wp', ['WPMultiCity\\Redirect', 'handle']), - 'boot() must register Redirect on wp@9998' + 1, + has_action('template_redirect', ['WPMultiCity\\Redirect', 'handle']), + 'boot() must register Redirect on template_redirect@1' ); } } diff --git a/tests/PluginBootTest.php b/tests/PluginBootTest.php index ea35668..04360f9 100644 --- a/tests/PluginBootTest.php +++ b/tests/PluginBootTest.php @@ -74,8 +74,8 @@ final class PluginBootTest extends TestCase \Brain\Monkey\Actions\expectAdded('acf/init') ->with([\WPMultiCity\TermMeta::class, 'do_register']) ->once(); - \Brain\Monkey\Actions\expectAdded('wp') - ->with([\WPMultiCity\Redirect::class, 'handle'], 9998) + \Brain\Monkey\Actions\expectAdded('template_redirect') + ->with([\WPMultiCity\Redirect::class, 'handle'], 1) ->once(); \Brain\Monkey\Actions\expectAdded('wp') ->with([\WPMultiCity\Router::class, 'route'], 9999) diff --git a/tests/RedirectTest.php b/tests/RedirectTest.php index 105d1c6..e36a47b 100644 --- a/tests/RedirectTest.php +++ b/tests/RedirectTest.php @@ -7,14 +7,14 @@ use WPMultiCity\Redirect; final class RedirectTest extends TestCase { - public function test_register_attaches_wp_action_at_priority_9998(): void + public function test_register_attaches_template_redirect_at_priority_1(): void { Redirect::register(); self::assertSame( - 9998, - has_action('wp', [Redirect::class, 'handle']), - 'Redirect::register() must hook wp action at priority 9998' + 1, + has_action('template_redirect', [Redirect::class, 'handle']), + 'Redirect::register() must hook template_redirect at priority 1' ); }