@@ -2743,6 +2743,26 @@ public function respondWithRequestedPageVariant()
27432743 }
27442744 return false ;
27452745 }
2746+ /**
2747+ * The absolute URL of the site's Contact page for structured data: the
2748+ * published page whose slug is "contact", or '' when there is none.
2749+ * $toAbsolute turns a site-relative slug into an absolute URL.
2750+ */
2751+ private function getContactPageUrlForStructuredData ($ toAbsolute )
2752+ {
2753+ $ items = isset ($ this ->manifest ->items ) && is_array ($ this ->manifest ->items ) ? $ this ->manifest ->items : array ();
2754+ foreach ($ items as $ item ) {
2755+ if (!is_object ($ item ) || !isset ($ item ->slug ) || !is_string ($ item ->slug )) {
2756+ continue ;
2757+ }
2758+ $ slug = trim ($ item ->slug , '/ ' );
2759+ if (strtolower ($ slug ) === 'contact ' && SiteRouteUtils ::isItemPublished ($ item )) {
2760+ return $ toAbsolute ($ slug );
2761+ }
2762+ }
2763+ return '' ;
2764+ }
2765+
27462766 /**
27472767 * Whether a page is published: what the shell and the page variants,
27482768 * served without a login, may show (SiteRouteUtils::isItemPublished).
@@ -3469,6 +3489,21 @@ public function getSiteMetadata($page = NULL, $domain = NULL, $cdn = '') {
34693489 if (count ($ siteSameAs ) > 0 ) {
34703490 $ publisherNode ['sameAs ' ] = $ siteSameAs ;
34713491 }
3492+ // what the site is, in its own words
3493+ $ siteDescription = isset ($ this ->manifest ->description ) ? trim ((string ) $ this ->manifest ->description ) : '' ;
3494+ if ($ siteDescription != '' ) {
3495+ $ publisherNode ['description ' ] = $ siteDescription ;
3496+ }
3497+ // how to reach the site: its published Contact page (slug "contact"),
3498+ // never the author's email
3499+ $ contactUrl = $ this ->getContactPageUrlForStructuredData ($ toAbsoluteStructuredDataUrl );
3500+ if ($ contactUrl != '' ) {
3501+ $ publisherNode ['contactPoint ' ] = array (
3502+ '@type ' => 'ContactPoint ' ,
3503+ 'contactType ' => 'customer support ' ,
3504+ 'url ' => $ contactUrl ,
3505+ );
3506+ }
34723507 if ($ authorNode !== null ) {
34733508 $ publisherNode ['founder ' ] = array (
34743509 '@id ' => $ authorNode ['@id ' ],
0 commit comments