Adding an admin page near “Setting/Plugins/Users”

October 22, 2008 · Print This Article

WordPress have a lot of very nice function which allows you to quickly add menu page in the admin dashboard. But sadly, no function was created to add an admin page near the “Setting/Plugins/Users”. Here’s a nice code to easily add an admin page there.

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);


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.