#56954 - Add 'doing_sitemap'#12150
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| */ | ||
| public function render_index( $sitemaps ) { | ||
| if ( ! defined( 'DOING_SITEMAP' ) ) { | ||
| define( 'DOING_SITEMAP', true ); |
There was a problem hiding this comment.
Instead of adding this here, I think it would be better to add the calling location:
This will make it easier to unit test and it could avoid having to define the constant in two different places. That render_sitemaps() method is already calling exit so it clearly isn't being unit tested yet.
| */ | ||
| public function render_sitemap( $url_list ) { | ||
| if ( ! defined( 'DOING_SITEMAP' ) ) { | ||
| define( 'DOING_SITEMAP', true ); |
There was a problem hiding this comment.
Suggest to remove this here per above.
There was a problem hiding this comment.
What about a unit test for this function and that adding a filter changes the output as expected.
Co-authored-by: Weston Ruter <westonruter@gmail.com>
This patch introduces a
DOING_SITEMAPconstant andwp_doing_sitemap()function, following the established pattern ofDOING_CRON/wp_doing_cron()andDOING_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.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.