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

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

Thnaks to Calak for this awesome code!

6 Responses

Oct 18 2008 13:44

Excellent hack, especially for plugins creators!

Oct 18 2008 16:54

“ass an admin page there” or “add…” ? :)

Oct 18 2008 16:57

@alleks: That’s what I call an embarassing typo haha! Thanks for letting me know.

Oct 20 2008 02:42

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:

Leave a Comment

* Name, Email, Comment are Required
Blog And Make Cash