Skip to content

Commit

Permalink
🐛 Don't redirect search and other page types
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
MatzeKitt committed Dec 2, 2024
1 parent c85d834 commit 59978c4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions inc/class-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down

0 comments on commit 59978c4

Please sign in to comment.