2

I am creating a plugin for add menu option to WordPress admin and using below function for that:

<?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); ?>

But I would like to add absolute path for menu option in the place of $menu_slug.

enter image description here

please see the screen shot, I have created both " Header and footer " using add_menu_page function. I would like to give absolute path for both header and footer. I know plugins are available for this but I am creating my plugin with different functionality.

4
  • 1
    Could you narrow down absolute path to where? If it's another site entirely then WP probably won't let you without much grief. For same site it depends. Commented Oct 19, 2014 at 17:37
  • Please read my question once again I have update my question. Commented Oct 20, 2014 at 6:09
  • But where does those link point to? A file in your theme? Plugin? Commented Oct 20, 2014 at 7:57
  • I would like for plugin Commented Oct 20, 2014 at 9:19

1 Answer 1

0

I don't think there is a clean way to put arbitrary link into the menu item. At most you could change it with JavaScript after the fact.

However there is an edge case that allows you to load plugin file there.

  1. Pass as $menu_slug argument a path to a plugin file relative to plugins directory, for example plugin-folder/boo.php.
  2. Omit $function argument.
  3. This will generate link like admin.php?page=plugin-folder/boo.php.
  4. Following the link will load the file as content of admin page.

There isn't actually much benefit over just using callback for output. But from technical point of view this is about as close as possible to including a file in there.

3
  • but I want to add third party link there.reay my question I want to put absolute path.not like your given example Commented Oct 20, 2014 at 13:24
  • Then you are stuck with JS most likely. I don't quite follow why would Header/Footer send user out of admin entirely, but if that's what you need to do — WP doesn't do it. Commented Oct 20, 2014 at 13:27
  • You can use this method and just redirect to the external URL. Following the example here, inside the plugin-folder/boo.php file include <meta http-equiv="refresh" content="0;url=http://example.com/">. Commented May 15, 2015 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.