Introducing menu_page_url()

We’ve just added a new api into WordPress 3.0 to make plugin writing that bit easier – #13829

It is now really easy to get the url for a plugin page that you have registered to make it easy to link between different plugin pages. You use the new function like this:

add_options_page('Best Evar Menu', 'Best Evar Menu', 'manage_options', 'best_evar_menu', 'best_evar_options_page');

menu_page_url( 'best_evar_menu' );

The function will by default echo the url out but if you want you can get it returned for processing by setting the second argument to false.

15 thoughts on “Introducing menu_page_url()

  1. Cool!

    Now we don’t need anymore to know which kind of page it is, must the mage tag 😀

    Will this work for any page, including themes pages?

  2. Shouldn’t this be admin_menu_url() rather? menu_page_url() sounds like we’re implementing an API for newly menu items.

    1. Not really.

      All the front end menu functions refer to themselves as *nav_menu*

      All the back end menu functions for the admin menus refer to themselves add_*_page

  3. Just tried to use this in my plugin and I didn’t get it to work.
    My code looks like this:

    add_pages_page( CMS_TPV_NAME, CMS_TPV_NAME, “edit_pages”, “cms-tpv-pages-page”, “cms_tpv_pages_page” );

    echo menu_page_url(“cms-tpv-pages-page”);
    // echoes “http://localhost/wordpress3/wp-admin/edit.php?post_type=page?page=cms-tpv-pages-page”

    See that is outputs a questionmark instead of an ampersand. Don’t know if I did anything wrong here..

Comments are closed.