DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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!

Tags

Leave a Comment

Your email address will not be published. Required fields are marked *