Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/153 - Uploads/Clone: revert version_compare() flip. Split CLI logic. #184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 11 additions & 3 deletions wp-multi-network/includes/classes/class-wp-ms-network-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,22 @@ public function create( $args, $assoc_args ) {
$network_admin_id = get_current_user_id();
}

$clone_network = $assoc_args['clone_network'];
$options_to_clone = false;
$clone_network = $assoc_args['clone_network'];
if ( empty( $clone_network ) ) {
$clone_network = get_current_site()->id;
}

if ( ! empty( $clone_network ) && ! get_network( $clone_network ) ) {
$network_exists = get_network( $clone_network );
if ( empty( $network_exists ) ) {
WP_CLI::error( sprintf( "Clone network %s doesn't exist.", $clone_network ) );
}

$options_to_clone = false;
if ( ! empty( $clone_network ) && ! empty( $network_exists ) ) {
if ( ! empty( $assoc_args['options_to_clone'] ) ) {
$options_to_clone = explode( ',', $assoc_args['options_to_clone'] );
} else {
$options_to_clone = array_keys( network_options_to_copy() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion wp-multi-network/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ function add_network( $args = array() ) {
: get_site_option( 'ms_files_rewriting' );

// Not using rewriting, and using a newer version of WordPress than 3.7.
if ( empty( $use_files_rewriting ) && version_compare( $wp_version, '3.7', '>' ) ) {
if ( empty( $use_files_rewriting ) && version_compare( $wp_version, '3.7', '<' ) ) {

Choose a reason for hiding this comment

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

@JJJ The new logic is "Not using rewriting, and using an older version of WordPress than 3.7." This results in a new network using blogs.dir since upload_path and upload_url_path are empty.

Screenshot 2021-09-17 at 16 48 21

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@christianwach Reverted the revert 😅

Choose a reason for hiding this comment

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

Reverted the revert 😅

@JJJ 🆒 That still leaves the /sites/*/sites/* conundrum and what to do about it. PR as it stands still produces:

Screenshot 2021-09-18 at 12 11 04

As I said, for new multi-network installs it seems sensible not to append $ms_dir but for existing sites that have that schema? I'm not sure.


// WP_CONTENT_URL is locked to the current site and can't be overridden,
// so we have to replace the hostname the hard way.
Expand Down