Multisite: Remove restriction of minimum site name length in `wpmu_validate_blog_signup()`.

It is sometimes desirable to support shorter site names than 4 characters, therefore that restriction should be removed. It is still possible to manually enforce it by using the `wpmu_validate_blog_signup` filter.

As a result of this change, another `is_super_admin()` call gets removed which affects the ongoing efforts of working on a network-wide role system.

Props milindmore22.
Fixes #39676. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40295 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz 2017-03-17 14:35:08 +00:00
parent 169c32723f
commit eb7a3d1a2f
2 changed files with 8 additions and 7 deletions

View File

@ -576,9 +576,6 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
if ( in_array( $blogname, $illegal_names ) )
$errors->add('blogname', __( 'That name is not allowed.' ) );
if ( strlen( $blogname ) < 4 && !is_super_admin() )
$errors->add('blogname', __( 'Site name must be at least 4 characters.' ) );
// do not allow users to create a blog that conflicts with a page on the main blog.
if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );

View File

@ -66,10 +66,6 @@ class Tests_Multisite_WpmuValidateBlogSignup extends WP_UnitTestCase {
array( self::$existing_user_login, 'Site names must not collide with an existing user login.' ),
);
if ( ! is_super_admin() ) {
$data[] = array( 'foo', 'Site names must at least contain 4 characters.' );
}
$illegal_names = get_site_option( 'illegal_names' );
if ( ! empty( $illegal_names ) ) {
$data[] = array( array_shift( $illegal_names ), 'Illegal site names are not allowed.' );
@ -89,6 +85,14 @@ class Tests_Multisite_WpmuValidateBlogSignup extends WP_UnitTestCase {
$result = wpmu_validate_blog_signup( self::$existing_user_login, 'Foo Site Title', get_userdata( self::$existing_user_id ) );
$this->assertEmpty( $result['errors']->get_error_codes() );
}
/**
* @ticket 39676
*/
public function test_validate_short_blogname() {
$result = wpmu_validate_blog_signup( 'foo', 'Foo Site Title', get_userdata( self::$super_admin_id ) );
$this->assertEmpty( $result['errors']->get_error_codes() );
}
}
endif;