From d134ede053b7c854edcbc5e49467528b23e62805 Mon Sep 17 00:00:00 2001 From: Ben Ritner Date: Wed, 11 Dec 2024 13:02:07 -0700 Subject: [PATCH 1/2] Account for an empty siteurl in the database --- src/Uplink/Site/Data.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Uplink/Site/Data.php b/src/Uplink/Site/Data.php index 0a02f68e..ca658c04 100644 --- a/src/Uplink/Site/Data.php +++ b/src/Uplink/Site/Data.php @@ -155,7 +155,10 @@ public function get_domain( bool $original = false ): string { protected function get_domain_multisite_option(): string { /** @var string */ $site_url = get_site_option( 'siteurl', '' ); - + // Fallback to get_site_url function if the network site url is empty which is possible. + if ( empty( $site_url ) ) { + $site_url = get_site_url(); + } /** @var array */ $site_url = wp_parse_url( $site_url ); if ( ! $site_url || ! isset( $site_url['host'] ) ) { From 82d3e1992d15acb108f7c4beb5c4c2a77c11c893 Mon Sep 17 00:00:00 2001 From: Ben Ritner Date: Wed, 11 Dec 2024 16:54:57 -0700 Subject: [PATCH 2/2] apply change --- src/Uplink/Site/Data.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Uplink/Site/Data.php b/src/Uplink/Site/Data.php index ca658c04..38a5a046 100644 --- a/src/Uplink/Site/Data.php +++ b/src/Uplink/Site/Data.php @@ -154,11 +154,8 @@ public function get_domain( bool $original = false ): string { */ protected function get_domain_multisite_option(): string { /** @var string */ - $site_url = get_site_option( 'siteurl', '' ); - // Fallback to get_site_url function if the network site url is empty which is possible. - if ( empty( $site_url ) ) { - $site_url = get_site_url(); - } + $site_url = get_site_option( 'siteurl', '' ) ?: get_site_url(); // Fallback to get_site_url function if the network site url is empty which is possible. + /** @var array */ $site_url = wp_parse_url( $site_url ); if ( ! $site_url || ! isset( $site_url['host'] ) ) {