Skip to content

Ensure compatibility with Google Site Kit #4

@adamsilverstein

Description

@adamsilverstein

Hi! Adam here from the Google Site Kit team (https://sitekit.withgoogle.com).

We recently had some users reporting issues when they were using translatepress and Site Kit at the same time. (WordPress support forum and also here).

The underlying issue is that Site Kit identifies site's by their URL, as returned by WordPress's home_url function. When we detect that a site's URL has changed, we prompt (/force) the user to reconnect their site (going thru the auth process again). We do this to help users when they change their site URL for any reason (because otherwise, their connection is broken).

As a consequence, when plugins filter the home_url this logic can cause issues as the user gets unexpectedly disconnected. translatepress does this in add_language_to_home_url.

To improve compatibility in these types of situations, in Site Kit we added a googlesitekit_canonical_home_url filter (in google/site-kit-wp#2131). Site Kit uses the URL returned from this filter as our canonical URL, and as long as this URL doesn't change users will remain connected.

Using this filter, translatepress could add compatibility with Site Kit by returning the root site url of the site.

Pseudo code:

add_filter(
	'googlesitekit_canonical_home_url',
	function( $url ) {
		return $url_converter->get_abs_home(); // return root url.
	}
);

I would be happy to open a PR with this change. Is this something you would consider adding to your plugin?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions