-
-
Save tazziedave/72e03cecd0cd756785e0f28f652f7d8c to your computer and use it in GitHub Desktop.
Obtain path to wp-admin directory in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
$blogUrl = preg_replace("(^https?://)", "", get_bloginfo( 'url' )); | |
$adminUrl = preg_replace("(^https?://)", "", get_admin_url()); | |
$admin_path = str_replace( $blogUrl . '/', ABSPATH, $adminUrl); | |
// 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
And you can use trailingslashit(ABSPATH)