wp-admin/network/site-new.php
Lines:
1 to 100 of 313
<?php /** * Add Site Administration Screen * * @package WordPress * @subpackage Multisite * @since 3.1.0 */ /** Load WordPress Administration Bootstrap */ require_once __DIR__ . '/admin.php'; /** WordPress Translation Installation API */ require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if ( ! current_user_can( 'create_sites' ) ) { wp_die( __( 'Sorry, you are not allowed to add sites to this network.' ) ); } get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __( 'Overview' ), 'content' => '<p>' . __( 'This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.' ) . '</p>' . '<p>' . __( 'If the admin email for the new site does not exist in the database, a new user will also be created.' ) . '</p>', ) ); get_current_screen()->set_help_sidebar( '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . '<p>' . __( '<a href="https://wordpress.org/documentation/article/network-admin-sites-screen/">Documentation on Site Management</a>' ) . '</p>' . '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support forums</a>' ) . '</p>' ); if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) { check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); if ( ! is_array( $_POST['blog'] ) ) { wp_die( __( 'Cannot create an empty site.' ) ); } $blog = $_POST['blog']; $domain = ''; $blog['domain'] = trim( $blog['domain'] ); if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) { $domain = strtolower( $blog['domain'] ); } // If not a subdomain installation, make sure the domain isn't a reserved word. if ( ! is_subdomain_install() ) { $subdirectory_reserved_names = get_subdirectory_reserved_names(); if ( in_array( $domain, $subdirectory_reserved_names, true ) ) { wp_die( sprintf( /* translators: %s: Reserved names list. */ __( 'The following words are reserved for use by WordPress functions and cannot be used as site names: %s' ), '<code>' . implode( '</code>, <code>', $subdirectory_reserved_names ) . '</code>' ) ); } } $title = $blog['title']; $meta = array( 'public' => 1, ); // Handle translation installation for the new site. if ( isset( $_POST['WPLANG'] ) ) { if ( '' === $_POST['WPLANG'] ) { $meta['WPLANG'] = ''; // en_US } elseif ( in_array( $_POST['WPLANG'], get_available_languages(), true ) ) { $meta['WPLANG'] = $_POST['WPLANG']; } elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) { $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) ); if ( $language ) { $meta['WPLANG'] = $language; } } } if ( empty( $title ) ) { wp_die( __( 'Missing site title.' ) ); } if ( empty( $domain ) ) { wp_die( __( 'Missing or invalid site address.' ) ); } if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) { wp_die( __( 'Missing email address.' ) ); }
Called by
Invoked by
Calls
1 to 4 of 4
- wp_admin_notice() – Outputs an admin notice.
- wp_required_field_indicator() – Assigns a visual indicator for required form fields.
- wp_required_field_message() – Creates a message to explain required form fields.
- wpmu_new_site_admin_notification() – Notifies the Multisite network administrator that a new site was created.