This is a function that will create a new admin page near "Setting/Plugins/Users" in your WordPress dashboard.
Paste the code below in your functions.php file.
define ('TWEAK_MENU_BEGIN', 25);
define ('TWEAK_MENU_END', 40);
function add_tweak_menu_page($name, $capability, $link, $title) {
global $menu;
$i = TWEAK_MENU_END;
do {
$i--;
if ( empty($menu[$i]) ) {
while ( $i < TWEAK_MENU_END ) {
$menu[$i] = $menu[$i+1];
$i++;
}
$menu[TWEAK_MENU_END] = array ( 0 => $name, $capability, $link, $title);
return true;
}
} while ( $i > TWEAK_MENU_BEGIN );
add_menu_page($name, $capability, $link, $title);
return false;
}
To call the function and add a new admin page, do the following:
add_tweak_menu_page($name, $capability, $link, $title);
Thnaks to Calak for this awesome code!
6 Responses
Excellent hack, especially for plugins creators!
“ass an admin page there” or “add…” ?
@alleks: That’s what I call an embarassing typo haha! Thanks for letting me know.
Grammatically isn’t have supposed to be has?
Anyways, what exactly would this hack be used for? Can it be used to create a themes options page and when you say “functions.php”, do you mean the themes functions file?
Trackbacks: