Changeset 56985
- Timestamp:
- 10/23/2023 03:40:44 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php
r54855 r56985 113 113 ); 114 114 115 /* 116 * Get the most recent posts displayed on the homepage, 117 * and then sort them by their modified date to find 118 * the date the homepage was approximately last updated. 119 */ 120 $latest_posts = new WP_Query( 121 array( 122 'post_type' => 'post', 123 'post_status' => 'publish', 124 'orderby' => 'date', 125 'order' => 'DESC', 126 'no_found_rows' => true, 127 'update_post_meta_cache' => false, 128 'update_post_term_cache' => false, 129 ) 130 ); 131 132 if ( ! empty( $latest_posts->posts ) ) { 133 $posts = wp_list_sort( $latest_posts->posts, 'post_modified_gmt', 'DESC' ); 134 $sitemap_entry['lastmod'] = wp_date( DATE_W3C, strtotime( $posts[0]->post_modified_gmt ) ); 135 } 136 115 137 /** 116 138 * Filters the sitemap entry for the home page when the 'show_on_front' option equals 'posts'. … … 126 148 foreach ( $query->posts as $post ) { 127 149 $sitemap_entry = array( 128 'loc' => get_permalink( $post ), 150 'loc' => get_permalink( $post ), 151 'lastmod' => wp_date( DATE_W3C, strtotime( $post->post_modified_gmt ) ), 129 152 ); 130 153 -
trunk/tests/phpunit/tests/sitemaps/sitemaps.php
r51492 r56985 252 252 $post_list = $providers['posts']->get_url_list( 1, 'page' ); 253 253 254 $post_list_sorted = wp_list_sort( $post_list, 'lastmod', 'DESC' ); 255 254 256 $expected = $this->_get_expected_url_list( 'page', self::$pages ); 255 257 … … 258 260 $expected, 259 261 array( 260 'loc' => home_url( '/' ), 262 'loc' => home_url( '/' ), 263 'lastmod' => $post_list_sorted[0]['lastmod'], 261 264 ) 262 265 ); … … 379 382 static function ( $post ) { 380 383 return array( 381 'loc' => get_permalink( $post ), 384 'loc' => get_permalink( $post ), 385 'lastmod' => get_post_modified_time( DATE_W3C, true, $post ), 382 386 ); 383 387 }, -
trunk/tests/phpunit/tests/sitemaps/wpSitemapsPosts.php
r53556 r56985 60 60 $sitemap_entry = array_shift( $url_list ); 61 61 62 $this->assertArrayHasKey( 'lastmod', $sitemap_entry ); 62 $this->assertEqualSetsWithIndex( 63 array( 64 'loc' => home_url( '/' ), 65 'lastmod' => '2000-01-01', 66 ), 67 $sitemap_entry 68 ); 63 69 } 64 70 … … 67 73 */ 68 74 public function _show_on_front_entry( $sitemap_entry ) { 69 $sitemap_entry['lastmod'] = wp_date( DATE_W3C, time() );75 $sitemap_entry['lastmod'] = '2000-01-01'; 70 76 71 77 return $sitemap_entry; … … 94 100 95 101 foreach ( $post_ids as $post_id ) { 96 $expected[] = array( 'loc' => home_url( "?p={$post_id}" ) ); 102 $expected[] = array( 103 'loc' => home_url( "?p={$post_id}" ), 104 'lastmod' => get_post_modified_time( DATE_W3C, true, $post_id ), 105 ); 97 106 } 98 107
Note: See TracChangeset
for help on using the changeset viewer.