PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Providers/AdminServiceProvider.php +15 -0 3.0.5 → 3.0.16 View file →
@@ -16,8 +16,18 @@
16 16 {
17 17 private const UPGRADE_TO_PRO_URL = 'https://wpyatra.com/pricing';
18 18
19 19 /**
20 + * Guard so bootstrapMenuCapability() is idempotent across the two
21 + * call sites (AppServiceProvider::register() — always-loaded path —
22 + * and registerAdminMenu() — admin-only). add_filter() with anonymous
23 + * closures does NOT dedupe, because each call creates a new closure
24 + * with a distinct object identity, so without this guard the filters
25 + * would run twice per cap check on admin pageviews.
26 + */
27 + private static bool $capabilityFiltersInstalled = false;
28 +
29 + /**
20 30 * Register services
21 31 */
22 32 public function register(): void
23 33 {
@@ -483,8 +493,13 @@
483 493 * Idempotent — adding the same filter callback twice is a no-op in WP.
484 494 */
485 495 public static function bootstrapMenuCapability(): void
486 496 {
497 + if (self::$capabilityFiltersInstalled) {
498 + return;
499 + }
500 + self::$capabilityFiltersInstalled = true;
501 +
487 502 add_filter('user_has_cap', static function (array $allcaps, array $caps, array $args, \WP_User $user): array {
488 503 if (empty($allcaps['manage_options'])) return $allcaps;
489 504 // Only set if the cap was asked-about (avoids polluting
490 505 // unrelated cap checks with a key we don't need to answer).