mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
While web crawlers are able to discover pages from links within the site and from other sites, XML sitemaps supplement this approach by allowing crawlers to quickly and comprehensively identify all URLs included in the sitemap and learn other signals about those URLs using the associated metadata. See https://make.wordpress.org/core/2020/06/10/merge-announcement-extensible-core-sitemaps/ for more details. This feature exposes the sitemap index via `/wp-sitemap.xml` and exposes a variety of new filters and hooks for developers to modify the behavior. Users can disable sitemaps completely by turning off search engine visibility in WordPress admin. This change also introduces a new `esc_xml()` function to escape strings for output in XML, as well as XML support to `wp_kses_normalize_entities()`. Props Adrian McShane, afragen, adamsilverstein, casiepa, flixos90, garrett-eclipse, joemcgill, kburgoine, kraftbj, milana_cap, pacifika, pbiron, pfefferle, Ruxandra Gradina, swissspidy, szepeviktor, tangrufus, tweetythierry. Fixes #50117. See #3670. See #19998. git-svn-id: https://develop.svn.wordpress.org/trunk@48072 602fd350-edb4-49c9-b593-d223f7449a82
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group sitemaps
|
|
*/
|
|
class Test_WP_Sitemaps_Users extends WP_UnitTestCase {
|
|
/**
|
|
* List of user IDs.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $users;
|
|
|
|
/**
|
|
* Editor ID for use in some tests.
|
|
*
|
|
* @var int
|
|
*/
|
|
public static $editor_id;
|
|
|
|
/**
|
|
* Set up fixtures.
|
|
*
|
|
* @param WP_UnitTest_Factory $factory A WP_UnitTest_Factory object.
|
|
*/
|
|
public static function wpSetUpBeforeClass( $factory ) {
|
|
self::$users = $factory->user->create_many( 10, array( 'role' => 'editor' ) );
|
|
self::$editor_id = self::$users[0];
|
|
}
|
|
|
|
/**
|
|
* Test getting a URL list for a users sitemap page via
|
|
* WP_Sitemaps_Users::get_url_list().
|
|
*/
|
|
public function test_get_url_list_users() {
|
|
// Set up the user to an editor to assign posts to other users.
|
|
wp_set_current_user( self::$editor_id );
|
|
|
|
// Create a set of posts for each user and generate the expected URL list data.
|
|
$expected = array_map(
|
|
static function ( $user_id ) {
|
|
$post = self::factory()->post->create_and_get( array( 'post_author' => $user_id ) );
|
|
|
|
return array(
|
|
'loc' => get_author_posts_url( $user_id ),
|
|
);
|
|
},
|
|
self::$users
|
|
);
|
|
|
|
$user_provider = new WP_Sitemaps_Users();
|
|
|
|
$url_list = $user_provider->get_url_list( 1 );
|
|
|
|
$this->assertEqualSets( $expected, $url_list );
|
|
}
|
|
}
|