Last active
August 30, 2018 18:43
-
-
Save earth3300/6056f7557788b9517c6963dfcf65347c to your computer and use it in GitHub Desktop.
Changes the WP /wp-admin url to /admin for for consistency and standardization purposes.
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
/** | |
* Change the /wp-admin url to /admin | |
* | |
* Adapted from {@link https://gist.github.com/hakre/701245} | |
*/ | |
class WPAdminUrl { | |
/** | |
* The instance of the class | |
*/ | |
static $instance; | |
/** | |
* Bootstrap function | |
*/ | |
static public function bootstrap() { | |
null === self::$instance | |
&& self::$instance = new self() | |
; | |
return self::$instance; | |
} | |
/** | |
* The cookie path has been set already (see config). | |
*/ | |
public function __construct() { | |
add_action('init', array($this, 'init')); | |
} | |
/** | |
* Filter the admin url | |
*/ | |
public function init() { | |
add_filter('admin_url', array($this, 'admin_url'), 10, 3); | |
} | |
/** | |
* Provide the admin url set in /config | |
*/ | |
public function admin_url() { | |
return SITE_ADMIN_URL . '/'; | |
} | |
} | |
return WPAdminUrl::bootstrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment