Skip to content

Commit

Permalink
Use the full domain name (#214)
Browse files Browse the repository at this point in the history
* Use the full domain name

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

* network_site_url instead of get_site_url

* Capitalize return description.
  • Loading branch information
namithj authored Nov 30, 2024
1 parent f4326db commit b1104df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function admin_enqueue_scripts( $hook ) {
[
'ajax_url' => network_admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'aspireupdate-ajax' ),
'domain' => Utilities::get_top_level_domain(),
'domain' => Utilities::get_site_domain(),
'line_ending' => PHP_EOL,
'unexpected_error' => esc_html__( 'Unexpected Error', 'aspireupdate' ),
]
Expand Down
13 changes: 5 additions & 8 deletions includes/class-utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
* The Class for Admin Settings Page and functions to access Settings Values.
*/
class Utilities {

/**
* Get the top level domain name from the site URL.
* Get the domain name from the site URL.
*
* @return string the top level domain name.
* @return string The domain name.
*/
public static function get_top_level_domain() {
$site_url = get_site_url();
$domain_name = wp_parse_url( $site_url, PHP_URL_HOST );
$domain_parts = explode( '.', $domain_name );
return sanitize_text_field( implode( '.', array_slice( $domain_parts, -2 ) ) );
public static function get_site_domain() {
$site_url = network_site_url();
return wp_parse_url( $site_url, PHP_URL_HOST );
}

/**
Expand Down

0 comments on commit b1104df

Please sign in to comment.