is_admin

函数


is_admin ( No parameters )
返回值
  • (bool) True if inside WordPress administration interface, false otherwise.
定义位置
  • wp-includes/load.php
    , line 1172
引入
1.5.1
弃用

判断当前请求是否是管理界面的页面。

不检查用户是否是管理员;使用current_user_can()来检查角色和权限。

关于这个和类似主题函数的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。

function is_admin() {
	if ( isset( $GLOBALS['current_screen'] ) ) {
		return $GLOBALS['current_screen']->in_admin();
	} elseif ( defined( 'WP_ADMIN' ) ) {
		return WP_ADMIN;
	}

	return false;
}