diff --git a/Classes/Service/PageLayoutHeader/VisibilityChecker.php b/Classes/Service/PageLayoutHeader/VisibilityChecker.php index 7ffe3096..f0e13621 100644 --- a/Classes/Service/PageLayoutHeader/VisibilityChecker.php +++ b/Classes/Service/PageLayoutHeader/VisibilityChecker.php @@ -5,6 +5,7 @@ namespace YoastSeoForTypo3\YoastSeo\Service\PageLayoutHeader; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use YoastSeoForTypo3\YoastSeo\Traits\BackendUserTrait; use YoastSeoForTypo3\YoastSeo\Utility\YoastUtility; @@ -31,25 +32,31 @@ public function shouldShowPreview(int $pageId, array $pageRecord): bool protected function isSnippetPreviewEnabled(int $pageId, array $pageRecord): bool { $backendUser = $this->getBackendUser(); - if (!$backendUser->check('non_exclude_fields', 'pages:tx_yoastseo_snippetpreview')) { return false; } - if ((bool)($backendUser->uc['hideYoastInPageModule'] ?? false)) { + if ($this->hideFromUserSettings($backendUser)) { return false; } $pageTsConfig = $this->getPageTsConfig($pageId); - if (isset($pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview']) - && (int)$pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'] === 1 - ) { + if ((int)($pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'] ?? 0) === 1) { return false; } return !((bool)($pageRecord['tx_yoastseo_hide_snippet_preview'] ?? false)); } + protected function hideFromUserSettings(BackendUserAuthentication $backendUser): bool + { + if (isset($backendUser->uc['hideYoastInPageModule'])) { + return (bool)$backendUser->uc['hideYoastInPageModule']; + } + + return false; + } + /** * @return array */