Making WordPress.org


Ignore:
Timestamp:
09/24/2020 03:09:17 AM (5 years ago)
Author:
dd32
Message:

WordPress.org Learn: Sync with GitHub

https://github.com/WordPress/learn/compare/1d7ba6d647dca8345507f2a7ad22179513047909...403f2323659621ae92721adb79ff23ea3bb7d618

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-type.php

    r10283 r10284  
    1414add_action( 'manage_wporg_workshop_posts_custom_column', __NAMESPACE__ . '\render_workshop_list_table_columns', 10, 2 );
    1515add_filter( 'jetpack_sitemap_post_types', __NAMESPACE__ . '\jetpack_sitemap_post_types' );
     16add_filter( 'jetpack_page_sitemap_other_urls', __NAMESPACE__ . '\jetpack_page_sitemap_other_urls' );
    1617
    1718/**
     
    274275/**
    275276 * Register our post types with Jetpack Sitemaps.
     277 *
    276278 * @link https://developer.jetpack.com/hooks/jetpack_sitemap_post_types/
    277279 *
     
    285287    return $post_types;
    286288}
     289
     290/**
     291 * Register our post type archives with Jetpack Sitemaps.
     292 *
     293 * @link https://developer.jetpack.com/hooks/jetpack_page_sitemap_other_urls/
     294 *
     295 * @param array $urls
     296 * @return array
     297 */
     298function jetpack_page_sitemap_other_urls( $urls ) {
     299    foreach ( array( 'wporg_workshop', 'lesson-plan' ) as $post_type ) {
     300        $url = get_post_type_archive_link( $post_type );
     301        if ( ! $url ) {
     302            continue;
     303        }
     304
     305        $latest_post = get_posts( array(
     306            'post_type'   => $post_type,
     307            'numberposts' => 1,
     308            'orderby'     => 'date',
     309            'order'       => 'DESC',
     310        ) );
     311        if ( ! $latest_post ) {
     312            continue;
     313        }
     314
     315        $urls[] = array(
     316            'loc'     => $url,
     317            'lastmod' => gmdate(
     318                'Y-m-d\TH:i:s\Z',
     319                strtotime( $latest_post[0]->post_modified_gmt )
     320            ),
     321        );
     322    }
     323
     324    return $urls;
     325}
Note: See TracChangeset for help on using the changeset viewer.