I suggest you ...

Remove the 4 character limit to new host names.

There is no name length limit in Wordpress. You can have b.example.com or bbb.example.com but your plugin refuses to work and says there is a 4 character limit in wordpress. There is not.

3 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Dorkly shared this idea  ·   ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • AdminAndrew (Technology Architecture, Never Settle) commented  · 

        This is simply not correct. There IS a default limit of 4 characters in WP Core.

        Here is an article describing the mechanism that is enforcing that limit outside the Cloner from WP Core. It's specifically addressing the error raised when using dashes in site names, but the mechanism is the same - there's also a handler for the 4 character limit error:
        https://neversettle.it/documentation/ns-cloner/how-to-use-dashes-clone-wordpress-sites/

        If you dig into WP core you'll see that WP does in fact inherently have a default 4 character minimum:
        From /wp-includes/ms-functions.php line 589
        if ( strlen( $blogname ) < $minimum_site_name_length ) {
            /* translators: %s: minimum site name length */
            $errors->add( 'blogname', sprintf( _n( 'Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length ), number_format_i18n( $minimum_site_name_length ) ) );
          }

        As of version 4.8 WP Core added a filter to change this (it used to be hard-coded). So there are a couple ways to now get around this. #1 use the code from the article above and tweak it to your needs. Or #2 use the new filter in WP 4.8. Here's the spec from /wp-includes/ms-functions.php line 580:
        /**
          * Filters the minimum site name length required when validating a site signup.
          *
          * @since 4.8.0
          *
          * @param int $length The minimum site name length. Default 4.
          */
          $minimum_site_name_length = apply_filters( 'minimum_site_name_length', 4 );

        The bottom line is this is NOT an issue with NS Cloner. This is in fact a restriction in the core code for WP Multisite as described in the article above. The internal WP function wpmu_validate_blog_signup() has to be used by the NS Cloner to make sure that all WP core rules are followed in naming conventions. That's the only way to ensure backwards and forwards compatibility and to prevent database corruption. The wpmu_validate_blog_signup() function defines what is or is not a valid site name and you have to use WP mechanisms (like a filter on minimum_site_name_length) if you want to get around those. 

        It's quite possible that the normal WP Network Admin tool for adding a site uses a different set of rules in WP Core which does not apply the 4 character limit restriction. Welcome to open source :)

      Feedback and Knowledge Base