Wordpress - What's the difference between admin_url() and get_admin_url() functions?

The admin_url() function retrieves the URL to the admin area for your current site. You needn't give the blog id for your current site. You can use this function if you aren't running WordPress multisite. And use the get_admin_url() function to get a specific site URL in the multisite admin.


Technically, except the $blog_id parameter, there isn't any difference at all.

admin_url function uses get_admin_url function internally with $blog_id parameter set to null. This is the CODE of admin_url function:

function admin_url( $path = '', $scheme = 'admin' ) {
    return get_admin_url( null, $path, $scheme );
}

Now, check the function signature of get_admin_url:

function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' )

So basically, calling admin_url() is the same as calling get_admin_url() unless you are in a multisite installation.

So, the only realistic difference is that, admin_url() doesn't support the $blog_id parameter, so it's always used to get the admin url of the default blog (i.e. the current site you are accessing). That's why you'll need get_admin_url( $blog_id ) in a multisite installation (to get another site's admin URL within the same multisite network).