wppaste
WordPress

ms_site_check(): true|string

Since
3.0.0
Source
wp-includes/ms-load.php:74
Checks status of current blog.

Description

Checks if the blog is deleted, inactive, archived, or spammed.

Dies with a default message if the blog does not pass the check.

To change the default message when a blog does not pass the check, use the wp-content/blog-deleted.php, blog-inactive.php and blog-suspended.php drop-ins.

Compatibility

WordPress
since 3.0.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Return value

true|string
Returns true on success, or drop-in file to include.

Performance profile

How much work a call to ms_site_check() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reads or writes the filesystem via file_exists().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
8–84

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 95.

Plugin surface
1 hook

Third-party callbacks on 'ms_site_check' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionnetwork optionget_site_option()called directly
  • filesystemfilesystem accessfile_exists()called directly

Further down the call graph this can also reach query, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 13 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost ms_site_check() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$check !== null8apply_filters()
$check === null && is_super_admin()11apply_filters(), is_super_admin()
$check === null && !is_super_admin() && file_exists()25–34apply_filters(), is_super_admin(), get_site(), file_exists()
$check === null && !is_super_admin()26apply_filters(), is_super_admin(), get_site()
$check === null && !is_super_admin() && !file_exists()37–40apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die()
$check === null && !is_super_admin()42–48apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die(), file_exists()
$check === null && !is_super_admin() && !file_exists()51–54apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die(), file_exists(), __(), wp_die()
$check === null && !is_super_admin() && !file_exists()56apply_filters(), is_super_admin(), get_site(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die()
$check === null && !is_super_admin()61–64apply_filters(), is_super_admin(), get_site(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die(), file_exists()
$check === null && !is_super_admin() && !file_exists()67–70apply_filters(), is_super_admin(), get_site(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die(), file_exists(), __(), wp_die()
$check === null && !is_super_admin() && !file_exists()70apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die()
$check === null && !is_super_admin()75–78apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die(), file_exists()
1 further outcome, up to 84 instructions
$check === null && !is_super_admin() && !file_exists()81–84apply_filters(), is_super_admin(), get_site(), file_exists(), __(), wp_die(), file_exists(), get_network(), get_site_option(), __(), sprintf(), sprintf(), wp_die(), file_exists(), __(), wp_die()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev958–849
8.5958–849
8.4958–8494 fewer instructions than PHP 8.3
8.3998–889
8.2998–889
8.1998–889
7.4998–889

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while ms_site_check() runs, in this order:

  1. apply_filters( ms_site_check )filterline 83 (+9 into the body)

    Filters checking the status of the current blog.

Uses · 7

  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • is_super_admin()Determines whether user is a site admin.
  • get_site()Retrieves site data given a site ID or site object.
  • wp_die()Kills WordPress execution and displays HTML page with an error message.
  • __()Retrieves the translation of $text.
  • get_site_option()Retrieve an option value for the current network based on name of option.
  • get_network()Retrieves network data given a network ID or network object.

Source code

function ms_site_check() { 	/**	 * Filters checking the status of the current blog.	 *	 * @since 3.0.0	 *	 * @param bool|null $check Whether to skip the blog status check. Default null.	 */	$check = apply_filters( 'ms_site_check', null );	if ( null !== $check ) {		return true;	} 	// Allow super admins to see blocked sites.	if ( is_super_admin() ) {		return true;	} 	$blog = get_site(); 	if ( '1' === $blog->deleted ) {		if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {			return WP_CONTENT_DIR . '/blog-deleted.php';		} else {			wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );		}	} 	if ( '2' === $blog->deleted ) {		if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {			return WP_CONTENT_DIR . '/blog-inactive.php';		} else {			$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_network()->domain ) );			wp_die(				sprintf(					/* translators: %s: Admin email link. */					__( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),					sprintf( '<a href="mailto:%1$s">%1$s</a>', $admin_email )				)			);		}	} 	if ( '1' === $blog->archived || '1' === $blog->spam ) {		if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {			return WP_CONTENT_DIR . '/blog-suspended.php';		} else {			wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );		}	} 	return true;}

Changelog

Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/ms-load.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.