WordPress.org

Make WordPress Core

Ticket #17287: 17287.diff

File 17287.diff, 815 bytes (added by solarissmoke, 3 years ago)

Use preg_replace instead of preg_match, avoiding extra variable

  • wp-includes/ms-functions.php

     
    644644        if (! is_subdomain_install() ) 
    645645                $illegal_names = array_merge($illegal_names, apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) ); 
    646646 
    647  
    648647        if ( empty( $blogname ) ) 
    649648                $errors->add('blogname', __('Please enter a site name')); 
    650649 
    651         $maybe = array(); 
    652         preg_match( '/[a-z0-9]+/', $blogname, $maybe ); 
    653         if ( $blogname != $maybe[0] ) 
     650        if ( preg_replace( '/[^a-z0-9]+/', '', $blogname ) != $blogname ) 
    654651                $errors->add('blogname', __('Only lowercase letters and numbers allowed')); 
    655652 
    656653        if ( in_array( $blogname, $illegal_names ) == true )