From c9d72aaaa1f8f9d1fec3e2f1b784febdb147ad85 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 31 Jul 2023 10:49:08 +0200 Subject: [PATCH] hide listing on others tab if corresponding tab is displayed --- plugins/SitesManager/SiteContentDetection/Cloudflare.php | 6 +++++- .../SitesManager/SiteContentDetection/GoogleTagManager.php | 6 +++++- .../SitesManager/SiteContentDetection/MatomoTagManager.php | 2 +- plugins/SitesManager/SiteContentDetection/ReactJs.php | 6 +++++- .../SiteContentDetection/SiteContentDetectionAbstract.php | 3 ++- plugins/SitesManager/SiteContentDetection/SpaPwa.php | 2 +- plugins/SitesManager/SiteContentDetection/VueJs.php | 6 +++++- plugins/SitesManager/SiteContentDetection/WordPress.php | 6 +++++- 8 files changed, 29 insertions(+), 8 deletions(-) diff --git a/plugins/SitesManager/SiteContentDetection/Cloudflare.php b/plugins/SitesManager/SiteContentDetection/Cloudflare.php index 50de0b69d685..5e33e82914b0 100644 --- a/plugins/SitesManager/SiteContentDetection/Cloudflare.php +++ b/plugins/SitesManager/SiteContentDetection/Cloudflare.php @@ -62,8 +62,12 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str return $view->render(); } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { + if ($detector->wasDetected(self::class)) { + return ''; // don't show on others page if tab is being displayed + } + return sprintf( '

%s

', Piwik::translate( diff --git a/plugins/SitesManager/SiteContentDetection/GoogleTagManager.php b/plugins/SitesManager/SiteContentDetection/GoogleTagManager.php index e1f125d68621..d3331b4dfee2 100644 --- a/plugins/SitesManager/SiteContentDetection/GoogleTagManager.php +++ b/plugins/SitesManager/SiteContentDetection/GoogleTagManager.php @@ -81,8 +81,12 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str return $view->render(); } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { + if ($detector->wasDetected(self::class)) { + return ''; // don't show on others page if tab is being displayed + } + return sprintf( '

%s

', Piwik::translate( diff --git a/plugins/SitesManager/SiteContentDetection/MatomoTagManager.php b/plugins/SitesManager/SiteContentDetection/MatomoTagManager.php index 611994ba2ffa..f458286ca2e1 100644 --- a/plugins/SitesManager/SiteContentDetection/MatomoTagManager.php +++ b/plugins/SitesManager/SiteContentDetection/MatomoTagManager.php @@ -53,7 +53,7 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str

' . Piwik::translate( 'SitesManager_SiteWithoutDataMatomoTagManagerNotActive', ['', '']) . '

'; } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { return sprintf( '

%s

', diff --git a/plugins/SitesManager/SiteContentDetection/ReactJs.php b/plugins/SitesManager/SiteContentDetection/ReactJs.php index 0d8837e60d72..4f1754c8d005 100644 --- a/plugins/SitesManager/SiteContentDetection/ReactJs.php +++ b/plugins/SitesManager/SiteContentDetection/ReactJs.php @@ -82,8 +82,12 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str '; } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { + if ($detector->wasDetected(self::class)) { + return ''; // don't show on others page if tab is being displayed + } + return sprintf( '

%s

', Piwik::translate( diff --git a/plugins/SitesManager/SiteContentDetection/SiteContentDetectionAbstract.php b/plugins/SitesManager/SiteContentDetection/SiteContentDetectionAbstract.php index 2d89a745205c..178a20369412 100644 --- a/plugins/SitesManager/SiteContentDetection/SiteContentDetectionAbstract.php +++ b/plugins/SitesManager/SiteContentDetection/SiteContentDetectionAbstract.php @@ -115,9 +115,10 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): ?st /** * Returns the content that should be displayed in the Others tab on the no data page * + * @param SiteContentDetector|null $detector * @return string|null */ - public function renderOthersInstruction(): ?string + public function renderOthersInstruction(SiteContentDetector $detector = null): ?string { return null; } diff --git a/plugins/SitesManager/SiteContentDetection/SpaPwa.php b/plugins/SitesManager/SiteContentDetection/SpaPwa.php index 3fa35203842e..b17b0115cc09 100644 --- a/plugins/SitesManager/SiteContentDetection/SpaPwa.php +++ b/plugins/SitesManager/SiteContentDetection/SpaPwa.php @@ -45,7 +45,7 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str return ''; } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { return sprintf( '

%s

', diff --git a/plugins/SitesManager/SiteContentDetection/VueJs.php b/plugins/SitesManager/SiteContentDetection/VueJs.php index 1cf869f543de..fed6787f9870 100644 --- a/plugins/SitesManager/SiteContentDetection/VueJs.php +++ b/plugins/SitesManager/SiteContentDetection/VueJs.php @@ -58,8 +58,12 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str return $view->render(); } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { + if ($detector->wasDetected(self::class)) { + return ''; // don't show on others page if tab is being displayed + } + return sprintf( '

%s

', Piwik::translate( diff --git a/plugins/SitesManager/SiteContentDetection/WordPress.php b/plugins/SitesManager/SiteContentDetection/WordPress.php index 6c7086d0c89d..608b0eb1530e 100644 --- a/plugins/SitesManager/SiteContentDetection/WordPress.php +++ b/plugins/SitesManager/SiteContentDetection/WordPress.php @@ -74,8 +74,12 @@ public function renderInstructionsTab(SiteContentDetector $detector = null): str return $view->render(); } - public function renderOthersInstruction(): string + public function renderOthersInstruction(SiteContentDetector $detector = null): string { + if ($detector->wasDetected(self::class)) { + return ''; // don't show on others page if tab is being displayed + } + return sprintf( '

%s

', Piwik::translate(