-
Notifications
You must be signed in to change notification settings - Fork 805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST API: Use home URL as unmapped URL #13818
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: November 5, 2019. |
Noting that D34373 has green tests. Not sure how to re-trigger the PR check here. We might need to rebase? |
One way to test this is with a JN site and the
add_filter( 'home_url', function () { return 'testing'; } ); With D34373-code on a sandbox and the API sandboxed, we should be able to make the API calls above and get the correct unmapped URL. |
With a standalone, subdirectory install on Linode that appears to be working properly, the site URL looks like |
Subdirectory installs typically have a home URL pointing to the root address (i.e.
Seems to be normal, given the site has a custom permalink: Does Calypso refuse from previewing those links? |
I think there is an issue with the Linode site and probably it is not correctly configured. Trying to load a post (i.e. I'm trying now setting up a local env with Chassis, which seems to install WordPress in a subdirectory out-of-the-box. |
No luck with this since the site is not publicly available (so Jetpack cannot connect to it) and ngrok doesn't help given that it only exposes the site under |
Updated the testing instructions with the fake method suggested by @kwight. I tried that and it seems to work (despite being impossible to load the admin pages). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mob tested with @mmtr @kwight and @gwwar. For a subdirectory install, verified a 404 preview before and a working preview after with this branch and diff applied.
Kudos to @griffbrad for providing the testing site! ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work well in my tests. Merging.
* 7.9: Changelog * Update version number * Update stable tag and tested up to * Changelog: add #13530 * changelog: add #13578 * Changelog: add #13598 * Changelog: add entry for numerous block preview changes * Changelog: add #13599 * changelog: add #13541 * Changelog: add #13542 * Changelog: add #13331 * Changelog: add #13558 * Changelog: add #13409 * Changelog: add #13582 * Changelog: add #13600 * Changelog: add #13601 * Changelog: add #13595 * Changelog: add #12695 * Changelog: add #13009 * Changelog: add #13649 * Changelog: add #13450 * Changelog: add #13507 * Changelog: add #13658 * Changelog: add #13687 * changelog: add #13683 * Changelog: add #9323 * Changelog: add #13681 * Fix typos in readme * Add link to WordPress Beta Tester plugin * Changelog: add #13630 * Changelog: add #13695 * Changelog: add #13659 * Changelog: add #13716 * Changelog: add #13664 * Changelog: add #13682 * Changelog: add #13362 * Changelog: add #13563 * Add testing list for #13563 * Changelog: add #13735 * Changelog: add #13752 * Changelog: add #13624 * Changelog: add #13756 * Changelog: add #13745 * Changelog: add #13728 * Changelog: add #13779 * Changelog: add #13699 * Changelog: add #13804 * Changelog: add #13761 * Changelog: add #13637 * Changelog: add #13517 * Changelog: add #13521 * Changelog: add #13729 * Testing list: add testing instructions for #13729 * Changelog: add sync changes * Changelog: add #13807 * Changelog: add #13654 * Changelog: add #13795 * Changelog: add #13801 * Changelog: add #13818 * Changelog: add #13725 * Changelog: add #13831 * Changelog: add #13516 * Testing list: add Twenty Twenty instructions * Changelog: add #13799 * Changelog: add #13805 * Changelog: add #13688 * Changelog: add #13830
Fixes Automattic/wp-calypso#36837
Changes proposed in this Pull Request:
Uses the site URL used as the value of the
unmapped_url
option returned when requesting a site via REST API.WordPress.com sites stores in the
siteurl
option the*.wordpress.com
domain of a site, but this does not apply for Jetpack sites where that option could be the default value (same mapped domain as the home URL) or a custom URL defined by the user (i.e. subdirectory installs) that is not intended to be used as unmapped URL.Given that Jetpack sites don't have an unmapped URL (they all have a mapped domain and can be accessed only through that mapped domain), this PR ensures its value fallbacks to the home URL (which is actually the mapped domain).
This was resulting in issues like Automattic/wp-calypso#36837, caused by Calypso building a wrong preview URL due to the unmapped URL pointing to the subdirectory where the WordPress files live.
Quick note to understand the differences between site and home URLs, since it can be very easy to confuse them:
/wp-content/
and/wp-include
. The value of this setting is displayed in the "Settings > General" screen as "WordPress Address (URL)". It is defined by theWP_SITEURL
constant and stored in thesiteurl
site option.WP_HOME
constant and stored in thehome
site option.Is this a new feature or does it add/remove features to an existing part of Jetpack?
Fix an existing bug in the REST API shared with WP.com
Testing instructions:
public-api.wordpress.com
.GET
request tohttps://public-api.wordpress.com/rest/v1.1/sites/<YOUR_JETPACK_SITE>?fields=ID,URL,options&options=unmapped_url
.unmapped_url
option points to the home URL of your site.https://wordpress.com/posts/<YOUR_JETPACK_SITE>
.Further testing
*.wordpress.com
URL in an iframe for Simple sites, and redirect to the WP Admin customizer for Jetpack sites.wp-includes
and it is built using the unmapped URL:.
Proposed changelog entry for your changes:
REST API: Use home URL as unmapped URL