class-wp-sitemaps-large-test-provider.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Class WP_Sitemaps_Large_Test_Provider.
  4. *
  5. * Provides test data for additional registered providers.
  6. */
  7. class WP_Sitemaps_Large_Test_Provider extends WP_Sitemaps_Provider {
  8. /**
  9. * Number of entries in the sitemap the provider produces.
  10. *
  11. * @var integer
  12. */
  13. public $num_entries = 1;
  14. /**
  15. * WP_Sitemaps_Large_Test_Provider constructor.
  16. *
  17. * @param int $num_entries Optional. Number of entries in in the sitemap.
  18. */
  19. public function __construct( $num_entries = 50001 ) {
  20. $this->name = 'tests';
  21. $this->object_type = 'test';
  22. $this->num_entries = $num_entries;
  23. }
  24. /**
  25. * Gets a URL list for a sitemap.
  26. *
  27. * @param int $page_num Page of results.
  28. * @param string $object_subtype Optional. Object subtype name. Default empty.
  29. * @return array List of URLs for a sitemap.
  30. */
  31. public function get_url_list( $page_num, $object_subtype = '' ) {
  32. return array_fill( 0, $this->num_entries, array( 'loc' => home_url( '/' ) ) );
  33. }
  34. /**
  35. * Lists sitemap pages exposed by this provider.
  36. *
  37. * The returned data is used to populate the sitemap entries of the index.
  38. *
  39. * @return array[] Array of sitemap entries.
  40. */
  41. public function get_sitemap_entries() {
  42. return array_fill( 0, $this->num_entries, array( 'loc' => home_url( '/' ) ) );
  43. }
  44. /**
  45. * Query for determining the number of pages.
  46. *
  47. * @param string $object_subtype Optional. Object subtype. Default empty.
  48. * @return int Total number of pages.
  49. */
  50. public function get_max_num_pages( $object_subtype = '' ) {
  51. return $this->num_entries;
  52. }
  53. }