The only thing more efficient code-wise than your Option 2 would be this one-liner:
<?php
$dom = str_replace( "https://wordpress.stackexchange.com/", '', get_blog_details()->path );
Related Posts:
- Issue with htaccess redirection in WP Multisite
- restore_current_blog() vs switch_to_blog()
- Anyone figured out how to use WordPress MultiSite with Domain Mapping & SSL?
- What do I need to do to convert my MultiSite from HTTP to HTTPS?
- WP Multisite development with Mamp Pro and wildcard subdomains, not really working for me
- SSL wildcard issue for wp multisite subdomains
- How to set configuration options for particular sub blogs?
- REST API for Multisite
- How can I display all Multisite blogs where this user is administrator?
- Organize uploaded media files
- How to upload images manually to wordpress?
- MU domain mapping login issue
- How to make WordPress use new Upload Path settings in Multisite Setup
- Create unique robots.txt for every site on multisite-installation
- WPDB Multiple site’s posts and get featured images
- Using WP CLI to set options in WP Multisite
- Import a regular WordPress blog into a MU installation
- Ideal WP multisite server setup for up to 1000 sites?
- WordPress 3.2(Multisite) – How to add custom user meta fields to signup form?
- WordPress 3.8.1 Multisite blog slug problem
- How to make wp-signup.php a 1-step process [closed]
- Transients API and multisite
- Multiple Multisite networks on the same domain?
- Subdomain login problems
- Importing Multiple DB to one MU database
- Get Permalink of Network Blog Post
- What is the best practice to get a site from local to online?
- Downgrading a WP3.3.1 Network Install
- WP Multisite – domain mapping to domain.com and separate site to domain.com/help
- How to disable W3 Total Cache “Performance” menu under multisite? [closed]
- How i can get blog info using site url in multi-site
- Embedding screencast.com Videos in WordPress Multisite
- How to create sub site in wordpress multisite programmatically?
- Why my deleted url is redirecting to random post?
- Reset a site in multisite
- Problem uploading images
- Multisite – 404 when accessing sub-sites
- Redirect Site Geologically
- WordPress Network admin options page: how to store options and where will they be stored?
- WordPress Multisite’s in subdirectory not redirecting to dashboard settings
- Multisite: How can I have the admin bar (toolbar) use the language of the user instead of the language of the sub-site being viewed?
- .htaccess rules for blocking bots with an extra condition
- Wrong filepaths and admin page infinite reload after migrating to aws bitnami
- Multisite not using subdomains as hostname in from address when sending emails
- Cookie signed verification failed – wp-saving-post
- Do I need a Multisite? [closed]
- How to host unrelated pages on WordPress domain
- How can I overhaul a live MultiSite network?
- Update configured themes
- Multi-Site Subfolder User Permission Issue
- Programmatically Add Item to WP Multisite Menus
- why there is a large file named core in wpmu’s directory?
- WordPress multi-site, developing locally and syncing live changes
- wp_get_attachment_image_src on multisite
- Problem with parked domain for my mutisite
- WordPress multisite – What’s the ideal setup for development/staging/production environments?
- WordPress self hosted site asking to login again when used www
- User registration on two sites in same multisite
- How To Run Multiple Multi-Site Networks On Same Box [closed]
- Changed sub-site to its own domain trigger 302 redirects for all page links
- Multisite – big hosting package or several hosting packages?
- WordPress network vs Separate installs
- 404 on page 2 multisite
- How many databases do I need?
- How can I append blog_id to … echo [functions-defined-constant]?
- Page Builders and WP Multisite
- WordPress Multisite Add User
- Some permalinks are not working and show 404
- WP MS: How to query over the network
- unable to access network admin of a blog
- Is a multisite install what I need?
- Infamous admin login redirect
- WordPress Multisite Permalinks on mapped domain = server 404 error
- Sites network with sub-folders
- Manually Moving Posts/Pages/Comments/Tags from WPMU to WP3.0
- Setup another new subdomain root on top of multisite configuration
- WordPress keeps deleting user account for multisite after loggin out i need your help please?
- Change main site / network admin site?
- Create link preview for theme wordpress
- Language per user role, how can I achieve this?
- Internet explorer not finding right content from multisite
- Change WordPress multisite to sub-folder installation
- Serve theme and plugins assets from correct domain on multi-domain multisite
- How to add a link of “one” website in posts of “second” website in multisite WordPress
- Themes are visible in Network, but invisible in sites
- logging out with/without confirmation – single site, multisite
- No debug log for WP multisite is created
- Multisite different domains mapping error on GGS
- Possible to have duplicate usernames on different two multisites
- Main site media are accessible in subsite domain
- Multisite – each site with it’s own set of users
- Including non-wordpress pages within a single multisite domain
- WordPress Multisite wp-admin/ redirect loop but adding index.php works fine
- Migrate site from WordPress multisite to another WordPress multisite
- WordPress Multisite redirect loop
- Split a Multisite Into Single WordPress Websites
- Is it possible to put a site other than #1 as a Multisite top-level domain?
- Should I go for Multisite or separate WP Installation?
- Multiple WordPress sites on one hosting [closed]
- Run WordPress multisite from secondary volume on AWS EC2