class-wp-sitemaps-test-provider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Class WP_Sitemaps_Test_Provider.
  4. *
  5. * Provides test data for additional registered providers.
  6. */
  7. class WP_Sitemaps_Test_Provider extends WP_Sitemaps_Provider {
  8. /**
  9. * WP_Sitemaps_Posts constructor.
  10. *
  11. * @param string $object_type Optional. Object type name to use. Default 'test'.
  12. */
  13. public function __construct( $object_type = 'test' ) {
  14. $this->object_type = $object_type;
  15. }
  16. /**
  17. * Return the public post types, which excludes nav_items and similar types.
  18. * Attachments are also excluded. This includes custom post types with public = true
  19. *
  20. * @return array Map of object subtype objects (WP_Post_Type) keyed by their name.
  21. */
  22. public function get_object_subtypes() {
  23. return array(
  24. 'type-1' => (object) array( 'name' => 'type-1' ),
  25. 'type-2' => (object) array( 'name' => 'type-2' ),
  26. 'type-3' => (object) array( 'name' => 'type-3' ),
  27. );
  28. }
  29. /**
  30. * Gets a URL list for a sitemap.
  31. *
  32. * @param int $page_num Page of results.
  33. * @param string $object_subtype Optional. Object subtype name. Default empty.
  34. * @return array List of URLs for a sitemap.
  35. */
  36. public function get_url_list( $page_num, $object_subtype = '' ) {
  37. return array();
  38. }
  39. /**
  40. * Query for determining the number of pages.
  41. *
  42. * @param string $object_subtype Optional. Object subtype. Default empty.
  43. * @return int Total number of pages.
  44. */
  45. public function get_max_num_pages( $object_subtype = '' ) {
  46. return 4;
  47. }
  48. }