Hugh Lashbrooke

Community builder by day, tabletop game designer by night.

WordPress: Add plugin settings link to Plugins page

, ,

When building a plugin that has its own settings page, it’s often handy to create a link to the settings page straight from the Plugins list – this saves users the time it takes to find where exactly your plugin appears in the admin menu. Here is a simple code snippet that creates the settings link for you – all you need to do is tell it where to go:


View this gist on GitHub

Simply replace the href attribute with the link to the plugin settings page and rename the function to something slightly more unique (preferably all wrapped in an if(!function_exists()) conditional).

12 responses to “WordPress: Add plugin settings link to Plugins page”

  1. paul Avatar
    paul

    Thanks for the useful tip,

  2. avi Avatar
    avi

    Thanks for the nice post.
    however i recommend this little change to make Settings as the first link

    array_unshift($links, $settings_link);

  3. Telaga Sari Avatar
    Telaga Sari

    Nice tips, save time for me

  4. Dennis Hall Avatar
    Dennis Hall

    Hi: I really appreciate this post. It will allow me to (optionally) remove one page from the Admin menu, however, when I click the link, I get the “You do not have sufficient permissions to access this page” message. Any idea what would cause this?

    1. R Wickham Avatar
      R Wickham

      @Dennis_Hall This happens when you have an invalid url

  5. New WordPress Plugin Shows Users Where a Plugin’s Settings Link Is Upon Activation – WordPress Tavern

    […] to the above, I encourage plugin developers to read this article by Hugh Lashbrooke, that explains how to add a settings link to the plugins listing page. Adding a […]

  6. Danny Santoro Avatar
    Danny Santoro

    Hugh, I’ve been trying to figure this out forever now and kept putting it on the back burner because I was getting frustrated trying to Frankenstein code in from other plugins. You’re my hero.

    1. Hugh Avatar
      Hugh

      Always nice to be someone’s hero :p

  7. Sumon Avatar
    Sumon

    Thanks

  8. Rayan IT Avatar
    Rayan IT

    Thanks. So Good.

  9. model gorden rumah sakit Avatar
    model gorden rumah sakit

    I couldn’t refrain from ¤▓ommenting. Well written!

  10. tomaseklund Avatar
    tomaseklund

    I see you are hard coding the “options-general.php?page=plugin_name” part.

    I’ve found that menu_page_url( ‘ plugin_name’, false ) works too. Any particular reason you’re not using this function?

    I see that your post is rather old, from July 2012, but the function menu_page_url() has been around since WordPress version 3.0.0 which was released in June 2010.

    (Not trying to be a smart-ass. I’m genuinely trying to learn best coding practices for WordPress.)

Leave a Reply

Your email address will not be published. Required fields are marked *