When you’re building a plugin you of course want the best experience for the users. One part of this is the ability to easily install and use the plugin. The first time the plugin is installed, it would be great to be able to quickly navigate to the settings page if you have one, right after you’ve activated the plugin.

Having a link right next to (its actually below) your plugin would help users tremendously. You’ve probably already seen this on other plugin you’re using, and here’s how you can use it on your own plugins.

PS. These kind of links are called ‘Plugin action links’ in case you were wondering.

The plugin action links will only show up when the plugin is activated, so you won’t have to worry about hiding the settings link when the plugin isn’t active.

In the code snippet there are a couple things you’d need to change for your needs.

1) Function name
Change the function name to something else that no one else is using. Adding a prefix related to your plugin is best. If you use PHP namespaces you of course don’t have anything to worry about 🙂

Don’t forget to update the function name in the action hook which is at the bottom.

2) The link itself
Change the link and the text of the link to your needs. ‘Settings’ is the most common text thats used when linking to a settings page, and is highly recommended to use the same here.

If you want to add more then one link you can do so by adding extra array elements. Do try to keep the amount of links as low as possible here as it only clogs the user interface more.

3) Textdomain
The last thing that needs changing is the textdomain for the displayed text.

Positioning

The code snippet above positions the ‘Settings’ link before the standard ‘Deactivate’ link, which is the most used format. If you’d like to change the order / add a links after the default plugin action links you can do so by merging the links in reverse like so:

  • Jeroen Sormani

    I'm a professional WordPress plugin developer on a mission to create the best plugins for my clients. I'm specialised in developing general WordPress, WooCommerce and Easy Digital Downloads plugins.

    Interested in talking about a WordPress project? Get in touch!

    Follow me on Twitter
  • Leave a Reply