get_admin_url

Retrieves the URL to the admin area for a given site.

Description

(string) get_admin_url( (constant) $blog_id = null, (string) $path = '', (string) $scheme = 'admin' ); 

Returns (string)

Admin URL link with optional path appended.

Parameters (3)

0. $blog_id — Optional. (constant) => null
Site ID. Default null (current site).
1. $path — Optional. (string) => ''
Path relative to the admin URL. Default empty.
2. $scheme — Optional. (string) => 'admin'
The scheme to use. Accepts http or https,, to force those schemes. Default admin, which obeys force_ssl_admin() and is_ssl().

Usage

  1. if ( !function_exists( 'get_admin_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Site ID. Default null (current site). 
  5. $blog_id = null; 
  6.  
  7. // Optional. Path relative to the admin URL. Default empty. 
  8. $path = ''; 
  9. $scheme = 'admin'; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = get_admin_url($blog_id, $path, $scheme); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { 
  2. $url = get_site_url($blog_id, 'wp-admin/', $scheme); 
  3.  
  4. if ( $path && is_string( $path ) ) 
  5. $url .= ltrim( $path, '/' ); 
  6.  
  7. /** 
  8. * Filters the admin area URL. 
  9. * @since 2.8.0 
  10. * @param string $url The complete admin area URL including scheme and path. 
  11. * @param string $path Path relative to the admin area URL. Blank string if no path is specified. 
  12. * @param int|null $blog_id Site ID, or null for the current site. 
  13. */ 
  14. return apply_filters( 'admin_url', $url, $path, $blog_id );