Existing site as root site for new network#1
Closed
SimonvanWijhe wants to merge 2 commits into
Closed
Conversation
3ba412d to
4a6dea4
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for creating a new network using an existing site as the network’s root (main) site, updating the network creation UI, backend network creation logic, assets, and integration tests.
Changes:
- Add “Create new site” vs “Use existing site” root-site selection UI and toggle behavior.
- Extend
add_network()to acceptexisting_blog_idand move the selected site into the new network as its main site. - Add integration tests covering the existing-site flow and error cases.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| wp-multi-network/includes/metaboxes/edit-network.php | Adds eligible-site selection UI for choosing an existing root site. |
| wp-multi-network/includes/functions.php | Adds existing_blog_id support to add_network() and moves an existing site into the new network. |
| wp-multi-network/includes/classes/class-wp-ms-networks-admin.php | Adds root-site radio toggle UI and POST handling for existing-site selection. |
| wp-multi-network/assets/js/wp-multi-network.js | Adds JS UI toggling between “new” vs “existing” root-site inputs. |
| wp-multi-network/assets/js/wp-multi-network.min.js | Minified counterpart updated with the same toggle behavior. |
| wp-multi-network/assets/css/wp-multi-network.css | Adds styling for the root-site toggle and default visibility of existing-site row. |
| wp-multi-network/assets/css/wp-multi-network.min.css | Minified counterpart of the new styling. |
| wp-multi-network/assets/css/wp-multi-network-rtl.css | RTL styling for the toggle layout. |
| wp-multi-network/assets/css/wp-multi-network-rtl.min.css | Minified RTL counterpart of the new styling. |
| tests/integration/tests/test-add-network-existing-site.php | Adds integration tests for creating a network with an existing root site and related error cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+598
to
599
| move_site( $r['existing_blog_id'], $new_network_id ); | ||
|
|
Comment on lines
+75
to
+82
| $all_sites = get_sites( array( 'number' => 0 ) ); | ||
| $eligible_sites = array(); | ||
|
|
||
| foreach ( $all_sites as $site ) { | ||
| if ( ! is_main_site_for_network( $site->id ) ) { | ||
| $eligible_sites[] = $site; | ||
| } | ||
| } |
|
|
||
| // Root site option: 'new' (default) or 'existing'. | ||
| $root_site_option = ! empty( $_POST['root_site_option'] ) | ||
| ? sanitize_key( $_POST['root_site_option'] ) |
| $existing_site_id = 0; | ||
|
|
||
| if ( 'existing' === $root_site_option && ! empty( $_POST['existing_site_id'] ) ) { | ||
| $existing_site_id = absint( $_POST['existing_site_id'] ); |
Comment on lines
+584
to
+587
| if ( empty( $existing_site ) ) { | ||
| restore_current_network(); | ||
| return new WP_Error( 'blog_not_exist', esc_html__( 'The specified site does not exist.', 'wp-multi-network' ) ); | ||
| } |
f24e68f to
a9102e1
Compare
6c42ef1 to
cd9ce69
Compare
cd9ce69 to
8f1cca4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.