Determining URIs for plugin pages

Let’s say I create a plugin with a menu page and three different submenu pages. How can I determine the URI for each one of them? For example, if I want to have a link on one of the pages to one of the other pages, how do I do that?

I had this problem before, too, when I created a form to gather some information. I ultimately solved it by having the page that defined the form handle it. Like this:

Read More
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">

How would I let another page handle the form data, i.e. what would I put in the action parameter.

I noticed some people hardcode the URI one way or another, for example through

$_SERVER['PHP_SELF'].'?page=slug

But that won’t work with all URL schemes.

Related posts

Leave a Reply

1 comment

  1. You can dynamically generate those URLs like this:

    $url = add_query_arg( array(
        'page' => 'slug', // whatever the page slug should be, either for this page or the other pages
    ), admin_url( 'options-general.php' ) );