Skip to content

Commit 4a3f2f4

Browse files
Copilotswissspidy
andcommitted
Fix code style issues - use wp_parse_url and elseif structure
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 4b38f58 commit 4a3f2f4

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/Site_Command.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public function create( $args, $assoc_args ) {
449449
$base = null;
450450

451451
if ( $has_site_url ) {
452-
$parsed_url = parse_url( $assoc_args['site-url'] );
452+
$parsed_url = wp_parse_url( $assoc_args['site-url'] );
453453
if ( ! isset( $parsed_url['host'] ) ) {
454454
WP_CLI::error( 'Invalid URL format. Please provide a valid URL (e.g., http://site.example.com).' );
455455
}
@@ -545,16 +545,14 @@ public function create( $args, $assoc_args ) {
545545
$newdomain = $base . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
546546
$path = $current_site->path;
547547
}
548+
} elseif ( null !== $custom_domain ) {
549+
// Use custom domain and path if provided via --site-url
550+
$newdomain = $custom_domain;
551+
$path = $custom_path;
548552
} else {
549-
if ( null !== $custom_domain ) {
550-
// Use custom domain and path if provided via --site-url
551-
$newdomain = $custom_domain;
552-
$path = $custom_path;
553-
} else {
554-
// Use default behavior
555-
$newdomain = $current_site->domain;
556-
$path = $current_site->path . $base . '/';
557-
}
553+
// Use default behavior
554+
$newdomain = $current_site->domain;
555+
$path = $current_site->path . $base . '/';
558556
}
559557

560558
$user_id = email_exists( $email );

0 commit comments

Comments
 (0)