WordPress.org

Ready to get started?Download WordPress

Forums

Admin Menu Help (4 posts)

  1. TBotNik
    Member
    Posted 2 years ago #

    All,

    Been struggling with adding a custom plugin. Been following HOWTOs from:

    codex.wordpress.org/Administration_Menus,
    codex.wordpress.org/Plugin_API,
    codex.wordpress.org/Function_Reference/add_action,
    codex.wordpress.org/Function_Reference/add_submenu_page,
    codex.wordpress.org/Writing_a_Plugin,
    return-true.com/2009/02/creating-an-options-admin-page-for-your-wordpress-plugin/,
    ditio.net/2007/08/09/how-to-create-wordpress-plugin-from-a-scratch/,
    www.wp-starter.com/2011/02/how-to-create-a-new-admin-page-in-wordpress/,
    kovshenin.com/2010/02/wordpress-extending-the-contact-form-7-plugin-1985/,

    I tried all the commands, with no errors, but even though I can register and activate my plugin, I can not get the Admin Menu or submenu items to write into my WP session.

    I'm workdering if the commands changed in 3.2.1 as, looking through all the code for my other plugins, that do add to the Admin Menu, I do not find the commands specified in any of these HOWTOs.

    All help appreciated!

    Thanks!

    TBNK

  2. TBotNik
    Member
    Posted 2 years ago #

    All,

    Can I get some help?

    The commands:

    add_menu_page
    add_submenu_page

    are not working at all!

    TBNK

  3. deltafactory
    Member
    Posted 2 years ago #

    Can you provide some more details and perhaps a list of what you've been trying and/or sample code?

    When are you calling those functions? It should be after the right routines are loaded but before the page output begins. Ideally, use something like:

    add_action( 'admin_menu', 'myplugin_menus' );
    function myplugin_menus() {
      add_menu_page( ... ); //Fill proper arguments in..
      add_submenu_page( ... ); //Fill proper arguments in..
    }

    If you are trying to extend another plugin's menu, make sure you're creating your submenus after they create theirs. Try using a lower priority (higher number..) for the admin_menu action.

    Finally, turn on debug mode so that you can see every little thing that's going on. Good luck.

  4. TBotNik
    Member
    Posted 2 years ago #

    All,

    Hey I found out that the syntax is soooo very specific and none of the codex HOWTOs even talk about it. Here is what I had to do with my code to get it to work:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Item 1-3 were just experimental, the real one I was trying to do is #4.

    It finally worked when all the code was right. Putting the values into vars and then dropping them into the commands was really helpful, but had to figure that out on my own, because none of the HOWTOs in the codex or elsewhere did that.

    Still got some other errors, but not related to getting these commands working.

    Thanks!

    TBNK

Topic Closed

This topic has been closed to new replies.

About this Topic