The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to add Admin menu item linking directly to a page/ or widgets.php (3 posts)

  1. naastje
    Posted 3 years ago #

    Hey guys,

    Could you help me out with creating a "direct" menu item on the backend linking to a specific page and widget's and Nav Menus.

    This is what I have now:

    function mt_add_pages() {
        add_menu_page('admin-menu', 'Navigation', 5, __FILE__, 'mt_toplevel_page');
    function mt_toplevel_page() {
      echo '
        <div class="wrap">
          <h2>Page Link</h2>
          <li><a href="http://www.mywebsite.com/website/wp-admin/post.php?post=1118&action=edit"><h3>Page Link</h3></a></li>
          <li><a href="http://www.mywebsite.com/website/wp-admin/nav-menus.php"><h3>Go to Menus</h3></a></li>
          <li><a href="http://www.mywebsite.com/website/wp-admin/widgets.php"><h3>Go to widgets</h3></a></li>
    add_action('admin_menu', 'mt_add_pages');

    It looks all right, it works fine, what I'm worried about is this:


    This shows up in the addres bar when I click on the "Navigation" menu item. I don't think it's a secure way to do it at all.

    Is there any other way to do something like that?

    Just like you have the menu item "Pages" with submenu "Alle pages" "New Page" but then a top level menu item "Navigation" with submenu "Page Link" "Menus" (the same menus as you go from "Appearance"-> "Menus") and "Widgets"(also the same as "Appearance" -> "Widgets" but then linked to a new top level menu item)

  2. bcworkz
    Posted 3 years ago #

    Since you are using a callback to display content, the menu slug is just a label. Don't use __FILE__, use something like 'navigation'.

    Incidentally, you should use a capability instead of a user level for the 3rd parameter. User levels will stop working at some point.

  3. naastje
    Posted 3 years ago #

    Thanks for the suggestion to change the __FILE__ to something else.

Topic Closed

This topic has been closed to new replies.

About this Topic