From: joshuaruesweg Date: Sun, 4 Apr 2021 19:49:45 +0000 (+0200) Subject: Add meta tags for trophy page X-Git-Tag: 5.4.0_Alpha_1~120 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=298cb6fda16a7bd48c8c5b234a72c95e40cb18cb;p=GitHub%2FWoltLab%2FWCF.git Add meta tags for trophy page --- diff --git a/wcfsetup/install/files/lib/page/TrophyPage.class.php b/wcfsetup/install/files/lib/page/TrophyPage.class.php index 312330c26e..2bca822ec2 100644 --- a/wcfsetup/install/files/lib/page/TrophyPage.class.php +++ b/wcfsetup/install/files/lib/page/TrophyPage.class.php @@ -13,9 +13,11 @@ use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\PermissionDeniedException; +use wcf\system\MetaTagHandler; use wcf\system\page\PageLocationManager; use wcf\system\request\LinkHandler; use wcf\system\WCF; +use wcf\util\StringUtil; /** * Represents a trophy page. @@ -90,6 +92,33 @@ class TrophyPage extends MultipleLinkPage $this->trophy->getCategory()->getObjectID(), $this->trophy->getCategory() ); + + // Add meta tags. + MetaTagHandler::getInstance()->addTag( + 'og:title', + 'og:title', + $this->trophy->getTitle() . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), + true + ); + MetaTagHandler::getInstance()->addTag('og:url', 'og:url', $this->trophy->getLink(), true); + + if ($this->trophy->getDescription()) { + MetaTagHandler::getInstance()->addTag( + 'og:description', + 'og:description', + StringUtil::decodeHTML(StringUtil::stripHTML($this->trophy->getDescription())), + true + ); + } + + if ($this->trophy->type == Trophy::TYPE_IMAGE) { + MetaTagHandler::getInstance()->addTag( + 'og:image', + 'og:image', + WCF::getPath() . 'images/trophy/' . $this->trophy->iconFile, + true + ); + } } /**