• Stay in touch. Sign up for the 9seeds newsletter.
  • The path to admin menu enlightenment

    We’ve all seen this menu a million times. It’s our friendly neighborhood WordPress admin nav menu. If your’re the kind of person who enjoys making plugins you’re probably on the following path.

    Level 1

    Q) My plugin is simple and all my options fit on a single page. How do I add an option page for my plugin?
    A) Let add_options_page() be your guide.

    add_options_page('Simple Options','Simple','activate_plugins','simple-admin-settings',array('tutorial','controlForm'));

    Level 2

    Q) My plugin is not that simple anymore and I’m going to need more than one page to control all this awesome. How do I make a whole new top level nav container like Users, Tools or Settings?
    A) add_menu_page() with a couple add_submenu_page() calls will solve this problem lickety split.

    add_menu_page('Complicated Options', 'Complicated', 'activate_plugins', 'complicated', array("tutorial", "controlForm"));
    add_submenu_page('complicated', 'Reporting', 'Reporting', 'activate_plugins', 'reporting', array('tutorial', 'reporting'));
    add_submenu_page('complicated', 'More Options', 'More', 'activate_plugins', 'moreoptions', array('tutorial', 'moreControl'));

    Level 3

    Q) My awesome is contained in a box but I don’t want the first link to match the name of the nav container. I want reporting to be first and I don’t want that first link to say Complicated. How do I change the name in that first link?
    A) add_menu_page() with a couple add_submenu_page() still but we have to do something a little weird.

    What you have to do is make the first submenu page have the same slug as the top level menu page and have them both point at the same callback.

    add_menu_page('Complicated Options', 'Complicated', 'activate_plugins', 'complicated', array("tutorial", "reporting"));
    add_submenu_page('complicated', 'Reporting', 'Reporting', 'activate_plugins', 'complicated', array('tutorial', 'reporting'));
    add_submenu_page('complicated', 'Options', 'Options', 'activate_plugins', 'control', array('tutorial', 'controlForm'));
    add_submenu_page('complicated', 'More Options', 'More', 'activate_plugins', 'moreoptions', array('tutorial', 'moreControl'));

    Level 4 – Menu Nirvana

    Q) My menu link is perfect in every way but for UI purposes I want the menu page to show up somewhere else in the nav menu, not at the bottom. How do I place it somewhere else?
    A) add_menu_page() and its siblings add_object_page() and add_utility_page() help you out here.

    First, a brief description of the “priority” argument to add_menu_page(). You can forcibly put your menu page wherever you want in the nav menu. If you ever programmed BASIC in the days you had to type line numbers this will seem familiar. Each menu has a position, illustrated here

    So if you wanted to drop your menu right after comments you could do the following (but don’t, I’ll explain why in a second)

    add_menu_page('Tickets', 'Tickets', 'activate_plugins', 'eventticketing', array("eventTicketingSystem", "ticketReporting"),'',30);

    It looks good but there is a fatal flaw in this method and that is that there is no internal check to make sure that 2 plugins aren’t picking the same position in the menu. In this case what happens is whichever plugin gets loaded second wins. Your plugin will work just find and you can manually get to all your option pages via their slugs but you won’t be able to see it at all. We discovered this the hard way when we picked 30 for a plugin we wrote. 30 is an especially bad one to chose as that’s the same menu position that Thesis picks for itself.

    WordPress understands this desire, however, and gives you an easy way to pick that spot which picking 30 would get you: add_object_page().

    add_object_page('Complicated Options', 'Complicated', 'activate_plugins', 'complicated', array("tutorial", "reporting"));
    add_submenu_page('complicated', 'Reporting', 'Reporting', 'activate_plugins', 'complicated', array('tutorial', 'reporting'));
    add_submenu_page('complicated', 'Options', 'Options', 'activate_plugins', 'control', array('tutorial', 'controlForm'));
    add_submenu_page('complicated', 'More Options', 'More', 'activate_plugins', 'moreoptions', array('tutorial', 'moreControl'));

    The benefit here is that it just appends and as long as plugins are using it, they won’t be bumping into each other. There’s also add_utility_page() which appends your menu below the Settings menu page. The difference between this and just not using a position whatsoever is that this method puts it above anything menu page which has no position defined. Position 81 instead of position 100 as seen in the previous screenshots.

    Hopefully this helps you understand menu positioning a little bit more and if you find that your menu position is causing your plugin to disappear in certain circumstances, take a look at what else you have activated and what positions they’re grabbing. Odds are it’s the same one you are

    And, like so many things in life, it’s not always what you know but who you know. Big, big thank you to Brandon Dove for pointing out how to rename the first link in a menu page to be something different than the name of the menu page.

    A Change at 9seeds

    Normally when we have BIG NEWS to announce, we’re really excited to share it with the World. Unfortunately, today’s news isn’t like that and has been one of the toughest posts I’ve had write.

    I am sad to announce that on February 14th, Shayne Sanderson will be leaving 9seeds.

    We know you have questions. Heck, we have a ton of them, too. But, let me answer what seem to be the two most important; why? and what now?

    The Why
    Things change. Situations change. Building a business is hard work and sometimes that can cause issues in other areas of your life. Shayne feels it’s best that he step away, refocus himself and his energy and try something different. We know that everybody loves a bit of drama. You are going to be sorely disappointed. There just isn’t any.

    The What Now
    Todd and I spoke at length about our plans for 9seeds. We are both really happy with the direction things are going and have every intention to continue on our path. We will continue to take on new development projects and we will most definitely continue working on our own plugins.

    Shayne has been in integral part of the growth of 9seeds over the past 16 months and we are going to miss having him on our team. Over the past two years Shayne and his wife Abbie have become part of our family. Both Todd and I have assured him that we are friends first and business partners second. Losing him as a partner hurts, losing him as a friend would be devastating.

    Best of luck my friend.

    New plugin: WP Chargify

    Early last year we were contacted by Jason Glaspey who was looking for a custom WordPress plugin. He wanted a plugin that would let a site admin hide content from the general public but make it available to paid members. While there are several plugins like that already available, this one would be different in that it would use Chargify as the payment processor. We agreed to the project and he hired us to build WP Chargify.

    Shortly after delivering the finished product, circumstances beyond Jason’s control forced him to shelf the project. Even though we had been paid for the project, we were still bummed since we like to see the plugins we write get used. After a few months went by, we didn’t really expect anything to happen with the plugin. We had basically written it off. Until last month…

    Last month we were contacted by two people who both had copies of the plugin. Jason had sent them our way saying that if they needed help, we were the guys to contact. After we helped them both out, Jason and I talked about the project and what the next step might be for the plugin. After a short discussion, we both agreed that making the plugin available to the WordPress community was the best thing to do!

    Here are some questions you may be wondering:

    What does that mean?
    Jason, the original owner of the code, is making the plugin a free, open source plugin. So that means, the WP Chargify plugin is available for you to download, use, modify or whatever else you want to do with it.

    Will more features be added?
    We (9seeds) will manage the plugin project, but it is being released as-is and at this time we have no plans to continue development on it. However, if you make any enhancements to the plugin that you think others could use as well, you can submit the patch to us and we will be happy to merge it in and release it at our discretion.

    What if I find a bug?
    You are welcome to submit a bug ticket and hopefully somebody in the community will be able to assist. We will be monitoring the forum as well. If you need help in a more urgent fashion, you can contact us and we’ll be happy to provide an estimate.

    Why would you release it if you don’t plan to support it?
    This plugin isn’t going to be for everybody. Hopefully another developer will find it, be able to make use of it and eventually take over continuing development on the project. If we can give that developer a head start with the code we’ve already written than it’s totally worth it.

    If you are a developer and interested in being part of the development team for WP Chargify, be sure to let us know!