7.x path.inc path_is_admin($path)

Determines whether a path is in the administrative section of the site.

By default, paths are considered to be non-administrative. If a path does not match any of the patterns in path_get_admin_paths(), or if it matches both administrative and non-administrative patterns, it is considered non-administrative.


$path: A Drupal path.

Return value

TRUE if the path is administrative, FALSE otherwise.

See also




3 calls to path_is_admin()
overlay_init in modules/overlay/overlay.module
Implements hook_init().
system_custom_theme in modules/system/system.module
Implements hook_custom_theme().
system_init in modules/system/system.module
Implements hook_init().


includes/path.inc, line 496
Functions to handle paths in Drupal, including path aliasing.


function path_is_admin($path) {
  $path_map = &drupal_static(__FUNCTION__);
  if (!isset($path_map['admin'][$path])) {
    $patterns = path_get_admin_paths();
    $path_map['admin'][$path] = drupal_match_path($path, $patterns['admin']);
    $path_map['non_admin'][$path] = drupal_match_path($path, $patterns['non_admin']);
  return $path_map['admin'][$path] && !$path_map['non_admin'][$path];


Elijah Lynn’s picture

if (path_is_admin(current_path())) {
  // Do stuff.
jonhattan’s picture

To check the path of the current page:

$is_admin = \Drupal::service('router.admin_context')->isAdminRoute();

to check an arbitrary path, you need to create a Request object and obtain its matching Route:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;

$path = '/node/1';
$request = Request::create($path);

$route_match = \Drupal::service('router.no_access_checks')->matchRequest($request);
$route = $route_match[RouteObjectInterface::ROUTE_OBJECT];
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);