-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensured that the last modification date from the jetpack_page_sitema…
…p_other_urls filter is considered for the last modification date of the generated sitemap. (#36991)
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/sitemap-consider-other-urls-lastmod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: other | ||
|
||
Sitemaps: Ensured that the last modification date from the jetpack_page_sitemap_other_urls filter is considered for the last modification date of the generated sitemap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
projects/plugins/jetpack/tests/php/modules/sitemaps/test-class.sitemap-builder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Tests for the Jetpack_Sitemap_Builder class. | ||
* | ||
* @package automattic/jetpack | ||
* @since $$next-version$$ | ||
*/ | ||
|
||
/** | ||
* Test class for Jetpack_Sitemap_Builder. | ||
* | ||
* @since $$next-version$$ | ||
*/ | ||
class WP_Test_Jetpack_Sitemap_Builder extends WP_UnitTestCase { | ||
|
||
/** | ||
* "lastmod" date from other URLs filter is considered when building a sitemap. | ||
* | ||
* @covers Jetpack_Sitemap_Builder::build_one_page_sitemap | ||
* @group jetpack-sitemap | ||
* @since $$next-version$$ | ||
*/ | ||
public function test_build_one_page_sitemap_considers_lastmod_from_other_urls() { | ||
$other_urls = array( | ||
array( | ||
'loc' => 'https://example.com/1', | ||
'lastmod' => '2019-01-01T00:00:00Z', | ||
), | ||
array( | ||
'loc' => 'https://example.com/2', | ||
'lastmod' => '2024-03-08T01:02:03Z', | ||
), | ||
array( | ||
'loc' => 'https://example.com/3', | ||
'lastmod' => '2022-02-02T00:00:00Z', | ||
), | ||
); | ||
|
||
$callback = function () use ( $other_urls ) { | ||
return $other_urls; | ||
}; | ||
|
||
add_filter( 'jetpack_page_sitemap_other_urls', $callback ); | ||
|
||
$builder = new Jetpack_Sitemap_Builder(); | ||
$result = $builder->build_one_page_sitemap( 1, 1 ); | ||
|
||
remove_filter( 'jetpack_page_sitemap_other_urls', $callback ); | ||
|
||
$this->assertSame( '2024-03-08T01:02:03Z', $result['last_modified'], 'Last modified date is not the one from the other_urls filter.' ); | ||
} | ||
} |