Skip to content

Conversation

@Clorith
Copy link
Member

@Clorith Clorith commented Feb 18, 2025

The wp_get_api_hostname() function would allow hosters the ability to more easily set up local mirrors of the WordPress API.

This pull request summarizes some of the work already put into the ticket, and feedback from other communication platforms, so that all ideas are brought forth.

It introduces a new function, wp_get_api_hostname(), this is very directly named, as it relates to the base hostname used for API requests, and we wish to ensure its self evident what the intent of the function is.

It allows a hoster to define a WP_API_HOSTNAME environment variable, to pre-empt any installation steps, ensuring all requests are passed through their mirror from start to finish in the WP journey if need be.

It is also possible for a site to define the WP_API_HOSTNAME constant in their wp-config.php file, if they wish to diverge from the hosters predefined expectations.

And finally, there's the wp_api_hostname filter, for more fine grained control. Currently it does not pass any contexts, but it is easier to add to a filter later, than to take away from it, so this is a nice starting point for an initial implementation I think.

For more fine grained filtering control, the filters found within the WordPress HTTP API are better suited, but are not available to a site early enough in the flow to be usable for example during setup.

I've also simplified the Site Health outputs, instead of introducing extra checks, re-labeling the reference to "api.wordpress.org" to "the WordPress API" does the same, and by adding a field in the debug data section to reference what API host is returned, the information is still readily available if someone needs to look it up.

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


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.

…bility to more easily set up local mirrors of the WordPress API.
@github-actions
Copy link

github-actions bot commented Feb 18, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props clorith, sergeybiryukov, afragen, mindctrl.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…ite Health check, preventing a deprecation warning from being thrown if a scheme is not included
…rue` where the HTTP scheme was previously used in core for now.
@afragen
Copy link
Member

afragen commented Feb 27, 2025

This looks great @Clorith.

@afragen
Copy link
Member

afragen commented Mar 6, 2025

Any chance of getting this commited for 6.8? The beta period upon us.

@mindctrl
Copy link

mindctrl commented May 7, 2025

@Clorith @SergeyBiryukov this is looking nice! What remains to be done here? Happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants