• nimh

    (@nimh)


    I’ve looked and googled but I’m not finding my answer, maybe someone here can point me in the right direction.

    I’m attempting to code my first plugin, and I’m stuck at the moment.

    The plugin’s first page opens as expected, then I want to add some actions/links to that main page that will take the user to another screen for data entry to a database.

    How can I do this?

    plugin_basename( __FILE__ ) ."?action=edit

    doesnt give me the desired effect, as i thought it would…
    I think i need to get to “tools.php?page=myPlugin” and then add the “?action=edit”, am I right?

    Thank you for any help, let me know if i need to clarify anything.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    plugin_basename() as you used it would link to the current code page, as you have discovered. To link to a different plugin file, you’ll have better luck using plugins_url().

    Adding URL query arguments is a bit tricky because you cannot be sure if you should use ‘?’ OR ‘&’ as the delimiter. Using you last examples, what you do not want is tools.php?page=myPlugin?action=edit! (two question marks) It must be tools.php?page=myPlugin&action=edit when there’s an existing argument, otherwise it must be tools.php?action=edit. add_query_arg() handles this bit of logic for you.

    Thread Starter nimh

    (@nimh)

    Thank you.

    What about if I want to make a link go to the exact place a menu option is pointing to?

    Moderator bcworkz

    (@bcworkz)

    I’m not sure I understand your last question. My best guess is you mean skip links to a particular ID on a page, as in tools.php#update that might take one to a <h2 id="update">Update</h2> element halfway down the page. Am I right?

    I would think you just add the URL parameters to the end as usual.
    tools.php#update?page=myPlugin&action=edit

    I’ve never had the need to do anything like that, I don’t see why it’d be a problem though. Typically the URL parameters are used to display specific content, so there is normally no need to skip halfway down a page. Just show the relevant content using conditionals based on the URL parameters.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin Development needing new page’ is closed to new replies.