wpseek.com
WordPress开发者和主题制作者的搜索引擎



is_admin › WordPress Function

Since1.5.1
已弃用n/a
is_admin ( 没有参数 )
返回:
  • (bool) True if inside WordPress administration interface, false otherwise.
定义在:
文档:

Determines whether the current request is for an administrative interface page.

Does not check if the user is an administrator; use current_user_can() for checking roles and capabilities. For more information on this and similar theme functions, check out the {@link Conditional Tags} article in the Theme Developer Handbook.


源码

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

	return false;
}