From 59978c45c206ee8881619e7cd24fcdf833462790 Mon Sep 17 00:00:00 2001 From: Matthias Kittsteiner Date: Mon, 2 Dec 2024 10:40:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20redirect=20search=20and?= =?UTF-8?q?=20other=20page=20types=20Closes=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/class-switcher.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/inc/class-switcher.php b/inc/class-switcher.php index 9d86e04..0cdc8ba 100644 --- a/inc/class-switcher.php +++ b/inc/class-switcher.php @@ -75,7 +75,18 @@ private static function get_permalink( string $locale ): string { * Maybe redirect a user to another language. */ public static function maybe_redirect(): void { - if ( \is_admin() || \wp_doing_ajax() || \wp_doing_cron() ) { + if ( + \is_admin() + || \is_archive() + || \is_author() + || \is_comment_feed() + || \is_feed() + || \is_preview() + || \is_search() + || \is_trackback() + || \wp_doing_ajax() + || \wp_doing_cron() + ) { return; } @@ -94,7 +105,7 @@ public static function maybe_redirect(): void { return; } - $current_permalink = \get_permalink(); + $current_permalink = \get_permalink( \get_queried_object_id() ); if ( $current_permalink === false ) { return;