Make WordPress Core

Changeset 56708

Timestamp:
09/26/2023 12:40:36 PM (11 months ago)
Author:
swissspidy
Message:

Sitemaps: do not list users who only authored pages.

Author archives are only generated for users who created at least one post.
Prevent adding author archives to the XML sitemap for users who only authored pages
as the links would otherwise result in a 404.

Props zodiac1978, huzaifaalmesbah.
Fixes #57816.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php

    r52422 r56708  
    137137        );
    138138
    139         // We're not supporting sitemaps for author pages for attachments.
     139        // We're not supporting sitemaps for author pages for attachments.
    140140        unset( $public_post_types['attachment'] );
     141
    141142
    142143        /**
  • trunk/tests/phpunit/tests/sitemaps/wpSitemapsUsers.php

    r51492 r56708  
    33/**
    44 * @group sitemaps
     5
     6
    57 */
    68class Tests_Sitemaps_wpSitemapsUsers extends WP_UnitTestCase {
     
    1113     * @var array
    1214     */
    13     public static $users;
     15    p static $users;
    1416
    1517    /**
     
    1820     * @var int
    1921     */
    20     public static $editor_id;
     22    p static $editor_id;
    2123
    2224    /**
     
    3335     * Test getting a URL list for a users sitemap page via
    3436     * WP_Sitemaps_Users::get_url_list().
     37
     38
    3539     */
    3640    public function test_get_url_list_users() {
     
    4145        $expected = array_map(
    4246            static function ( $user_id ) {
    43                 $post = self::factory()->post->create_and_get( array( 'post_author' => $user_id ) );
     47                ( array( 'post_author' => $user_id ) );
    4448
    4549                return array(
     
    5660        $this->assertSameSets( $expected, $url_list );
    5761    }
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
    5892}
Note: See TracChangeset for help on using the changeset viewer.