确定switch_to_blog()是否生效

原型

ms_is_switched()

返回值

(bool)  如果切换则为真,否则为假。

源文件

路径:wp-includes/ms-blogs.php

<?php
...
function ms_is_switched() {
	return ! empty( $GLOBALS['_wp_switched_stack'] );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/ms_is_switched/