Opened 16 months ago
Closed 2 months ago
#63467 closed defect (bug) (fixed)
function do_robots() should use admin_url()
| Reported by: | Hrohh | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Privacy | Version: | 6.8 |
| Severity: | normal | Keywords: | has-patch has-unit-tests commit |
| Cc: | Focuses: | administration, privacy |
Description
Dear all,
we have /wp-admin/ hardcoded in do_robots() function. How can i use filter admin_url('admin-ajax.php') ?
<?php $site_url = parse_url( site_url() ); $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : ''; $output .= "Disallow: $path/wp-admin/\n"; $output .= "Allow: $path/wp-admin/admin-ajax.php\n";
Thank you.
Change History (9)
#1
@
16 months ago
- Summary function do_robots() should use admin_url() a → function do_robots() should use admin_url()
This ticket was mentioned in PR #8834 on WordPress/wordpress-develop by @yogeshbhutkar.
16 months ago
#2
- Keywords has-patch added
This ticket was mentioned in PR #11998 on WordPress/wordpress-develop by @masteradhoc.
4 months ago
#3
- Keywords has-unit-tests added
Updates do_robots() to use filtered admin URL paths instead of hardcoded /wp-admin/ values.
This changes the default robots.txt output to derive the Disallow and Allow paths from admin_url() and admin_url( 'admin-ajax.php' ), while continuing to output only the path portion. This allows installs that filter admin URLs to generate correct robots.txt directives.
A PHPUnit regression test is included to verify that filtered admin paths are reflected in the do_robots() output.
Trac ticket: https://core.trac.wordpress.org/ticket/63467
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): GPT-5.4
Used for: Drafting the initial patch and regression test. The final implementation, test coverage, and PR description were reviewed and edited by me.
#4
@
4 months ago
Hey all
I've just refreshed the PR with test. Thanks to @yogeshbhutkar for the initial PR!
@mukesh27 As you've already checked the initial PR, can i ask you to check the refreshed PR as well?
I think we can Milestone this as we'll for 7.1 now.
Thanks
This ticket was mentioned in Slack in #meta by westonruter. View the logs.
3 months ago
@westonruter commented on PR #8834:
3 months ago
#8
Thank for for the PR. Closing in favor of https://github.com/WordPress/wordpress-develop/pull/11998
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: https://core.trac.wordpress.org/ticket/63467
### Description
This PR introduces the use of the
admin_url()function to dynamically retrieve the admin URL, replacing previously hardcoded values.### Screenshots