Skip to content

Instantly share code, notes, and snippets.

@twobyte
Forked from andrezrv/get-admin-path.php
Created October 23, 2020 14:01
Show Gist options
  • Save twobyte/72ef5f9aca1b2de4c624e8a91ecc6c5c to your computer and use it in GitHub Desktop.
Save twobyte/72ef5f9aca1b2de4c624e8a91ecc6c5c to your computer and use it in GitHub Desktop.
Obtain path to wp-admin directory in WordPress.
<?php
/**
* Obtain the path to the admin directory.
*
* @return string
*/
function my_plugin_get_admin_path() {
// Replace the site base URL with the absolute path to its installation directory.
$admin_path = str_replace( get_bloginfo( 'url' ) . '/', ABSPATH, get_admin_url() );
// Make it filterable, so other plugins can hook into it.
$admin_path = apply_filters( 'my_plugin_get_admin_path', $admin_path );
return $admin_path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment