Skip to content
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

Investigate compatibility with WPML, Polylang, etc #231

Closed
westonruter opened this issue Jan 7, 2020 · 7 comments · Fixed by #266
Closed

Investigate compatibility with WPML, Polylang, etc #231

westonruter opened this issue Jan 7, 2020 · 7 comments · Fixed by #266
Milestone

Comments

@westonruter
Copy link
Collaborator

When a translation plugin forces the home_url() to have a language-specific prefix, this could cause problems for the start_url in the web app manifest and also the service worker URL.

See https://wordpress.org/support/topic/compatibility-with-wpml-70/

@westonruter
Copy link
Collaborator Author

This came up again with the WPGlobus plugin: https://wordpress.org/support/topic/does-not-display-9/

The start_url in the manifest is incorrectly using a locale-specific subdirectory, and the service worker is incorrectly being installed from that subdirectory as opposed from the root.

@westonruter westonruter added this to the 0.4 milestone Mar 16, 2020
@westonruter
Copy link
Collaborator Author

One possibility would be to use the site_url() as opposed to the home_url(). But this may have other unintended consequences (like pointing to another domain entirely). We could discard the hostname, however. What we need is to identify the path to the root of where WordPress is installed. We need to take care for subdirectory installs and subdirectory multisite configurations.

@westonruter
Copy link
Collaborator Author

Perhaps instead of home_url() a safer bet would be to use wp_parse_url( site_url( '/' ), PHP_URL_PATH ).

@westonruter
Copy link
Collaborator Author

No, that won't work either. When WordPress core is installed in a subdirectory that is different than the site root, this would result in something like /wordpress/ being the path.

@westonruter
Copy link
Collaborator Author

westonruter commented Mar 16, 2020

Perhaps what is needed is the logic from get_home_url() but omit the apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ). For example:

$url = trailinglsashit( set_url_scheme( get_option( 'home' ), 'https' ) );

@westonruter
Copy link
Collaborator Author

@lkraav Would you give this fix a try: #266 (comment)

Instead of bypassing the home_url filter, the easier (and safer) fix seems to be to consistently use the relative scheme when invoking home_url() for both the script src and the service worker scope.

@westonruter
Copy link
Collaborator Author

Apparently it's still not working properly with Polylang: https://wordpress.org/support/topic/nothing-has-changed-after-installation/

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

Successfully merging a pull request may close this issue.

1 participant