allow_subdomain_install(): bool

Allow subdomain installation


Return

bool Whether subdomain installation is allowed


Top ↑

Source

File: wp-admin/includes/network.php. View all references

function allow_subdomain_install() {
	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
	if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
		return false;
	}

	return true;
}


Top ↑

Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Muhibul Haque

    The allow_subdomain_install() function is a WordPress function used to determine whether subdomain-based multisite installations are allowed on a WordPress site. This function returns a boolean value (true or false) indicating whether subdomain-based multisite installations are permitted.

    In a WordPress multisite network, you have the option to create either subdirectory-based or subdomain-based installations. Here’s what each option means:

    Subdirectory-Based Multisite: In this mode, sites within the network are structured as subdirectories of the main site’s domain. For example, if the main site’s domain is example.com, a subdirectory-based site might have the URL example.com/site1/.

    Subdomain-Based Multisite: In this mode, sites within the network are structured as subdomains of the main site’s domain. For example, if the main site’s domain is example.com, a subdomain-based site might have the URL site1.example.com.

    The allow_subdomain_install() function is used to check if subdomain-based multisite installations are allowed. The function returns true if subdomain-based installations are permitted, and false if they are not.

    Here’s a typical usage scenario:

    if (allow_subdomain_install()) {
        // Subdomain-based multisite is allowed.
        // You can proceed with subdomain-based multisite setup.
    } else {
        // Subdomain-based multisite is not allowed.
        // You may only set up subdirectory-based multisite.
    }

You must log in before being able to contribute a note or feedback.