Make WordPress Core

Opened 4 years ago

Closed 3 months ago

Last modified 3 months ago

#56954 closed enhancement (wontfix)

Add action or constant 'doing_sitemap'

Reported by: Cybr Owned by: westonruter
Priority: normal Milestone:
Component: Sitemaps Version:
Severity: normal Keywords: has-patch close 2nd-opinion
Cc: Focuses:

Description

At WP_Sitemaps_Renderer::render_sitemap() and WP_Sitemaps_Renderer::render_index(), all preliminary checks for proper sitemap display have been conducted.

To verify we're on an actual sitemap output page, it'd be helpful to have a constant or function asserting we reached this state. Such as define( 'DOING_SITEMAP', true );.

A use case I'm facing is filtering posts in archives from visitors but not necessarily search engines.

Change History (10)

This ticket was mentioned in ​PR #12142 on ​WordPress/wordpress-develop by ​@masteradhoc.


4 months ago
#1

  • Keywords has-patch added

This patch introduces two complementary ways to detect a sitemap request in WordPress core, following established patterns for is_robots()/is_favicon() and DOING_CRON/DOING_AJAX.

Trac ticket: https://core.trac.wordpress.org/ticket/56954
Trac ticket: https://core.trac.wordpress.org/ticket/51543

## Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Initial implementation scaffolding. All code was reviewed, adjusted, and tested by me.

This ticket was mentioned in ​PR #12150 on ​WordPress/wordpress-develop by ​@masteradhoc.


4 months ago
#2

This patch introduces a DOING_SITEMAP constant and wp_doing_sitemap() function, following the established pattern of DOING_CRON/wp_doing_cron() and DOING_AJAX/wp_doing_ajax().

Trac ticket: https://core.trac.wordpress.org/ticket/56954

## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Initial implementation scaffolding. All code was reviewed,
adjusted, and tested by me.

​@masteradhoc commented on ​PR #12142:


4 months ago
#3

@mukeshpanchal27 to make reviewing easier i split the second trac ticket to a own PR, see: ​https://github.com/WordPress/wordpress-develop/pull/12150

#4 @masteradhoc
4 months ago

  • Milestone Awaiting Review → 7.1

​@westonruter commented on ​PR #12142:


4 months ago
#5

✅ New code passes PHPStan rule level 10 with the bleeding edge ruleset.

#6 @westonruter
4 months ago

  • Owner set to westonruter
  • Status new → reviewing

​@masteradhoc commented on ​PR #12142:


4 months ago
#7

@westonruter thanks to @nimesh-xecurify we have now tests as well for this PR :)

#8 @westonruter
3 months ago

  • Keywords close 2nd-opinion added

@masteradhoc I'm wondering now whether we really need this at all. We have is_sitemap() from #51543 which should satisfy this requirement.

#9 @peterwilsoncc
3 months ago

  • Milestone 7.1
  • Resolution → wontfix
  • Status reviewing → closed

I agree with @westonruter that the introduction of is_sitemap() serves this purpose so there's no need to add the constant and this can be closed as unplanned.

Note: See TracTickets for help on using tickets.