Make WordPress Core

Ticket #30233: 30233.diff

File 30233.diff, 3.5 KB (added by earnjam, 10 years ago)
  • wp-includes/ms-deprecated.php

     
    346346                }
    347347        }
    348348        return esc_url_raw( $url );
     349}
     350
     351/**
     352 * Check whether a blogname is already taken.
     353 *
     354 * Used during the new site registration process to ensure
     355 * that each blogname is unique.
     356 *
     357 * @since MU
     358 * @deprecated 4.2
     359 * @deprecated Use wp_get_site()
     360 *
     361 * @param string $domain The domain to be checked.
     362 * @param string $path The path to be checked.
     363 * @param int $site_id Optional. Relevant only on multi-network installs.
     364 * @return int
     365 */
     366function domain_exists($domain, $path, $site_id = 1) {
     367        _deprecated_function( __FUNCTION__, '3.7', 'wp_get_site()' );
     368
     369        return wp_get_site( $domain, $path, $site_id );
    349370}
     371 No newline at end of file
  • wp-includes/ms-functions.php

     
    305305                $path = '/';
    306306
    307307        // Check if the domain has been used already. We should return an error message.
    308         if ( domain_exists($domain, $path, $site_id) )
     308        if ( wp_get_site($domain, $path, $site_id) )
    309309                return __( '<strong>ERROR</strong>: Site URL already taken.' );
    310310
    311311        // Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
     
    658658                $mydomain = "$domain";
    659659                $path = $base.$blogname.'/';
    660660        }
    661         if ( domain_exists($mydomain, $path, $current_site->id) )
     661        if ( wp_get_site($mydomain, $path, $current_site->id) )
    662662                $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
    663663
    664664        if ( username_exists( $blogname ) ) {
     
    11261126                $path = '/';
    11271127
    11281128        // Check if the domain has been used already. We should return an error message.
    1129         if ( domain_exists($domain, $path, $site_id) )
     1129        if ( wp_get_site($domain, $path, $site_id) )
    11301130                return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
    11311131
    11321132        if ( !defined('WP_INSTALLING') )
     
    12651265 * Used during the new site registration process to ensure
    12661266 * that each blogname is unique.
    12671267 *
    1268  * @since MU
     1268 * @since 4.2
    12691269 *
    12701270 * @param string $domain The domain to be checked.
    12711271 * @param string $path The path to be checked.
    1272  * @param int $site_id Optional. Relevant only on multi-network installs.
     1272 * @param int|array|null $site_ids Optional. Site ID(s) to search or NULL to search all. Relevant only on multi-network installs.
    12731273 * @return int
    12741274 */
    1275 function domain_exists($domain, $path, $site_id = 1) {
     1275function wp_get_site( $domain, $path, $site_ids = null ) {
     1276
    12761277        global $wpdb;
    12771278        $path = trailingslashit( $path );
    1278         $result = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) );
     1279        $sql = "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s";
     1280        if ( is_array( $site_ids ) ) {
     1281                $sql .= ' AND site_id IN (%s)';
     1282        } elseif ( ! empty( $site_ids ) ) {
     1283                $sql .= ' AND site_id = %d';
     1284        }
     1285        $result = $wpdb->get_var( $wpdb->prepare( $sql, $domain, $path, $site_ids ) );
    12791286
    12801287        /**
    12811288         * Filter whether a blogname is taken.
     
    12871294         * @param string   $path    Path to be checked.
    12881295         * @param int      $site_id Site ID. Relevant only on multi-network installs.
    12891296         */
    1290         return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
     1297        return apply_filters( 'domain_exists', $result, $domain, $path, $site_ids );
    12911298}
    12921299
    12931300/**