is_blog_admin()
Checks whether the current page—the current request—is a page in the admin area of an individual site in a WordPress MU network. Conditional tag.
The function is logically identical to is_admin(), except it works when we are in the admin area of an individual site in the network. Another difference — it only starts working much later — only after the current_screen hook is triggered. Whereas is_admin() works almost from the very beginning of WordPress core loading.
This function belongs to a group of functions:
- is_admin() - any admin page...
- is_network_admin() - admin page in the network management section.
- is_blog_admin() - admin page in the management section of an individual site, not the network of sites.
- is_user_admin() - special user page in the WordPress admin.
Note that the function does not determine whether the user is an administrator. For that there is another function current_user_can('manage_options').
Works based on the global variable $current_screen.
Возвращает
true|false. True, если мы находится на любой странице в админке отдельного сайта сети.
Использование
if( is_blog_admin() ){
// we are in the admin area of the network site
}
Примеры
#1 Add a widget to the console of a separate network site
// widget of the last activity on the site
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
Notes
- Global. WP_Screen.
$current_screenWordPress current screen object.
Changelog
| Since 3.1.0 | Introduced. |
is_blog_admin() is blog admin code WP 7.0
function is_blog_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin( 'site' );
} elseif ( defined( 'WP_BLOG_ADMIN' ) ) {
return WP_BLOG_ADMIN;
}
return false;
}