Skip to content

Existing site as root site for new network#1

Closed
SimonvanWijhe wants to merge 2 commits into
masterfrom
feat/add-network-existing-site
Closed

Existing site as root site for new network#1
SimonvanWijhe wants to merge 2 commits into
masterfrom
feat/add-network-existing-site

Conversation

@SimonvanWijhe
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 8, 2026 08:44
@SimonvanWijhe SimonvanWijhe force-pushed the feat/add-network-existing-site branch from 3ba412d to 4a6dea4 Compare May 8, 2026 08:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 accept existing_blog_id and 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 thread wp-multi-network/includes/functions.php Outdated
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' ) );
}
@SimonvanWijhe SimonvanWijhe force-pushed the feat/add-network-existing-site branch from f24e68f to a9102e1 Compare May 8, 2026 09:18
@SimonvanWijhe SimonvanWijhe force-pushed the feat/add-network-existing-site branch 6 times, most recently from 6c42ef1 to cd9ce69 Compare May 8, 2026 15:36
@SimonvanWijhe SimonvanWijhe force-pushed the feat/add-network-existing-site branch from cd9ce69 to 8f1cca4 Compare May 8, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants