• Hi All

    What is the correct way to create links with admin pages? For instance, I have written two admin pages a.php and b.php. From a.php I would like to create a link that goes to b.php. From what I can tell, the correct link should be https://mydomain.com/wp-admin/admin.php?page=foo

    where foo is the name i used to register b.php as a sub-menu item. I could hardcode this link but does wordpress provide some sort of wrapper for it?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • yeap, and its all explained here : https://codex.www.ads-software.com/Writing_a_Plugin#Adding_Administration_Panels

    if that doesnt help you can always look at how its done in the core, though that link helped me far more than what I saw in the core did.

    Thread Starter adieyal

    (@adieyal)

    thanks for the reply but I think you misunderstood me. I’ve already installed both a.php and b.php as menu items. I just want to create an html link on a.php that, when clicked, loads up b.php. It’s easy enough to do the following

    Link but I was wondering if there was a wrapper function for creating the url.

    mm, so you mean that if i were to install the 2 files they would work inside my wp-admin without further editing?

    if you were to use a $link variable of some kind, there all kinds of path variables available.

    Something like, get_bloginfo ought to get you started on the path..

    Is that more what you mean?

    Most plugins that ive seen (i am assuming your talking about a plugin since thats where this is posted) end up using a variable and then tacking on the necessary stuff, either through more variables or not.

    $link = $link . '" href="' . get_bloginfo('comments_rss2_url') . '" />'; for example.

    Thread Starter adieyal

    (@adieyal)

    I’m writing a plugin, say I want a product management system built into wordpress. I might have a page prodlist.php which will display all my products, not unlike the manage->post/page in the standard wordpress admin application. Next to each product, I have an edit button which, when pressed, lets me edit the product details. The edit page is say prodedit.php, is installed as a submenu item in the admin application and can be found by following the following link: mydomain.com/wp-admin/admin.php?page=foo. It would make sense to me that the wordpress developers would have written a wrapper function such as get_menu_url(“foo”) which would create the link above.

    I don’t think that get_bloginfo helps as it gives blog specific content and does not deal with the admin application.

    This is not a serious issue as I can simply hardcode the link but a level of abstraction would be nice.

    Thanks for your responses so far.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    No, there is no such function. What you do is to build the link yourself, like so: get_settings('siteurl')."/wp-admin/admin.php?page=foo"

    For a working blog, the siteurl setting must point to the blog itself. Then you can add on the necessary bits to get your page.

    If you want to abstract that sort of thing into a single function in your plugin, feel free.

    Thread Starter adieyal

    (@adieyal)

    Thanks for the reply Otto42

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Correct way to link between admin pages’ is closed to new replies.