Making WordPress.org


Ignore:
Timestamp:
04/03/2020 01:45:43 AM (4 years ago)
Author:
dd32
Message:

WordPress.org: Downloads: Add Structured Data tags to the download pages.

Props dufresnesteven for initial patch.
Fixes #5079.

File:
1 edited

Legend:

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

    r9538 r9689  
    4747
    4848$latest_release_version   = WP_CORE_LATEST_RELEASE;
     49$latest_release_zip_ts    = defined( 'WPORG_WP_RELEASES_PATH' ) ? filemtime( WPORG_WP_RELEASES_PATH . 'wordpress-' . WP_CORE_LATEST_RELEASE . '.zip' ) : time();
    4950$latest_release_zip_url   = 'https://wordpress.org/latest.zip';
    5051$latest_release_targz_url = 'https://wordpress.org/latest.tar.gz';
     
    5556        $locale                   = get_locale();
    5657        $latest_release_version   = $rosetta_release['version'];
     58        $latest_release_zip_ts    = $rosetta_release['builton'];
    5759        $latest_release_zip_url   = home_url( "latest-{$locale}.zip" );
    5860        $latest_release_targz_url = home_url( "latest-{$locale}.tar.gz" );
     
    6365add_filter( 'jetpack_images_pre_get_images', function() {
    6466    return new \WP_Error();
     67} );
     68
     69// Add Schema.org structured data.
     70add_action( 'wp_head', function() use( $latest_release_version, $latest_release_zip_url, $latest_release_zip_ts ) {
     71    $graph_tags  = custom_open_graph_tags();
     72    $description = $graph_tags[ 'description' ] ?? '';
     73    ?>
     74    <script type="application/ld+json">
     75    [
     76        {
     77            "@context": "http://schema.org",
     78            "@type": [
     79                "SoftwareApplication",
     80                "Product"
     81            ],
     82            "name": "WordPress",
     83            "operatingSystem": [ "Linux", "Windows", "Unix", "Apache", "NGINX" ],
     84            "url": "<?php the_permalink(); ?>",
     85            "description": <?php echo wp_json_encode( $description ); ?>,
     86            "softwareVersion": <?php echo wp_json_encode( $latest_release_version ); ?>,
     87            "fileFormat": "application/zip",
     88            "downloadUrl": "<?php echo esc_url( $latest_release_zip_url ); ?>",
     89            "dateModified": "<?php echo gmdate( 'Y-m-d\TH:i:s\+00:00', $latest_release_zip_ts ); ?>",
     90            "applicationCategory": "WebApplication",
     91            "offers": {
     92                "@type": "Offer",
     93                "url": "<?php the_permalink(); ?>",
     94                "price": "0.00",
     95                "priceCurrency": "USD",
     96                "seller": {
     97                    "@type": "Organization",
     98                    "name": "WordPress.org",
     99                    "url": "https://wordpress.org"
     100                }
     101            }
     102        }
     103    ]
     104    </script>
     105    <?php
    65106} );
    66107
Note: See TracChangeset for help on using the changeset viewer.