Making WordPress.org

Changeset 13297


Ignore:
Timestamp:
03/07/2024 04:39:31 AM (13 months ago)
Author:
dd32
Message:

Robots.txt: Include subsite sitemaps in the make.wordpress.org/robots.txt file, and include wordpress.org/photos/ and wordpress.org/patterns/ sitemaps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-robots.php

    r13069 r13297  
    6565                  "Sitemap: https://wordpress.org/showcase/sitemap.xml\n" .
    6666                  "Sitemap: https://wordpress.org/documentation/sitemap.xml\n" .
     67                  "Sitemap: https://wordpress.org/patterns/sitemap.xml\n" .
     68                  "Sitemap: https://wordpress.org/photos/sitemap.xml\n" .
    6769                  $robots;
    6870    }
     
    8082    }
    8183
    82     /*
    83      * Add the Developer Blog sitemap.
    84      */
    85     if ( 'developer.wordpress.org' === $blog_details->domain ) {
    86         $robots = "Sitemap: https://developer.wordpress.org/news/sitemap.xml\n" .
    87                   "Sitemap: https://developer.wordpress.org/news/news-sitemap.xml\n" .
    88                   $robots;
     84    // Should all sub-sites sitemaps be included?
     85    if (
     86        'developer.wordpress.org' === $blog_details->domain ||
     87        'make.wordpress.org' === $blog_details->domain
     88    ) {
     89        $should_include_subsite_sitemaps = true;
     90    }
     91
     92    if ( $should_include_subsite_sitemaps && '/' === $blog_details->path ) {
     93        // Check all subsites.
     94        $sites = get_sites( [
     95            'network_id' => $blog_details->site_id,
     96            'domain'     => $blog_details->domain,
     97            'public'     => 1,
     98            'archived'   => 0,
     99        ] );
     100        foreach ( $sites as $site ) {
     101            if ( '/' === $site->path ) {
     102                continue;
     103            }
     104
     105            switch_to_blog( $site->blog_id );
     106
     107            // Are Jetpack Sitemaps enabled on a public site?
     108            if ( Jetpack::is_module_active( 'sitemaps' ) && get_option( 'blog_public' ) ) {
     109                // Load the modules, as the sitemaps may not be loaded.
     110                Jetpack::load_modules();
     111
     112                if (
     113                    class_exists( 'Jetpack_Sitemap_Manager' ) &&
     114                    is_callable( 'Jetpack_Sitemap_Manager', 'callback_action_do_robotstxt' )
     115                ) {
     116                    $sitemaps = new Jetpack_Sitemap_Manager();
     117                    ob_start();
     118                    $sitemaps->callback_action_do_robotstxt();
     119                    $robots = ob_get_clean() . $robots;
     120                }
     121            }
     122
     123            restore_current_blog();
     124        }
     125
    89126    }
    90127
Note: See TracChangeset for help on using the changeset viewer.