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

Use the full domain name #214

Merged
merged 3 commits into from
Nov 30, 2024
Merged

Use the full domain name #214

merged 3 commits into from
Nov 30, 2024

Conversation

namithj
Copy link
Contributor

@namithj namithj commented Nov 29, 2024

Use the full domain name instead of attempting to extract the top level TLD

Pull Request

What changed?

Changed behavior of API Key call to use the full domain name instead of trying to extract the top TLD which can lead to parsing issues

Why did it change?

Extracting the top TLD was an unnecessary complication which is not required.

Did you fix any specific issues?

Fixes #194

CERTIFICATION

By opening this pull request, I do agree to abide by the Code of Conduct and be bound by the terms of the Contribution Guidelines in effect on the date and time of my contribution as proven by the revision information in GitHub.

Use the full domain name instead of attempting to extract the top level TLD
@namithj namithj requested review from costdev and a team November 29, 2024 02:55
@costdev
Copy link
Contributor

costdev commented Nov 29, 2024

Thanks @namithj! I'll review this one and run some tests for multisite.

$domain_parts = explode( '.', $domain_name );
return sanitize_text_field( implode( '.', array_slice( $domain_parts, -2 ) ) );
public static function get_site_domain() {
$site_url = get_site_url();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In multisite, plugins can only be installed on the network level. Therefore, the URL for the API should be the main site's URL.

With a multisite setup of:

When on Second site, get_site_url() will return https://my-other-site.com.

Use network_site_url() instead, as it will return https://my-site.com.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with above

Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small change for multisite support. 🙂

network_site_url instead of get_site_url
@namithj
Copy link
Contributor Author

namithj commented Nov 29, 2024

I have pushed an update, technically it wouldn't matter as the settings page can only run from the main site of the network but no harm in having the proper function in place.

Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @namithj!

Pre-approving, but do invite me for a re-review if you push the tests I sent you for this one just so the latest changes are also approved.

Signed-off-by: Colin Stewart <[email protected]>
@costdev costdev merged commit b1104df into aspirepress:main Nov 30, 2024
5 checks passed
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.

[Bug]: Utilities::get_top_level_domain() only works for single-part TLDs.
3 participants