0

I'm currently writing a WordPress plugin, and am looking to retrieve the WordPress admin url. It sounds simple enough - and it is - assuming every WordPress install is using the default wp-admin slug; I could simply call get_admin_url(), which is a wrapper for get_site_url(), with wp-admin hard-coded (see here: http://wpseek.com/function/get_admin_url/).

However, I don't want to work under an assumption that this url will never change. I'd like to be able to retrieve the url regardless of whether it's default or not; i.e. for either of these cases:

http://example.com/wp-admin
http://example.com/backend

One suggestion has been to allow the plugin user to define the admin url slug, should it be different from the default, but it would be better if there were some way to retrieve it without forcing the user to specify. I'd really appreciate any help on this.

1 Answer 1

1

That's why the last line of the get_admin_url contains the line:

return apply_filters( 'admin_url', $url, $path, $blog_id );

Any valid modification of the admin URL will be via that filter, so get_admin_url is the correct function to use in all cases.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.