ms_site_check

函式
ms_site_check ( No parameters )
返回值
  • (true|string) Returns true on success, or drop-in file to include.
定義位置
相關方法
ms_is_switched_prime_site_cachesmake_site_themewp_version_checkhas_site_icon
引入
3.0.0
棄用
-

ms_site_check: 這個函式檢查當前站點是否是網路中的一個有效站點。如果網站是有效的,它返回一個布林值為true,否則為false。

檢查當前部落格的狀態。

檢查部落格是否被刪除、不活躍、被歸檔或被垃圾郵件攻擊。

如果部落格沒有通過檢查,則以預設資訊結束。

要改變部落格未通過檢查時的預設資訊,請使用wp-content/blog-deleted.php、blog-inactive.php和blog-suspended.php降序器。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >