WordPress.org

Making WordPress.org

Changeset 7961


Ignore:
Timestamp:
12/09/2018 07:02:49 PM (8 months ago)
Author:
obenland
Message:

Main: Add site's attribute schema.

Props jonoaldersonwp.
Fixes #3982.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/inc/page-meta-descriptions.php

    r7900 r7961  
    155155
    156156/**
     157 * Renders site's attributes for Rosetta sites.
     158 *
     159 * @see https://developers.google.com/search/docs/guides/enhance-site
     160 */
     161function sites_attributes_schema() {
     162    if ( ! is_front_page() ) {
     163        return;
     164    }
     165
     166    $og_tags = \WordPressdotorg\MainTheme\custom_open_graph_tags();
     167    $locale  = $GLOBALS['rosetta']->rosetta->glotpress_locale;
     168    ?>
     169<script type="application/ld+json">
     170{
     171    "@context":"https://schema.org",
     172    "@graph":[
     173        {
     174            "@type":"Organization",
     175            "@id":"https://wordpress.org/#organization",
     176            "url":"https://wordpress.org/",
     177            "name":"WordPress",
     178            "logo":{
     179                "@type":"ImageObject",
     180                "@id":"https://wordpress.org/#logo",
     181                "url":"https://s.w.org/style/images/about/WordPress-logotype-wmark.png"
     182            },
     183            "sameAs":[
     184                "https://www.facebook.com/WordPress/",
     185                "https://twitter.com/WordPress",
     186                "https://en.wikipedia.org/wiki/WordPress"
     187            ]
     188        },
     189        {
     190            "@type":"WebSite",
     191            "@id":"<?php echo esc_js( home_url( '/#website' ) ); ?>",
     192            "url":"<?php echo esc_js( home_url( '/' ) ); ?>",
     193            "name":"<?php echo esc_js( sprintf( __( 'WordPress - %s', 'wporg' ), $locale->native_name ) ); ?>",
     194            "publisher":{
     195                "@id":"https://wordpress.org/#organization"
     196            }
     197        },
     198        {
     199            "@type":"WebPage",
     200            "@id":"<?php echo esc_js( home_url( '/' ) ); ?>",
     201            "url":"<?php echo esc_js( home_url( '/' ) ); ?>",
     202            "inLanguage":"<?php echo esc_js( $locale->slug ); ?>",
     203            "name":"<?php echo esc_js( $og_tags['og:title'] ); ?>",
     204            "description":"<?php echo esc_js( $og_tags['og:description'] ); ?>",
     205            "isPartOf":{
     206                "@id":"<?php echo esc_js( home_url( '/#website' ) ); ?>"
     207            }
     208        }
     209    ]
     210}
     211</script>
     212<?php
     213}
     214add_action( 'wp_head', __NAMESPACE__ . '\sites_attributes_schema' );
     215
     216/**
    157217 * Maps page titles to translatable strings.
    158218 *
Note: See TracChangeset for help on using the changeset viewer.