WP_Sitemaps
- Since
- 5.5.0
- Source
wp-includes/sitemaps/class-wp-sitemaps.php:17
Class WP_Sitemaps.
Hooks fired · 1
Every hook that fires from inside WP_Sitemaps, in the order it appears in the class, grouped by the method that fires it.
Properties · 3
$indexWP_Sitemaps_Indexpublic- The main index of supported sitemaps.
$registryWP_Sitemaps_Registrypublic- The main registry of supported sitemaps.
$rendererWP_Sitemaps_Rendererpublic- An instance of the renderer class.
Methods · 8
- __construct()WP_Sitemaps constructor.
- init()Initiates all sitemap functionality.
- sitemaps_enabled()Determines whether sitemaps are enabled or not.
- register_sitemaps()Registers and sets up the functionality for all supported sitemaps.
- register_rewrites()Registers sitemap rewrite tags and routing rules.
- render_sitemaps()Renders sitemap templates based on rewrite rules.
- redirect_sitemapxml()Redirects a URL to the wp-sitemap.xml
- add_robots()Adds the sitemap index to robots.txt.
Source
#[AllowDynamicProperties]class WP_Sitemaps { /** * The main index of supported sitemaps. * * @since 5.5.0 * * @var WP_Sitemaps_Index */ public $index; /** * The main registry of supported sitemaps. * * @since 5.5.0 * * @var WP_Sitemaps_Registry */ public $registry; /** * An instance of the renderer class. * * @since 5.5.0 * * @var WP_Sitemaps_Renderer */ public $renderer; /** * WP_Sitemaps constructor. * * @since 5.5.0 */ public function __construct() { $this->registry = new WP_Sitemaps_Registry(); $this->renderer = new WP_Sitemaps_Renderer(); $this->index = new WP_Sitemaps_Index( $this->registry ); } /** * Initiates all sitemap functionality. * * If sitemaps are disabled, only the rewrite rules will be registered * by this method, in order to properly send 404s. * * @since 5.5.0 */ public function init() { // These will all fire on the init hook. $this->register_rewrites(); add_action( 'template_redirect', array( $this, 'render_sitemaps' ) ); if ( ! $this->sitemaps_enabled() ) { return; } $this->register_sitemaps(); // Add additional action callbacks. add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 ); } /** * Determines whether sitemaps are enabled or not. * * @since 5.5.0 * * @return bool Whether sitemaps are enabled. */ public function sitemaps_enabled() { $is_enabled = (bool) get_option( 'blog_public' ); /** * Filters whether XML Sitemaps are enabled or not. * * When XML Sitemaps are disabled via this filter, rewrite rules are still * in place to ensure a 404 is returned. *History
Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/sitemaps/class-wp-sitemaps.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.