domain_exists example

$errors->add( 'blog_title', __( 'Please enter a site title.' ) );
    }

    // Check if the domain/path has been used already.     if ( is_subdomain_install() ) {
        $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
        $path     = $base;
    } else {
        $mydomain = $domain;
        $path     = $base . $blogname . '/';
    }
    if ( domain_exists( $mydomain$path$current_network->id ) ) {
        $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
    }

    /* * Do not allow users to create a site that matches an existing user's login name, * unless it's the user's own username. */
    if ( username_exists( $blogname ) ) {
        if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) {
            $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
        }
    }

function create_empty_blog( $domain$path$weblog_title$site_id = 1 ) {
    _deprecated_function( __FUNCTION__, '4.4.0' );

    if ( empty($path) )
        $path = '/';

    // Check if the domain has been used already. We should return an error message.     if ( domain_exists($domain$path$site_id) )
        return __( '<strong>Error:</strong> Site URL you&#8217;ve entered is already taken.' );

    /* * Need to back up wpdb table names, and create a new wp_blogs entry for new blog. * Need to get blog_id from wp_blogs, and create new table names. * Must restore table names at the end of function. */

    if ( ! $blog_id = insert_blog($domain$path$site_id) )
        return __( '<strong>Error:</strong> There was a problem creating site entry.' );

    
if ( ! empty( $errors->errors ) ) {
        return;
    }

    // If a new site, or domain/path/network ID have changed, ensure uniqueness.     if ( ! $old_site
        || $data['domain'] !== $old_site->domain
        || $data['path'] !== $old_site->path
        || $data['network_id'] !== $old_site->network_id
    ) {
        if ( domain_exists( $data['domain']$data['path']$data['network_id'] ) ) {
            $errors->add( 'site_taken', __( 'Sorry, that site already exists!' ) );
        }
    }
}

/** * Runs the initialization routine for a given site. * * This process includes creating the site's database tables and * populating them with defaults. * * @since 5.1.0 * * @global wpdb $wpdb WordPress database abstraction object. * @global WP_Roles $wp_roles WordPress role management object. * * @param int|WP_Site $site_id Site ID or object. * @param array $args { * Optional. Arguments to modify the initialization behavior. * * @type int $user_id Required. User ID for the site administrator. * @type string $title Site title. Default is 'Site %d' where %d is the * site ID. * @type array $options Custom option $key => $value pairs to use. Default * empty array. * @type array $meta Custom site metadata $key => $value pairs to use. * Default empty array. * } * @return true|WP_Error True on success, or error object on failure. */
Home | Imprint | This part of the site doesn't use cookies.