Skip to content

Commit f6e02b7

Browse files
Copilotswissspidy
andcommitted
Rename --url to --site-url to avoid conflict with global WP-CLI parameter
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent ea3049e commit f6e02b7

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

features/site-create.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Feature: Create a new site on a WP multisite
9797
Scenario: Create site with custom URL in subdomain multisite
9898
Given a WP multisite subdomain install
9999
100-
When I run `wp site create --url=http://custom.example.com`
100+
When I run `wp site create --site-url=http://custom.example.com`
101101
Then STDOUT should contain:
102102
"""
103103
Success: Site 2 created: http://custom.example.com/
@@ -118,7 +118,7 @@ Feature: Create a new site on a WP multisite
118118
Scenario: Create site with custom URL in subdirectory multisite
119119
Given a WP multisite subdirectory install
120120
121-
When I run `wp site create --url=http://example.com/custom/path/`
121+
When I run `wp site create --site-url=http://example.com/custom/path/`
122122
Then STDOUT should contain:
123123
"""
124124
Success: Site 2 created: http://example.com/custom/path/
@@ -139,26 +139,26 @@ Feature: Create a new site on a WP multisite
139139
Scenario: Create site with custom URL and explicit slug
140140
Given a WP multisite subdomain install
141141
142-
When I run `wp site create --url=http://custom.example.com --slug=myslug`
142+
When I run `wp site create --site-url=http://custom.example.com --slug=myslug`
143143
Then STDOUT should contain:
144144
"""
145145
Success: Site 2 created: http://custom.example.com/
146146
"""
147147
148-
Scenario: Error when neither slug nor url is provided
148+
Scenario: Error when neither slug nor site-url is provided
149149
Given a WP multisite install
150150
151151
When I try `wp site create --title="Test Site"`
152152
Then STDERR should be:
153153
"""
154-
Error: Either --slug or --url must be provided.
154+
Error: Either --slug or --site-url must be provided.
155155
"""
156156
And the return code should be 1
157157
158158
Scenario: Error when invalid URL format is provided
159159
Given a WP multisite install
160160
161-
When I try `wp site create --url=not-a-valid-url`
161+
When I try `wp site create --site-url=not-a-valid-url`
162162
Then STDERR should contain:
163163
"""
164164
Error: Invalid URL format

src/Site_Command.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ public function delete( $args, $assoc_args ) {
391391
*
392392
* [--slug=<slug>]
393393
* : Path for the new site. Subdomain on subdomain installs, directory on subdirectory installs.
394-
* Required if --url is not provided.
394+
* Required if --site-url is not provided.
395395
*
396-
* [--url=<url>]
396+
* [--site-url=<url>]
397397
* : Full URL for the new site. Use this to specify a custom domain instead of the auto-generated one.
398398
* For subdomain installs, this allows you to use a different base domain (e.g., 'http://site.example.com' instead of 'http://site.main.example.com').
399399
* For subdirectory installs, this allows you to use a different path.
@@ -421,11 +421,11 @@ public function delete( $args, $assoc_args ) {
421421
* Success: Site 3 created: http://www.example.com/example/
422422
*
423423
* # Create a site with a custom domain (subdomain multisite)
424-
* $ wp site create --url=http://site.example.com
424+
* $ wp site create --site-url=http://site.example.com
425425
* Success: Site 4 created: http://site.example.com/
426426
*
427427
* # Create a site with a custom subdirectory (subdirectory multisite)
428-
* $ wp site create --url=http://example.com/custom/path/
428+
* $ wp site create --site-url=http://example.com/custom/path/
429429
* Success: Site 5 created: http://example.com/custom/path/
430430
*/
431431
public function create( $args, $assoc_args ) {
@@ -435,21 +435,21 @@ public function create( $args, $assoc_args ) {
435435

436436
global $wpdb, $current_site;
437437

438-
// Check if either slug or url is provided
439-
$has_slug = isset( $assoc_args['slug'] );
440-
$has_url = isset( $assoc_args['url'] );
438+
// Check if either slug or site-url is provided
439+
$has_slug = isset( $assoc_args['slug'] );
440+
$has_site_url = isset( $assoc_args['site-url'] );
441441

442-
if ( ! $has_slug && ! $has_url ) {
443-
WP_CLI::error( 'Either --slug or --url must be provided.' );
442+
if ( ! $has_slug && ! $has_site_url ) {
443+
WP_CLI::error( 'Either --slug or --site-url must be provided.' );
444444
}
445445

446-
// If URL is provided, parse it to get domain and path
446+
// If site URL is provided, parse it to get domain and path
447447
$custom_domain = null;
448448
$custom_path = null;
449449
$base = null;
450450

451-
if ( $has_url ) {
452-
$parsed_url = parse_url( $assoc_args['url'] );
451+
if ( $has_site_url ) {
452+
$parsed_url = 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
}
@@ -537,7 +537,7 @@ public function create( $args, $assoc_args ) {
537537

538538
if ( is_subdomain_install() ) {
539539
if ( null !== $custom_domain ) {
540-
// Use custom domain if provided via --url
540+
// Use custom domain if provided via --site-url
541541
$newdomain = $custom_domain;
542542
$path = $custom_path;
543543
} else {
@@ -547,7 +547,7 @@ public function create( $args, $assoc_args ) {
547547
}
548548
} else {
549549
if ( null !== $custom_domain ) {
550-
// Use custom domain and path if provided via --url
550+
// Use custom domain and path if provided via --site-url
551551
$newdomain = $custom_domain;
552552
$path = $custom_path;
553553
} else {

0 commit comments

Comments
 (0)