Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions wp-multi-network/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,16 @@ function add_network( $args = array() ) {
}
$upload_dir .= '/uploads';

if ( defined( 'MULTISITE' ) ) {
$ms_dir = '/sites/' . $new_blog_id;
} else {
$ms_dir = '/' . $new_blog_id;
// Check if wpmu_create_blog() already set the site-specific path.
$existing_upload_path = get_blog_option( $new_blog_id, 'upload_path' );
$site_path_suffix = defined( 'MULTISITE' ) ? '/sites/' . $new_blog_id : '/' . $new_blog_id;

// Only add the site-specific path if it's not already present.
if ( empty( $existing_upload_path ) || false === strpos( $existing_upload_path, $site_path_suffix ) ) {
$upload_dir .= $site_path_suffix;
$upload_url .= $site_path_suffix;
}

$upload_dir .= $ms_dir;
$upload_url .= $ms_dir;

update_blog_option( $new_blog_id, 'upload_path', $upload_dir );
update_blog_option( $new_blog_id, 'upload_url_path', $upload_url );
}
Expand Down
Loading