feat(wpmc S5): Helpers::without_url_filters bypass counter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-05-16 22:31:00 +05:00
parent 3824e28933
commit a835ba3662
2 changed files with 74 additions and 0 deletions
+17
View File
@@ -9,6 +9,7 @@ final class Helpers
private static bool $current_town_resolved = false;
private static array $term_cache = [];
private static array $page_unic_cache = [];
private static int $bypass_depth = 0;
public static function reset_cache(): void
{
@@ -16,6 +17,7 @@ final class Helpers
self::$current_town_resolved = false;
self::$term_cache = [];
self::$page_unic_cache = [];
self::$bypass_depth = 0;
}
public static function get_term_by_slug(string $slug, string $taxonomy = 'town'): ?\WP_Term
@@ -177,4 +179,19 @@ final class Helpers
}
return true;
}
public static function without_url_filters(callable $fn)
{
self::$bypass_depth++;
try {
return $fn();
} finally {
self::$bypass_depth--;
}
}
public static function is_bypassed(): bool
{
return self::$bypass_depth > 0;
}
}