Last active
December 4, 2020 20:37
-
-
Save devwax/b6d8f7e7305a15a33e3d894959339043 to your computer and use it in GitHub Desktop.
WordPress Admin URL shortcuts
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 | |
/* | |
Usage: | |
domain.com/plugins > domain.com/wp-admin/plugins.php (WP Admin > Plugins) | |
domain.com/pg > domain.com/wp-admin/edit.php?post_type=page (WP Admin > Pages) | |
etc... | |
*/ | |
add_action('wp', 'redirect_shortcuts'); | |
function redirect_shortcuts(){ | |
if (is_user_logged_in()) { | |
global $wp; | |
$url = ''; | |
switch ($wp->request) { | |
case 'pl': | |
$url = admin_url('plugins.php'); | |
break; | |
case 'plugins': | |
$url = admin_url('plugins.php'); | |
break; | |
case 'pg': | |
$url = admin_url('edit.php?post_type=page'); | |
break; | |
case 'pages': | |
$url = admin_url('edit.php?post_type=page'); | |
break; | |
case 'media': | |
$url = admin_url('upload.php'); | |
break; | |
case 'jch': | |
$url = admin_url('options-general.php?page=jchoptimize-settings'); | |
break; | |
default: | |
break; | |
} | |
if ($url) { | |
wp_safe_redirect($url); | |
} | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment